app.js 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841
  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/assetinfo.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/assetinfo.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. props: ['asset'],
  1619. data: function data() {
  1620. return {
  1621. data: JSON.parse(this.asset)
  1622. };
  1623. },
  1624. mounted: function mounted() {
  1625. var _this = this;
  1626. Echo.channel('assets').listen('AssetUpdated', function (e) {
  1627. _this.data = JSON.parse(e.data);
  1628. });
  1629. }
  1630. });
  1631. /***/ }),
  1632. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1633. /*!*****************************************************************************************************************************************************************!*\
  1634. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  1635. \*****************************************************************************************************************************************************************/
  1636. /*! exports provided: default */
  1637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1638. "use strict";
  1639. __webpack_require__.r(__webpack_exports__);
  1640. //
  1641. //
  1642. //
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. /* harmony default export */ __webpack_exports__["default"] = ({
  1652. props: ['workOrder'],
  1653. data: function data() {
  1654. return {
  1655. data: JSON.parse(this.workOrder)
  1656. };
  1657. },
  1658. mounted: function mounted() {
  1659. var _this = this;
  1660. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1661. _this.data = JSON.parse(e.data);
  1662. });
  1663. }
  1664. });
  1665. /***/ }),
  1666. /***/ "./node_modules/base64-js/index.js":
  1667. /*!*****************************************!*\
  1668. !*** ./node_modules/base64-js/index.js ***!
  1669. \*****************************************/
  1670. /*! no static exports found */
  1671. /***/ (function(module, exports, __webpack_require__) {
  1672. "use strict";
  1673. exports.byteLength = byteLength
  1674. exports.toByteArray = toByteArray
  1675. exports.fromByteArray = fromByteArray
  1676. var lookup = []
  1677. var revLookup = []
  1678. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1679. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1680. for (var i = 0, len = code.length; i < len; ++i) {
  1681. lookup[i] = code[i]
  1682. revLookup[code.charCodeAt(i)] = i
  1683. }
  1684. // Support decoding URL-safe base64 strings, as Node.js does.
  1685. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1686. revLookup['-'.charCodeAt(0)] = 62
  1687. revLookup['_'.charCodeAt(0)] = 63
  1688. function getLens (b64) {
  1689. var len = b64.length
  1690. if (len % 4 > 0) {
  1691. throw new Error('Invalid string. Length must be a multiple of 4')
  1692. }
  1693. // Trim off extra bytes after placeholder bytes are found
  1694. // See: https://github.com/beatgammit/base64-js/issues/42
  1695. var validLen = b64.indexOf('=')
  1696. if (validLen === -1) validLen = len
  1697. var placeHoldersLen = validLen === len
  1698. ? 0
  1699. : 4 - (validLen % 4)
  1700. return [validLen, placeHoldersLen]
  1701. }
  1702. // base64 is 4/3 + up to two characters of the original data
  1703. function byteLength (b64) {
  1704. var lens = getLens(b64)
  1705. var validLen = lens[0]
  1706. var placeHoldersLen = lens[1]
  1707. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1708. }
  1709. function _byteLength (b64, validLen, placeHoldersLen) {
  1710. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1711. }
  1712. function toByteArray (b64) {
  1713. var tmp
  1714. var lens = getLens(b64)
  1715. var validLen = lens[0]
  1716. var placeHoldersLen = lens[1]
  1717. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1718. var curByte = 0
  1719. // if there are placeholders, only get up to the last complete 4 chars
  1720. var len = placeHoldersLen > 0
  1721. ? validLen - 4
  1722. : validLen
  1723. var i
  1724. for (i = 0; i < len; i += 4) {
  1725. tmp =
  1726. (revLookup[b64.charCodeAt(i)] << 18) |
  1727. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1728. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1729. revLookup[b64.charCodeAt(i + 3)]
  1730. arr[curByte++] = (tmp >> 16) & 0xFF
  1731. arr[curByte++] = (tmp >> 8) & 0xFF
  1732. arr[curByte++] = tmp & 0xFF
  1733. }
  1734. if (placeHoldersLen === 2) {
  1735. tmp =
  1736. (revLookup[b64.charCodeAt(i)] << 2) |
  1737. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1738. arr[curByte++] = tmp & 0xFF
  1739. }
  1740. if (placeHoldersLen === 1) {
  1741. tmp =
  1742. (revLookup[b64.charCodeAt(i)] << 10) |
  1743. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1744. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1745. arr[curByte++] = (tmp >> 8) & 0xFF
  1746. arr[curByte++] = tmp & 0xFF
  1747. }
  1748. return arr
  1749. }
  1750. function tripletToBase64 (num) {
  1751. return lookup[num >> 18 & 0x3F] +
  1752. lookup[num >> 12 & 0x3F] +
  1753. lookup[num >> 6 & 0x3F] +
  1754. lookup[num & 0x3F]
  1755. }
  1756. function encodeChunk (uint8, start, end) {
  1757. var tmp
  1758. var output = []
  1759. for (var i = start; i < end; i += 3) {
  1760. tmp =
  1761. ((uint8[i] << 16) & 0xFF0000) +
  1762. ((uint8[i + 1] << 8) & 0xFF00) +
  1763. (uint8[i + 2] & 0xFF)
  1764. output.push(tripletToBase64(tmp))
  1765. }
  1766. return output.join('')
  1767. }
  1768. function fromByteArray (uint8) {
  1769. var tmp
  1770. var len = uint8.length
  1771. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1772. var parts = []
  1773. var maxChunkLength = 16383 // must be multiple of 3
  1774. // go through the array every three bytes, we'll deal with trailing stuff later
  1775. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1776. parts.push(encodeChunk(
  1777. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1778. ))
  1779. }
  1780. // pad the end with zeros, but make sure to not forget the extra bytes
  1781. if (extraBytes === 1) {
  1782. tmp = uint8[len - 1]
  1783. parts.push(
  1784. lookup[tmp >> 2] +
  1785. lookup[(tmp << 4) & 0x3F] +
  1786. '=='
  1787. )
  1788. } else if (extraBytes === 2) {
  1789. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1790. parts.push(
  1791. lookup[tmp >> 10] +
  1792. lookup[(tmp >> 4) & 0x3F] +
  1793. lookup[(tmp << 2) & 0x3F] +
  1794. '='
  1795. )
  1796. }
  1797. return parts.join('')
  1798. }
  1799. /***/ }),
  1800. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1801. /*!*****************************************************!*\
  1802. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1803. \*****************************************************/
  1804. /*! no static exports found */
  1805. /***/ (function(module, exports, __webpack_require__) {
  1806. /*!
  1807. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1808. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1809. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1810. */
  1811. (function (global, factory) {
  1812. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1813. undefined;
  1814. }(this, (function (exports, $, Popper) { 'use strict';
  1815. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1816. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1817. function _defineProperties(target, props) {
  1818. for (var i = 0; i < props.length; i++) {
  1819. var descriptor = props[i];
  1820. descriptor.enumerable = descriptor.enumerable || false;
  1821. descriptor.configurable = true;
  1822. if ("value" in descriptor) descriptor.writable = true;
  1823. Object.defineProperty(target, descriptor.key, descriptor);
  1824. }
  1825. }
  1826. function _createClass(Constructor, protoProps, staticProps) {
  1827. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1828. if (staticProps) _defineProperties(Constructor, staticProps);
  1829. return Constructor;
  1830. }
  1831. function _defineProperty(obj, key, value) {
  1832. if (key in obj) {
  1833. Object.defineProperty(obj, key, {
  1834. value: value,
  1835. enumerable: true,
  1836. configurable: true,
  1837. writable: true
  1838. });
  1839. } else {
  1840. obj[key] = value;
  1841. }
  1842. return obj;
  1843. }
  1844. function ownKeys(object, enumerableOnly) {
  1845. var keys = Object.keys(object);
  1846. if (Object.getOwnPropertySymbols) {
  1847. var symbols = Object.getOwnPropertySymbols(object);
  1848. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1849. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1850. });
  1851. keys.push.apply(keys, symbols);
  1852. }
  1853. return keys;
  1854. }
  1855. function _objectSpread2(target) {
  1856. for (var i = 1; i < arguments.length; i++) {
  1857. var source = arguments[i] != null ? arguments[i] : {};
  1858. if (i % 2) {
  1859. ownKeys(Object(source), true).forEach(function (key) {
  1860. _defineProperty(target, key, source[key]);
  1861. });
  1862. } else if (Object.getOwnPropertyDescriptors) {
  1863. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1864. } else {
  1865. ownKeys(Object(source)).forEach(function (key) {
  1866. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1867. });
  1868. }
  1869. }
  1870. return target;
  1871. }
  1872. function _inheritsLoose(subClass, superClass) {
  1873. subClass.prototype = Object.create(superClass.prototype);
  1874. subClass.prototype.constructor = subClass;
  1875. subClass.__proto__ = superClass;
  1876. }
  1877. /**
  1878. * --------------------------------------------------------------------------
  1879. * Bootstrap (v4.4.1): util.js
  1880. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1881. * --------------------------------------------------------------------------
  1882. */
  1883. /**
  1884. * ------------------------------------------------------------------------
  1885. * Private TransitionEnd Helpers
  1886. * ------------------------------------------------------------------------
  1887. */
  1888. var TRANSITION_END = 'transitionend';
  1889. var MAX_UID = 1000000;
  1890. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1891. function toType(obj) {
  1892. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1893. }
  1894. function getSpecialTransitionEndEvent() {
  1895. return {
  1896. bindType: TRANSITION_END,
  1897. delegateType: TRANSITION_END,
  1898. handle: function handle(event) {
  1899. if ($(event.target).is(this)) {
  1900. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1901. }
  1902. return undefined; // eslint-disable-line no-undefined
  1903. }
  1904. };
  1905. }
  1906. function transitionEndEmulator(duration) {
  1907. var _this = this;
  1908. var called = false;
  1909. $(this).one(Util.TRANSITION_END, function () {
  1910. called = true;
  1911. });
  1912. setTimeout(function () {
  1913. if (!called) {
  1914. Util.triggerTransitionEnd(_this);
  1915. }
  1916. }, duration);
  1917. return this;
  1918. }
  1919. function setTransitionEndSupport() {
  1920. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1921. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1922. }
  1923. /**
  1924. * --------------------------------------------------------------------------
  1925. * Public Util Api
  1926. * --------------------------------------------------------------------------
  1927. */
  1928. var Util = {
  1929. TRANSITION_END: 'bsTransitionEnd',
  1930. getUID: function getUID(prefix) {
  1931. do {
  1932. // eslint-disable-next-line no-bitwise
  1933. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1934. } while (document.getElementById(prefix));
  1935. return prefix;
  1936. },
  1937. getSelectorFromElement: function getSelectorFromElement(element) {
  1938. var selector = element.getAttribute('data-target');
  1939. if (!selector || selector === '#') {
  1940. var hrefAttr = element.getAttribute('href');
  1941. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1942. }
  1943. try {
  1944. return document.querySelector(selector) ? selector : null;
  1945. } catch (err) {
  1946. return null;
  1947. }
  1948. },
  1949. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1950. if (!element) {
  1951. return 0;
  1952. } // Get transition-duration of the element
  1953. var transitionDuration = $(element).css('transition-duration');
  1954. var transitionDelay = $(element).css('transition-delay');
  1955. var floatTransitionDuration = parseFloat(transitionDuration);
  1956. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1957. if (!floatTransitionDuration && !floatTransitionDelay) {
  1958. return 0;
  1959. } // If multiple durations are defined, take the first
  1960. transitionDuration = transitionDuration.split(',')[0];
  1961. transitionDelay = transitionDelay.split(',')[0];
  1962. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1963. },
  1964. reflow: function reflow(element) {
  1965. return element.offsetHeight;
  1966. },
  1967. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1968. $(element).trigger(TRANSITION_END);
  1969. },
  1970. // TODO: Remove in v5
  1971. supportsTransitionEnd: function supportsTransitionEnd() {
  1972. return Boolean(TRANSITION_END);
  1973. },
  1974. isElement: function isElement(obj) {
  1975. return (obj[0] || obj).nodeType;
  1976. },
  1977. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1978. for (var property in configTypes) {
  1979. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1980. var expectedTypes = configTypes[property];
  1981. var value = config[property];
  1982. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1983. if (!new RegExp(expectedTypes).test(valueType)) {
  1984. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1985. }
  1986. }
  1987. }
  1988. },
  1989. findShadowRoot: function findShadowRoot(element) {
  1990. if (!document.documentElement.attachShadow) {
  1991. return null;
  1992. } // Can find the shadow root otherwise it'll return the document
  1993. if (typeof element.getRootNode === 'function') {
  1994. var root = element.getRootNode();
  1995. return root instanceof ShadowRoot ? root : null;
  1996. }
  1997. if (element instanceof ShadowRoot) {
  1998. return element;
  1999. } // when we don't find a shadow root
  2000. if (!element.parentNode) {
  2001. return null;
  2002. }
  2003. return Util.findShadowRoot(element.parentNode);
  2004. },
  2005. jQueryDetection: function jQueryDetection() {
  2006. if (typeof $ === 'undefined') {
  2007. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2008. }
  2009. var version = $.fn.jquery.split(' ')[0].split('.');
  2010. var minMajor = 1;
  2011. var ltMajor = 2;
  2012. var minMinor = 9;
  2013. var minPatch = 1;
  2014. var maxMajor = 4;
  2015. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2016. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2017. }
  2018. }
  2019. };
  2020. Util.jQueryDetection();
  2021. setTransitionEndSupport();
  2022. /**
  2023. * ------------------------------------------------------------------------
  2024. * Constants
  2025. * ------------------------------------------------------------------------
  2026. */
  2027. var NAME = 'alert';
  2028. var VERSION = '4.4.1';
  2029. var DATA_KEY = 'bs.alert';
  2030. var EVENT_KEY = "." + DATA_KEY;
  2031. var DATA_API_KEY = '.data-api';
  2032. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2033. var Selector = {
  2034. DISMISS: '[data-dismiss="alert"]'
  2035. };
  2036. var Event = {
  2037. CLOSE: "close" + EVENT_KEY,
  2038. CLOSED: "closed" + EVENT_KEY,
  2039. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2040. };
  2041. var ClassName = {
  2042. ALERT: 'alert',
  2043. FADE: 'fade',
  2044. SHOW: 'show'
  2045. };
  2046. /**
  2047. * ------------------------------------------------------------------------
  2048. * Class Definition
  2049. * ------------------------------------------------------------------------
  2050. */
  2051. var Alert =
  2052. /*#__PURE__*/
  2053. function () {
  2054. function Alert(element) {
  2055. this._element = element;
  2056. } // Getters
  2057. var _proto = Alert.prototype;
  2058. // Public
  2059. _proto.close = function close(element) {
  2060. var rootElement = this._element;
  2061. if (element) {
  2062. rootElement = this._getRootElement(element);
  2063. }
  2064. var customEvent = this._triggerCloseEvent(rootElement);
  2065. if (customEvent.isDefaultPrevented()) {
  2066. return;
  2067. }
  2068. this._removeElement(rootElement);
  2069. };
  2070. _proto.dispose = function dispose() {
  2071. $.removeData(this._element, DATA_KEY);
  2072. this._element = null;
  2073. } // Private
  2074. ;
  2075. _proto._getRootElement = function _getRootElement(element) {
  2076. var selector = Util.getSelectorFromElement(element);
  2077. var parent = false;
  2078. if (selector) {
  2079. parent = document.querySelector(selector);
  2080. }
  2081. if (!parent) {
  2082. parent = $(element).closest("." + ClassName.ALERT)[0];
  2083. }
  2084. return parent;
  2085. };
  2086. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2087. var closeEvent = $.Event(Event.CLOSE);
  2088. $(element).trigger(closeEvent);
  2089. return closeEvent;
  2090. };
  2091. _proto._removeElement = function _removeElement(element) {
  2092. var _this = this;
  2093. $(element).removeClass(ClassName.SHOW);
  2094. if (!$(element).hasClass(ClassName.FADE)) {
  2095. this._destroyElement(element);
  2096. return;
  2097. }
  2098. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2099. $(element).one(Util.TRANSITION_END, function (event) {
  2100. return _this._destroyElement(element, event);
  2101. }).emulateTransitionEnd(transitionDuration);
  2102. };
  2103. _proto._destroyElement = function _destroyElement(element) {
  2104. $(element).detach().trigger(Event.CLOSED).remove();
  2105. } // Static
  2106. ;
  2107. Alert._jQueryInterface = function _jQueryInterface(config) {
  2108. return this.each(function () {
  2109. var $element = $(this);
  2110. var data = $element.data(DATA_KEY);
  2111. if (!data) {
  2112. data = new Alert(this);
  2113. $element.data(DATA_KEY, data);
  2114. }
  2115. if (config === 'close') {
  2116. data[config](this);
  2117. }
  2118. });
  2119. };
  2120. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2121. return function (event) {
  2122. if (event) {
  2123. event.preventDefault();
  2124. }
  2125. alertInstance.close(this);
  2126. };
  2127. };
  2128. _createClass(Alert, null, [{
  2129. key: "VERSION",
  2130. get: function get() {
  2131. return VERSION;
  2132. }
  2133. }]);
  2134. return Alert;
  2135. }();
  2136. /**
  2137. * ------------------------------------------------------------------------
  2138. * Data Api implementation
  2139. * ------------------------------------------------------------------------
  2140. */
  2141. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2142. /**
  2143. * ------------------------------------------------------------------------
  2144. * jQuery
  2145. * ------------------------------------------------------------------------
  2146. */
  2147. $.fn[NAME] = Alert._jQueryInterface;
  2148. $.fn[NAME].Constructor = Alert;
  2149. $.fn[NAME].noConflict = function () {
  2150. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2151. return Alert._jQueryInterface;
  2152. };
  2153. /**
  2154. * ------------------------------------------------------------------------
  2155. * Constants
  2156. * ------------------------------------------------------------------------
  2157. */
  2158. var NAME$1 = 'button';
  2159. var VERSION$1 = '4.4.1';
  2160. var DATA_KEY$1 = 'bs.button';
  2161. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2162. var DATA_API_KEY$1 = '.data-api';
  2163. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2164. var ClassName$1 = {
  2165. ACTIVE: 'active',
  2166. BUTTON: 'btn',
  2167. FOCUS: 'focus'
  2168. };
  2169. var Selector$1 = {
  2170. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2171. DATA_TOGGLES: '[data-toggle="buttons"]',
  2172. DATA_TOGGLE: '[data-toggle="button"]',
  2173. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2174. INPUT: 'input:not([type="hidden"])',
  2175. ACTIVE: '.active',
  2176. BUTTON: '.btn'
  2177. };
  2178. var Event$1 = {
  2179. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2180. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2181. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2182. };
  2183. /**
  2184. * ------------------------------------------------------------------------
  2185. * Class Definition
  2186. * ------------------------------------------------------------------------
  2187. */
  2188. var Button =
  2189. /*#__PURE__*/
  2190. function () {
  2191. function Button(element) {
  2192. this._element = element;
  2193. } // Getters
  2194. var _proto = Button.prototype;
  2195. // Public
  2196. _proto.toggle = function toggle() {
  2197. var triggerChangeEvent = true;
  2198. var addAriaPressed = true;
  2199. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2200. if (rootElement) {
  2201. var input = this._element.querySelector(Selector$1.INPUT);
  2202. if (input) {
  2203. if (input.type === 'radio') {
  2204. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2205. triggerChangeEvent = false;
  2206. } else {
  2207. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2208. if (activeElement) {
  2209. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2210. }
  2211. }
  2212. } else if (input.type === 'checkbox') {
  2213. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2214. triggerChangeEvent = false;
  2215. }
  2216. } else {
  2217. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2218. triggerChangeEvent = false;
  2219. }
  2220. if (triggerChangeEvent) {
  2221. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2222. $(input).trigger('change');
  2223. }
  2224. input.focus();
  2225. addAriaPressed = false;
  2226. }
  2227. }
  2228. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2229. if (addAriaPressed) {
  2230. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2231. }
  2232. if (triggerChangeEvent) {
  2233. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2234. }
  2235. }
  2236. };
  2237. _proto.dispose = function dispose() {
  2238. $.removeData(this._element, DATA_KEY$1);
  2239. this._element = null;
  2240. } // Static
  2241. ;
  2242. Button._jQueryInterface = function _jQueryInterface(config) {
  2243. return this.each(function () {
  2244. var data = $(this).data(DATA_KEY$1);
  2245. if (!data) {
  2246. data = new Button(this);
  2247. $(this).data(DATA_KEY$1, data);
  2248. }
  2249. if (config === 'toggle') {
  2250. data[config]();
  2251. }
  2252. });
  2253. };
  2254. _createClass(Button, null, [{
  2255. key: "VERSION",
  2256. get: function get() {
  2257. return VERSION$1;
  2258. }
  2259. }]);
  2260. return Button;
  2261. }();
  2262. /**
  2263. * ------------------------------------------------------------------------
  2264. * Data Api implementation
  2265. * ------------------------------------------------------------------------
  2266. */
  2267. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2268. var button = event.target;
  2269. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2270. button = $(button).closest(Selector$1.BUTTON)[0];
  2271. }
  2272. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2273. event.preventDefault(); // work around Firefox bug #1540995
  2274. } else {
  2275. var inputBtn = button.querySelector(Selector$1.INPUT);
  2276. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2277. event.preventDefault(); // work around Firefox bug #1540995
  2278. return;
  2279. }
  2280. Button._jQueryInterface.call($(button), 'toggle');
  2281. }
  2282. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2283. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2284. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2285. });
  2286. $(window).on(Event$1.LOAD_DATA_API, function () {
  2287. // ensure correct active class is set to match the controls' actual values/states
  2288. // find all checkboxes/readio buttons inside data-toggle groups
  2289. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2290. for (var i = 0, len = buttons.length; i < len; i++) {
  2291. var button = buttons[i];
  2292. var input = button.querySelector(Selector$1.INPUT);
  2293. if (input.checked || input.hasAttribute('checked')) {
  2294. button.classList.add(ClassName$1.ACTIVE);
  2295. } else {
  2296. button.classList.remove(ClassName$1.ACTIVE);
  2297. }
  2298. } // find all button toggles
  2299. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2300. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2301. var _button = buttons[_i];
  2302. if (_button.getAttribute('aria-pressed') === 'true') {
  2303. _button.classList.add(ClassName$1.ACTIVE);
  2304. } else {
  2305. _button.classList.remove(ClassName$1.ACTIVE);
  2306. }
  2307. }
  2308. });
  2309. /**
  2310. * ------------------------------------------------------------------------
  2311. * jQuery
  2312. * ------------------------------------------------------------------------
  2313. */
  2314. $.fn[NAME$1] = Button._jQueryInterface;
  2315. $.fn[NAME$1].Constructor = Button;
  2316. $.fn[NAME$1].noConflict = function () {
  2317. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2318. return Button._jQueryInterface;
  2319. };
  2320. /**
  2321. * ------------------------------------------------------------------------
  2322. * Constants
  2323. * ------------------------------------------------------------------------
  2324. */
  2325. var NAME$2 = 'carousel';
  2326. var VERSION$2 = '4.4.1';
  2327. var DATA_KEY$2 = 'bs.carousel';
  2328. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2329. var DATA_API_KEY$2 = '.data-api';
  2330. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2331. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2332. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2333. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2334. var SWIPE_THRESHOLD = 40;
  2335. var Default = {
  2336. interval: 5000,
  2337. keyboard: true,
  2338. slide: false,
  2339. pause: 'hover',
  2340. wrap: true,
  2341. touch: true
  2342. };
  2343. var DefaultType = {
  2344. interval: '(number|boolean)',
  2345. keyboard: 'boolean',
  2346. slide: '(boolean|string)',
  2347. pause: '(string|boolean)',
  2348. wrap: 'boolean',
  2349. touch: 'boolean'
  2350. };
  2351. var Direction = {
  2352. NEXT: 'next',
  2353. PREV: 'prev',
  2354. LEFT: 'left',
  2355. RIGHT: 'right'
  2356. };
  2357. var Event$2 = {
  2358. SLIDE: "slide" + EVENT_KEY$2,
  2359. SLID: "slid" + EVENT_KEY$2,
  2360. KEYDOWN: "keydown" + EVENT_KEY$2,
  2361. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2362. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2363. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2364. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2365. TOUCHEND: "touchend" + EVENT_KEY$2,
  2366. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2367. POINTERUP: "pointerup" + EVENT_KEY$2,
  2368. DRAG_START: "dragstart" + EVENT_KEY$2,
  2369. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2370. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2371. };
  2372. var ClassName$2 = {
  2373. CAROUSEL: 'carousel',
  2374. ACTIVE: 'active',
  2375. SLIDE: 'slide',
  2376. RIGHT: 'carousel-item-right',
  2377. LEFT: 'carousel-item-left',
  2378. NEXT: 'carousel-item-next',
  2379. PREV: 'carousel-item-prev',
  2380. ITEM: 'carousel-item',
  2381. POINTER_EVENT: 'pointer-event'
  2382. };
  2383. var Selector$2 = {
  2384. ACTIVE: '.active',
  2385. ACTIVE_ITEM: '.active.carousel-item',
  2386. ITEM: '.carousel-item',
  2387. ITEM_IMG: '.carousel-item img',
  2388. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2389. INDICATORS: '.carousel-indicators',
  2390. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2391. DATA_RIDE: '[data-ride="carousel"]'
  2392. };
  2393. var PointerType = {
  2394. TOUCH: 'touch',
  2395. PEN: 'pen'
  2396. };
  2397. /**
  2398. * ------------------------------------------------------------------------
  2399. * Class Definition
  2400. * ------------------------------------------------------------------------
  2401. */
  2402. var Carousel =
  2403. /*#__PURE__*/
  2404. function () {
  2405. function Carousel(element, config) {
  2406. this._items = null;
  2407. this._interval = null;
  2408. this._activeElement = null;
  2409. this._isPaused = false;
  2410. this._isSliding = false;
  2411. this.touchTimeout = null;
  2412. this.touchStartX = 0;
  2413. this.touchDeltaX = 0;
  2414. this._config = this._getConfig(config);
  2415. this._element = element;
  2416. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2417. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2418. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2419. this._addEventListeners();
  2420. } // Getters
  2421. var _proto = Carousel.prototype;
  2422. // Public
  2423. _proto.next = function next() {
  2424. if (!this._isSliding) {
  2425. this._slide(Direction.NEXT);
  2426. }
  2427. };
  2428. _proto.nextWhenVisible = function nextWhenVisible() {
  2429. // Don't call next when the page isn't visible
  2430. // or the carousel or its parent isn't visible
  2431. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2432. this.next();
  2433. }
  2434. };
  2435. _proto.prev = function prev() {
  2436. if (!this._isSliding) {
  2437. this._slide(Direction.PREV);
  2438. }
  2439. };
  2440. _proto.pause = function pause(event) {
  2441. if (!event) {
  2442. this._isPaused = true;
  2443. }
  2444. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2445. Util.triggerTransitionEnd(this._element);
  2446. this.cycle(true);
  2447. }
  2448. clearInterval(this._interval);
  2449. this._interval = null;
  2450. };
  2451. _proto.cycle = function cycle(event) {
  2452. if (!event) {
  2453. this._isPaused = false;
  2454. }
  2455. if (this._interval) {
  2456. clearInterval(this._interval);
  2457. this._interval = null;
  2458. }
  2459. if (this._config.interval && !this._isPaused) {
  2460. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2461. }
  2462. };
  2463. _proto.to = function to(index) {
  2464. var _this = this;
  2465. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2466. var activeIndex = this._getItemIndex(this._activeElement);
  2467. if (index > this._items.length - 1 || index < 0) {
  2468. return;
  2469. }
  2470. if (this._isSliding) {
  2471. $(this._element).one(Event$2.SLID, function () {
  2472. return _this.to(index);
  2473. });
  2474. return;
  2475. }
  2476. if (activeIndex === index) {
  2477. this.pause();
  2478. this.cycle();
  2479. return;
  2480. }
  2481. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2482. this._slide(direction, this._items[index]);
  2483. };
  2484. _proto.dispose = function dispose() {
  2485. $(this._element).off(EVENT_KEY$2);
  2486. $.removeData(this._element, DATA_KEY$2);
  2487. this._items = null;
  2488. this._config = null;
  2489. this._element = null;
  2490. this._interval = null;
  2491. this._isPaused = null;
  2492. this._isSliding = null;
  2493. this._activeElement = null;
  2494. this._indicatorsElement = null;
  2495. } // Private
  2496. ;
  2497. _proto._getConfig = function _getConfig(config) {
  2498. config = _objectSpread2({}, Default, {}, config);
  2499. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2500. return config;
  2501. };
  2502. _proto._handleSwipe = function _handleSwipe() {
  2503. var absDeltax = Math.abs(this.touchDeltaX);
  2504. if (absDeltax <= SWIPE_THRESHOLD) {
  2505. return;
  2506. }
  2507. var direction = absDeltax / this.touchDeltaX;
  2508. this.touchDeltaX = 0; // swipe left
  2509. if (direction > 0) {
  2510. this.prev();
  2511. } // swipe right
  2512. if (direction < 0) {
  2513. this.next();
  2514. }
  2515. };
  2516. _proto._addEventListeners = function _addEventListeners() {
  2517. var _this2 = this;
  2518. if (this._config.keyboard) {
  2519. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2520. return _this2._keydown(event);
  2521. });
  2522. }
  2523. if (this._config.pause === 'hover') {
  2524. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2525. return _this2.pause(event);
  2526. }).on(Event$2.MOUSELEAVE, function (event) {
  2527. return _this2.cycle(event);
  2528. });
  2529. }
  2530. if (this._config.touch) {
  2531. this._addTouchEventListeners();
  2532. }
  2533. };
  2534. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2535. var _this3 = this;
  2536. if (!this._touchSupported) {
  2537. return;
  2538. }
  2539. var start = function start(event) {
  2540. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2541. _this3.touchStartX = event.originalEvent.clientX;
  2542. } else if (!_this3._pointerEvent) {
  2543. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2544. }
  2545. };
  2546. var move = function move(event) {
  2547. // ensure swiping with one touch and not pinching
  2548. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2549. _this3.touchDeltaX = 0;
  2550. } else {
  2551. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2552. }
  2553. };
  2554. var end = function end(event) {
  2555. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2556. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2557. }
  2558. _this3._handleSwipe();
  2559. if (_this3._config.pause === 'hover') {
  2560. // If it's a touch-enabled device, mouseenter/leave are fired as
  2561. // part of the mouse compatibility events on first tap - the carousel
  2562. // would stop cycling until user tapped out of it;
  2563. // here, we listen for touchend, explicitly pause the carousel
  2564. // (as if it's the second time we tap on it, mouseenter compat event
  2565. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2566. // events to fire) we explicitly restart cycling
  2567. _this3.pause();
  2568. if (_this3.touchTimeout) {
  2569. clearTimeout(_this3.touchTimeout);
  2570. }
  2571. _this3.touchTimeout = setTimeout(function (event) {
  2572. return _this3.cycle(event);
  2573. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2574. }
  2575. };
  2576. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2577. return e.preventDefault();
  2578. });
  2579. if (this._pointerEvent) {
  2580. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2581. return start(event);
  2582. });
  2583. $(this._element).on(Event$2.POINTERUP, function (event) {
  2584. return end(event);
  2585. });
  2586. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2587. } else {
  2588. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2589. return start(event);
  2590. });
  2591. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2592. return move(event);
  2593. });
  2594. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2595. return end(event);
  2596. });
  2597. }
  2598. };
  2599. _proto._keydown = function _keydown(event) {
  2600. if (/input|textarea/i.test(event.target.tagName)) {
  2601. return;
  2602. }
  2603. switch (event.which) {
  2604. case ARROW_LEFT_KEYCODE:
  2605. event.preventDefault();
  2606. this.prev();
  2607. break;
  2608. case ARROW_RIGHT_KEYCODE:
  2609. event.preventDefault();
  2610. this.next();
  2611. break;
  2612. }
  2613. };
  2614. _proto._getItemIndex = function _getItemIndex(element) {
  2615. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2616. return this._items.indexOf(element);
  2617. };
  2618. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2619. var isNextDirection = direction === Direction.NEXT;
  2620. var isPrevDirection = direction === Direction.PREV;
  2621. var activeIndex = this._getItemIndex(activeElement);
  2622. var lastItemIndex = this._items.length - 1;
  2623. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2624. if (isGoingToWrap && !this._config.wrap) {
  2625. return activeElement;
  2626. }
  2627. var delta = direction === Direction.PREV ? -1 : 1;
  2628. var itemIndex = (activeIndex + delta) % this._items.length;
  2629. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2630. };
  2631. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2632. var targetIndex = this._getItemIndex(relatedTarget);
  2633. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2634. var slideEvent = $.Event(Event$2.SLIDE, {
  2635. relatedTarget: relatedTarget,
  2636. direction: eventDirectionName,
  2637. from: fromIndex,
  2638. to: targetIndex
  2639. });
  2640. $(this._element).trigger(slideEvent);
  2641. return slideEvent;
  2642. };
  2643. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2644. if (this._indicatorsElement) {
  2645. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2646. $(indicators).removeClass(ClassName$2.ACTIVE);
  2647. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2648. if (nextIndicator) {
  2649. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2650. }
  2651. }
  2652. };
  2653. _proto._slide = function _slide(direction, element) {
  2654. var _this4 = this;
  2655. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2656. var activeElementIndex = this._getItemIndex(activeElement);
  2657. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2658. var nextElementIndex = this._getItemIndex(nextElement);
  2659. var isCycling = Boolean(this._interval);
  2660. var directionalClassName;
  2661. var orderClassName;
  2662. var eventDirectionName;
  2663. if (direction === Direction.NEXT) {
  2664. directionalClassName = ClassName$2.LEFT;
  2665. orderClassName = ClassName$2.NEXT;
  2666. eventDirectionName = Direction.LEFT;
  2667. } else {
  2668. directionalClassName = ClassName$2.RIGHT;
  2669. orderClassName = ClassName$2.PREV;
  2670. eventDirectionName = Direction.RIGHT;
  2671. }
  2672. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2673. this._isSliding = false;
  2674. return;
  2675. }
  2676. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2677. if (slideEvent.isDefaultPrevented()) {
  2678. return;
  2679. }
  2680. if (!activeElement || !nextElement) {
  2681. // Some weirdness is happening, so we bail
  2682. return;
  2683. }
  2684. this._isSliding = true;
  2685. if (isCycling) {
  2686. this.pause();
  2687. }
  2688. this._setActiveIndicatorElement(nextElement);
  2689. var slidEvent = $.Event(Event$2.SLID, {
  2690. relatedTarget: nextElement,
  2691. direction: eventDirectionName,
  2692. from: activeElementIndex,
  2693. to: nextElementIndex
  2694. });
  2695. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2696. $(nextElement).addClass(orderClassName);
  2697. Util.reflow(nextElement);
  2698. $(activeElement).addClass(directionalClassName);
  2699. $(nextElement).addClass(directionalClassName);
  2700. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2701. if (nextElementInterval) {
  2702. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2703. this._config.interval = nextElementInterval;
  2704. } else {
  2705. this._config.interval = this._config.defaultInterval || this._config.interval;
  2706. }
  2707. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2708. $(activeElement).one(Util.TRANSITION_END, function () {
  2709. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2710. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2711. _this4._isSliding = false;
  2712. setTimeout(function () {
  2713. return $(_this4._element).trigger(slidEvent);
  2714. }, 0);
  2715. }).emulateTransitionEnd(transitionDuration);
  2716. } else {
  2717. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2718. $(nextElement).addClass(ClassName$2.ACTIVE);
  2719. this._isSliding = false;
  2720. $(this._element).trigger(slidEvent);
  2721. }
  2722. if (isCycling) {
  2723. this.cycle();
  2724. }
  2725. } // Static
  2726. ;
  2727. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2728. return this.each(function () {
  2729. var data = $(this).data(DATA_KEY$2);
  2730. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2731. if (typeof config === 'object') {
  2732. _config = _objectSpread2({}, _config, {}, config);
  2733. }
  2734. var action = typeof config === 'string' ? config : _config.slide;
  2735. if (!data) {
  2736. data = new Carousel(this, _config);
  2737. $(this).data(DATA_KEY$2, data);
  2738. }
  2739. if (typeof config === 'number') {
  2740. data.to(config);
  2741. } else if (typeof action === 'string') {
  2742. if (typeof data[action] === 'undefined') {
  2743. throw new TypeError("No method named \"" + action + "\"");
  2744. }
  2745. data[action]();
  2746. } else if (_config.interval && _config.ride) {
  2747. data.pause();
  2748. data.cycle();
  2749. }
  2750. });
  2751. };
  2752. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2753. var selector = Util.getSelectorFromElement(this);
  2754. if (!selector) {
  2755. return;
  2756. }
  2757. var target = $(selector)[0];
  2758. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2759. return;
  2760. }
  2761. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2762. var slideIndex = this.getAttribute('data-slide-to');
  2763. if (slideIndex) {
  2764. config.interval = false;
  2765. }
  2766. Carousel._jQueryInterface.call($(target), config);
  2767. if (slideIndex) {
  2768. $(target).data(DATA_KEY$2).to(slideIndex);
  2769. }
  2770. event.preventDefault();
  2771. };
  2772. _createClass(Carousel, null, [{
  2773. key: "VERSION",
  2774. get: function get() {
  2775. return VERSION$2;
  2776. }
  2777. }, {
  2778. key: "Default",
  2779. get: function get() {
  2780. return Default;
  2781. }
  2782. }]);
  2783. return Carousel;
  2784. }();
  2785. /**
  2786. * ------------------------------------------------------------------------
  2787. * Data Api implementation
  2788. * ------------------------------------------------------------------------
  2789. */
  2790. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2791. $(window).on(Event$2.LOAD_DATA_API, function () {
  2792. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2793. for (var i = 0, len = carousels.length; i < len; i++) {
  2794. var $carousel = $(carousels[i]);
  2795. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2796. }
  2797. });
  2798. /**
  2799. * ------------------------------------------------------------------------
  2800. * jQuery
  2801. * ------------------------------------------------------------------------
  2802. */
  2803. $.fn[NAME$2] = Carousel._jQueryInterface;
  2804. $.fn[NAME$2].Constructor = Carousel;
  2805. $.fn[NAME$2].noConflict = function () {
  2806. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2807. return Carousel._jQueryInterface;
  2808. };
  2809. /**
  2810. * ------------------------------------------------------------------------
  2811. * Constants
  2812. * ------------------------------------------------------------------------
  2813. */
  2814. var NAME$3 = 'collapse';
  2815. var VERSION$3 = '4.4.1';
  2816. var DATA_KEY$3 = 'bs.collapse';
  2817. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2818. var DATA_API_KEY$3 = '.data-api';
  2819. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2820. var Default$1 = {
  2821. toggle: true,
  2822. parent: ''
  2823. };
  2824. var DefaultType$1 = {
  2825. toggle: 'boolean',
  2826. parent: '(string|element)'
  2827. };
  2828. var Event$3 = {
  2829. SHOW: "show" + EVENT_KEY$3,
  2830. SHOWN: "shown" + EVENT_KEY$3,
  2831. HIDE: "hide" + EVENT_KEY$3,
  2832. HIDDEN: "hidden" + EVENT_KEY$3,
  2833. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2834. };
  2835. var ClassName$3 = {
  2836. SHOW: 'show',
  2837. COLLAPSE: 'collapse',
  2838. COLLAPSING: 'collapsing',
  2839. COLLAPSED: 'collapsed'
  2840. };
  2841. var Dimension = {
  2842. WIDTH: 'width',
  2843. HEIGHT: 'height'
  2844. };
  2845. var Selector$3 = {
  2846. ACTIVES: '.show, .collapsing',
  2847. DATA_TOGGLE: '[data-toggle="collapse"]'
  2848. };
  2849. /**
  2850. * ------------------------------------------------------------------------
  2851. * Class Definition
  2852. * ------------------------------------------------------------------------
  2853. */
  2854. var Collapse =
  2855. /*#__PURE__*/
  2856. function () {
  2857. function Collapse(element, config) {
  2858. this._isTransitioning = false;
  2859. this._element = element;
  2860. this._config = this._getConfig(config);
  2861. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2862. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2863. for (var i = 0, len = toggleList.length; i < len; i++) {
  2864. var elem = toggleList[i];
  2865. var selector = Util.getSelectorFromElement(elem);
  2866. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2867. return foundElem === element;
  2868. });
  2869. if (selector !== null && filterElement.length > 0) {
  2870. this._selector = selector;
  2871. this._triggerArray.push(elem);
  2872. }
  2873. }
  2874. this._parent = this._config.parent ? this._getParent() : null;
  2875. if (!this._config.parent) {
  2876. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2877. }
  2878. if (this._config.toggle) {
  2879. this.toggle();
  2880. }
  2881. } // Getters
  2882. var _proto = Collapse.prototype;
  2883. // Public
  2884. _proto.toggle = function toggle() {
  2885. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2886. this.hide();
  2887. } else {
  2888. this.show();
  2889. }
  2890. };
  2891. _proto.show = function show() {
  2892. var _this = this;
  2893. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2894. return;
  2895. }
  2896. var actives;
  2897. var activesData;
  2898. if (this._parent) {
  2899. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2900. if (typeof _this._config.parent === 'string') {
  2901. return elem.getAttribute('data-parent') === _this._config.parent;
  2902. }
  2903. return elem.classList.contains(ClassName$3.COLLAPSE);
  2904. });
  2905. if (actives.length === 0) {
  2906. actives = null;
  2907. }
  2908. }
  2909. if (actives) {
  2910. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2911. if (activesData && activesData._isTransitioning) {
  2912. return;
  2913. }
  2914. }
  2915. var startEvent = $.Event(Event$3.SHOW);
  2916. $(this._element).trigger(startEvent);
  2917. if (startEvent.isDefaultPrevented()) {
  2918. return;
  2919. }
  2920. if (actives) {
  2921. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2922. if (!activesData) {
  2923. $(actives).data(DATA_KEY$3, null);
  2924. }
  2925. }
  2926. var dimension = this._getDimension();
  2927. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2928. this._element.style[dimension] = 0;
  2929. if (this._triggerArray.length) {
  2930. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2931. }
  2932. this.setTransitioning(true);
  2933. var complete = function complete() {
  2934. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2935. _this._element.style[dimension] = '';
  2936. _this.setTransitioning(false);
  2937. $(_this._element).trigger(Event$3.SHOWN);
  2938. };
  2939. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2940. var scrollSize = "scroll" + capitalizedDimension;
  2941. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2942. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2943. this._element.style[dimension] = this._element[scrollSize] + "px";
  2944. };
  2945. _proto.hide = function hide() {
  2946. var _this2 = this;
  2947. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2948. return;
  2949. }
  2950. var startEvent = $.Event(Event$3.HIDE);
  2951. $(this._element).trigger(startEvent);
  2952. if (startEvent.isDefaultPrevented()) {
  2953. return;
  2954. }
  2955. var dimension = this._getDimension();
  2956. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2957. Util.reflow(this._element);
  2958. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2959. var triggerArrayLength = this._triggerArray.length;
  2960. if (triggerArrayLength > 0) {
  2961. for (var i = 0; i < triggerArrayLength; i++) {
  2962. var trigger = this._triggerArray[i];
  2963. var selector = Util.getSelectorFromElement(trigger);
  2964. if (selector !== null) {
  2965. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2966. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2967. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2968. }
  2969. }
  2970. }
  2971. }
  2972. this.setTransitioning(true);
  2973. var complete = function complete() {
  2974. _this2.setTransitioning(false);
  2975. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2976. };
  2977. this._element.style[dimension] = '';
  2978. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2979. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2980. };
  2981. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2982. this._isTransitioning = isTransitioning;
  2983. };
  2984. _proto.dispose = function dispose() {
  2985. $.removeData(this._element, DATA_KEY$3);
  2986. this._config = null;
  2987. this._parent = null;
  2988. this._element = null;
  2989. this._triggerArray = null;
  2990. this._isTransitioning = null;
  2991. } // Private
  2992. ;
  2993. _proto._getConfig = function _getConfig(config) {
  2994. config = _objectSpread2({}, Default$1, {}, config);
  2995. config.toggle = Boolean(config.toggle); // Coerce string values
  2996. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  2997. return config;
  2998. };
  2999. _proto._getDimension = function _getDimension() {
  3000. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3001. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3002. };
  3003. _proto._getParent = function _getParent() {
  3004. var _this3 = this;
  3005. var parent;
  3006. if (Util.isElement(this._config.parent)) {
  3007. parent = this._config.parent; // It's a jQuery object
  3008. if (typeof this._config.parent.jquery !== 'undefined') {
  3009. parent = this._config.parent[0];
  3010. }
  3011. } else {
  3012. parent = document.querySelector(this._config.parent);
  3013. }
  3014. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3015. var children = [].slice.call(parent.querySelectorAll(selector));
  3016. $(children).each(function (i, element) {
  3017. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3018. });
  3019. return parent;
  3020. };
  3021. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3022. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3023. if (triggerArray.length) {
  3024. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3025. }
  3026. } // Static
  3027. ;
  3028. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3029. var selector = Util.getSelectorFromElement(element);
  3030. return selector ? document.querySelector(selector) : null;
  3031. };
  3032. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3033. return this.each(function () {
  3034. var $this = $(this);
  3035. var data = $this.data(DATA_KEY$3);
  3036. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3037. if (!data && _config.toggle && /show|hide/.test(config)) {
  3038. _config.toggle = false;
  3039. }
  3040. if (!data) {
  3041. data = new Collapse(this, _config);
  3042. $this.data(DATA_KEY$3, data);
  3043. }
  3044. if (typeof config === 'string') {
  3045. if (typeof data[config] === 'undefined') {
  3046. throw new TypeError("No method named \"" + config + "\"");
  3047. }
  3048. data[config]();
  3049. }
  3050. });
  3051. };
  3052. _createClass(Collapse, null, [{
  3053. key: "VERSION",
  3054. get: function get() {
  3055. return VERSION$3;
  3056. }
  3057. }, {
  3058. key: "Default",
  3059. get: function get() {
  3060. return Default$1;
  3061. }
  3062. }]);
  3063. return Collapse;
  3064. }();
  3065. /**
  3066. * ------------------------------------------------------------------------
  3067. * Data Api implementation
  3068. * ------------------------------------------------------------------------
  3069. */
  3070. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3071. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3072. if (event.currentTarget.tagName === 'A') {
  3073. event.preventDefault();
  3074. }
  3075. var $trigger = $(this);
  3076. var selector = Util.getSelectorFromElement(this);
  3077. var selectors = [].slice.call(document.querySelectorAll(selector));
  3078. $(selectors).each(function () {
  3079. var $target = $(this);
  3080. var data = $target.data(DATA_KEY$3);
  3081. var config = data ? 'toggle' : $trigger.data();
  3082. Collapse._jQueryInterface.call($target, config);
  3083. });
  3084. });
  3085. /**
  3086. * ------------------------------------------------------------------------
  3087. * jQuery
  3088. * ------------------------------------------------------------------------
  3089. */
  3090. $.fn[NAME$3] = Collapse._jQueryInterface;
  3091. $.fn[NAME$3].Constructor = Collapse;
  3092. $.fn[NAME$3].noConflict = function () {
  3093. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3094. return Collapse._jQueryInterface;
  3095. };
  3096. /**
  3097. * ------------------------------------------------------------------------
  3098. * Constants
  3099. * ------------------------------------------------------------------------
  3100. */
  3101. var NAME$4 = 'dropdown';
  3102. var VERSION$4 = '4.4.1';
  3103. var DATA_KEY$4 = 'bs.dropdown';
  3104. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3105. var DATA_API_KEY$4 = '.data-api';
  3106. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3107. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3108. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3109. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3110. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3111. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3112. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3113. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3114. var Event$4 = {
  3115. HIDE: "hide" + EVENT_KEY$4,
  3116. HIDDEN: "hidden" + EVENT_KEY$4,
  3117. SHOW: "show" + EVENT_KEY$4,
  3118. SHOWN: "shown" + EVENT_KEY$4,
  3119. CLICK: "click" + EVENT_KEY$4,
  3120. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3121. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3122. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3123. };
  3124. var ClassName$4 = {
  3125. DISABLED: 'disabled',
  3126. SHOW: 'show',
  3127. DROPUP: 'dropup',
  3128. DROPRIGHT: 'dropright',
  3129. DROPLEFT: 'dropleft',
  3130. MENURIGHT: 'dropdown-menu-right',
  3131. MENULEFT: 'dropdown-menu-left',
  3132. POSITION_STATIC: 'position-static'
  3133. };
  3134. var Selector$4 = {
  3135. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3136. FORM_CHILD: '.dropdown form',
  3137. MENU: '.dropdown-menu',
  3138. NAVBAR_NAV: '.navbar-nav',
  3139. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3140. };
  3141. var AttachmentMap = {
  3142. TOP: 'top-start',
  3143. TOPEND: 'top-end',
  3144. BOTTOM: 'bottom-start',
  3145. BOTTOMEND: 'bottom-end',
  3146. RIGHT: 'right-start',
  3147. RIGHTEND: 'right-end',
  3148. LEFT: 'left-start',
  3149. LEFTEND: 'left-end'
  3150. };
  3151. var Default$2 = {
  3152. offset: 0,
  3153. flip: true,
  3154. boundary: 'scrollParent',
  3155. reference: 'toggle',
  3156. display: 'dynamic',
  3157. popperConfig: null
  3158. };
  3159. var DefaultType$2 = {
  3160. offset: '(number|string|function)',
  3161. flip: 'boolean',
  3162. boundary: '(string|element)',
  3163. reference: '(string|element)',
  3164. display: 'string',
  3165. popperConfig: '(null|object)'
  3166. };
  3167. /**
  3168. * ------------------------------------------------------------------------
  3169. * Class Definition
  3170. * ------------------------------------------------------------------------
  3171. */
  3172. var Dropdown =
  3173. /*#__PURE__*/
  3174. function () {
  3175. function Dropdown(element, config) {
  3176. this._element = element;
  3177. this._popper = null;
  3178. this._config = this._getConfig(config);
  3179. this._menu = this._getMenuElement();
  3180. this._inNavbar = this._detectNavbar();
  3181. this._addEventListeners();
  3182. } // Getters
  3183. var _proto = Dropdown.prototype;
  3184. // Public
  3185. _proto.toggle = function toggle() {
  3186. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3187. return;
  3188. }
  3189. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3190. Dropdown._clearMenus();
  3191. if (isActive) {
  3192. return;
  3193. }
  3194. this.show(true);
  3195. };
  3196. _proto.show = function show(usePopper) {
  3197. if (usePopper === void 0) {
  3198. usePopper = false;
  3199. }
  3200. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3201. return;
  3202. }
  3203. var relatedTarget = {
  3204. relatedTarget: this._element
  3205. };
  3206. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3207. var parent = Dropdown._getParentFromElement(this._element);
  3208. $(parent).trigger(showEvent);
  3209. if (showEvent.isDefaultPrevented()) {
  3210. return;
  3211. } // Disable totally Popper.js for Dropdown in Navbar
  3212. if (!this._inNavbar && usePopper) {
  3213. /**
  3214. * Check for Popper dependency
  3215. * Popper - https://popper.js.org
  3216. */
  3217. if (typeof Popper === 'undefined') {
  3218. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3219. }
  3220. var referenceElement = this._element;
  3221. if (this._config.reference === 'parent') {
  3222. referenceElement = parent;
  3223. } else if (Util.isElement(this._config.reference)) {
  3224. referenceElement = this._config.reference; // Check if it's jQuery element
  3225. if (typeof this._config.reference.jquery !== 'undefined') {
  3226. referenceElement = this._config.reference[0];
  3227. }
  3228. } // If boundary is not `scrollParent`, then set position to `static`
  3229. // to allow the menu to "escape" the scroll parent's boundaries
  3230. // https://github.com/twbs/bootstrap/issues/24251
  3231. if (this._config.boundary !== 'scrollParent') {
  3232. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3233. }
  3234. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3235. } // If this is a touch-enabled device we add extra
  3236. // empty mouseover listeners to the body's immediate children;
  3237. // only needed because of broken event delegation on iOS
  3238. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3239. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3240. $(document.body).children().on('mouseover', null, $.noop);
  3241. }
  3242. this._element.focus();
  3243. this._element.setAttribute('aria-expanded', true);
  3244. $(this._menu).toggleClass(ClassName$4.SHOW);
  3245. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3246. };
  3247. _proto.hide = function hide() {
  3248. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3249. return;
  3250. }
  3251. var relatedTarget = {
  3252. relatedTarget: this._element
  3253. };
  3254. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3255. var parent = Dropdown._getParentFromElement(this._element);
  3256. $(parent).trigger(hideEvent);
  3257. if (hideEvent.isDefaultPrevented()) {
  3258. return;
  3259. }
  3260. if (this._popper) {
  3261. this._popper.destroy();
  3262. }
  3263. $(this._menu).toggleClass(ClassName$4.SHOW);
  3264. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3265. };
  3266. _proto.dispose = function dispose() {
  3267. $.removeData(this._element, DATA_KEY$4);
  3268. $(this._element).off(EVENT_KEY$4);
  3269. this._element = null;
  3270. this._menu = null;
  3271. if (this._popper !== null) {
  3272. this._popper.destroy();
  3273. this._popper = null;
  3274. }
  3275. };
  3276. _proto.update = function update() {
  3277. this._inNavbar = this._detectNavbar();
  3278. if (this._popper !== null) {
  3279. this._popper.scheduleUpdate();
  3280. }
  3281. } // Private
  3282. ;
  3283. _proto._addEventListeners = function _addEventListeners() {
  3284. var _this = this;
  3285. $(this._element).on(Event$4.CLICK, function (event) {
  3286. event.preventDefault();
  3287. event.stopPropagation();
  3288. _this.toggle();
  3289. });
  3290. };
  3291. _proto._getConfig = function _getConfig(config) {
  3292. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3293. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3294. return config;
  3295. };
  3296. _proto._getMenuElement = function _getMenuElement() {
  3297. if (!this._menu) {
  3298. var parent = Dropdown._getParentFromElement(this._element);
  3299. if (parent) {
  3300. this._menu = parent.querySelector(Selector$4.MENU);
  3301. }
  3302. }
  3303. return this._menu;
  3304. };
  3305. _proto._getPlacement = function _getPlacement() {
  3306. var $parentDropdown = $(this._element.parentNode);
  3307. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3308. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3309. placement = AttachmentMap.TOP;
  3310. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3311. placement = AttachmentMap.TOPEND;
  3312. }
  3313. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3314. placement = AttachmentMap.RIGHT;
  3315. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3316. placement = AttachmentMap.LEFT;
  3317. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3318. placement = AttachmentMap.BOTTOMEND;
  3319. }
  3320. return placement;
  3321. };
  3322. _proto._detectNavbar = function _detectNavbar() {
  3323. return $(this._element).closest('.navbar').length > 0;
  3324. };
  3325. _proto._getOffset = function _getOffset() {
  3326. var _this2 = this;
  3327. var offset = {};
  3328. if (typeof this._config.offset === 'function') {
  3329. offset.fn = function (data) {
  3330. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3331. return data;
  3332. };
  3333. } else {
  3334. offset.offset = this._config.offset;
  3335. }
  3336. return offset;
  3337. };
  3338. _proto._getPopperConfig = function _getPopperConfig() {
  3339. var popperConfig = {
  3340. placement: this._getPlacement(),
  3341. modifiers: {
  3342. offset: this._getOffset(),
  3343. flip: {
  3344. enabled: this._config.flip
  3345. },
  3346. preventOverflow: {
  3347. boundariesElement: this._config.boundary
  3348. }
  3349. }
  3350. }; // Disable Popper.js if we have a static display
  3351. if (this._config.display === 'static') {
  3352. popperConfig.modifiers.applyStyle = {
  3353. enabled: false
  3354. };
  3355. }
  3356. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3357. } // Static
  3358. ;
  3359. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3360. return this.each(function () {
  3361. var data = $(this).data(DATA_KEY$4);
  3362. var _config = typeof config === 'object' ? config : null;
  3363. if (!data) {
  3364. data = new Dropdown(this, _config);
  3365. $(this).data(DATA_KEY$4, data);
  3366. }
  3367. if (typeof config === 'string') {
  3368. if (typeof data[config] === 'undefined') {
  3369. throw new TypeError("No method named \"" + config + "\"");
  3370. }
  3371. data[config]();
  3372. }
  3373. });
  3374. };
  3375. Dropdown._clearMenus = function _clearMenus(event) {
  3376. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3377. return;
  3378. }
  3379. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3380. for (var i = 0, len = toggles.length; i < len; i++) {
  3381. var parent = Dropdown._getParentFromElement(toggles[i]);
  3382. var context = $(toggles[i]).data(DATA_KEY$4);
  3383. var relatedTarget = {
  3384. relatedTarget: toggles[i]
  3385. };
  3386. if (event && event.type === 'click') {
  3387. relatedTarget.clickEvent = event;
  3388. }
  3389. if (!context) {
  3390. continue;
  3391. }
  3392. var dropdownMenu = context._menu;
  3393. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3394. continue;
  3395. }
  3396. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3397. continue;
  3398. }
  3399. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3400. $(parent).trigger(hideEvent);
  3401. if (hideEvent.isDefaultPrevented()) {
  3402. continue;
  3403. } // If this is a touch-enabled device we remove the extra
  3404. // empty mouseover listeners we added for iOS support
  3405. if ('ontouchstart' in document.documentElement) {
  3406. $(document.body).children().off('mouseover', null, $.noop);
  3407. }
  3408. toggles[i].setAttribute('aria-expanded', 'false');
  3409. if (context._popper) {
  3410. context._popper.destroy();
  3411. }
  3412. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3413. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3414. }
  3415. };
  3416. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3417. var parent;
  3418. var selector = Util.getSelectorFromElement(element);
  3419. if (selector) {
  3420. parent = document.querySelector(selector);
  3421. }
  3422. return parent || element.parentNode;
  3423. } // eslint-disable-next-line complexity
  3424. ;
  3425. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3426. // If not input/textarea:
  3427. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3428. // If input/textarea:
  3429. // - If space key => not a dropdown command
  3430. // - If key is other than escape
  3431. // - If key is not up or down => not a dropdown command
  3432. // - If trigger inside the menu => not a dropdown command
  3433. 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)) {
  3434. return;
  3435. }
  3436. event.preventDefault();
  3437. event.stopPropagation();
  3438. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3439. return;
  3440. }
  3441. var parent = Dropdown._getParentFromElement(this);
  3442. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3443. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3444. return;
  3445. }
  3446. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3447. if (event.which === ESCAPE_KEYCODE) {
  3448. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3449. $(toggle).trigger('focus');
  3450. }
  3451. $(this).trigger('click');
  3452. return;
  3453. }
  3454. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3455. return $(item).is(':visible');
  3456. });
  3457. if (items.length === 0) {
  3458. return;
  3459. }
  3460. var index = items.indexOf(event.target);
  3461. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3462. // Up
  3463. index--;
  3464. }
  3465. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3466. // Down
  3467. index++;
  3468. }
  3469. if (index < 0) {
  3470. index = 0;
  3471. }
  3472. items[index].focus();
  3473. };
  3474. _createClass(Dropdown, null, [{
  3475. key: "VERSION",
  3476. get: function get() {
  3477. return VERSION$4;
  3478. }
  3479. }, {
  3480. key: "Default",
  3481. get: function get() {
  3482. return Default$2;
  3483. }
  3484. }, {
  3485. key: "DefaultType",
  3486. get: function get() {
  3487. return DefaultType$2;
  3488. }
  3489. }]);
  3490. return Dropdown;
  3491. }();
  3492. /**
  3493. * ------------------------------------------------------------------------
  3494. * Data Api implementation
  3495. * ------------------------------------------------------------------------
  3496. */
  3497. $(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) {
  3498. event.preventDefault();
  3499. event.stopPropagation();
  3500. Dropdown._jQueryInterface.call($(this), 'toggle');
  3501. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3502. e.stopPropagation();
  3503. });
  3504. /**
  3505. * ------------------------------------------------------------------------
  3506. * jQuery
  3507. * ------------------------------------------------------------------------
  3508. */
  3509. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3510. $.fn[NAME$4].Constructor = Dropdown;
  3511. $.fn[NAME$4].noConflict = function () {
  3512. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3513. return Dropdown._jQueryInterface;
  3514. };
  3515. /**
  3516. * ------------------------------------------------------------------------
  3517. * Constants
  3518. * ------------------------------------------------------------------------
  3519. */
  3520. var NAME$5 = 'modal';
  3521. var VERSION$5 = '4.4.1';
  3522. var DATA_KEY$5 = 'bs.modal';
  3523. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3524. var DATA_API_KEY$5 = '.data-api';
  3525. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3526. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3527. var Default$3 = {
  3528. backdrop: true,
  3529. keyboard: true,
  3530. focus: true,
  3531. show: true
  3532. };
  3533. var DefaultType$3 = {
  3534. backdrop: '(boolean|string)',
  3535. keyboard: 'boolean',
  3536. focus: 'boolean',
  3537. show: 'boolean'
  3538. };
  3539. var Event$5 = {
  3540. HIDE: "hide" + EVENT_KEY$5,
  3541. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3542. HIDDEN: "hidden" + EVENT_KEY$5,
  3543. SHOW: "show" + EVENT_KEY$5,
  3544. SHOWN: "shown" + EVENT_KEY$5,
  3545. FOCUSIN: "focusin" + EVENT_KEY$5,
  3546. RESIZE: "resize" + EVENT_KEY$5,
  3547. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3548. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3549. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3550. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3551. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3552. };
  3553. var ClassName$5 = {
  3554. SCROLLABLE: 'modal-dialog-scrollable',
  3555. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3556. BACKDROP: 'modal-backdrop',
  3557. OPEN: 'modal-open',
  3558. FADE: 'fade',
  3559. SHOW: 'show',
  3560. STATIC: 'modal-static'
  3561. };
  3562. var Selector$5 = {
  3563. DIALOG: '.modal-dialog',
  3564. MODAL_BODY: '.modal-body',
  3565. DATA_TOGGLE: '[data-toggle="modal"]',
  3566. DATA_DISMISS: '[data-dismiss="modal"]',
  3567. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3568. STICKY_CONTENT: '.sticky-top'
  3569. };
  3570. /**
  3571. * ------------------------------------------------------------------------
  3572. * Class Definition
  3573. * ------------------------------------------------------------------------
  3574. */
  3575. var Modal =
  3576. /*#__PURE__*/
  3577. function () {
  3578. function Modal(element, config) {
  3579. this._config = this._getConfig(config);
  3580. this._element = element;
  3581. this._dialog = element.querySelector(Selector$5.DIALOG);
  3582. this._backdrop = null;
  3583. this._isShown = false;
  3584. this._isBodyOverflowing = false;
  3585. this._ignoreBackdropClick = false;
  3586. this._isTransitioning = false;
  3587. this._scrollbarWidth = 0;
  3588. } // Getters
  3589. var _proto = Modal.prototype;
  3590. // Public
  3591. _proto.toggle = function toggle(relatedTarget) {
  3592. return this._isShown ? this.hide() : this.show(relatedTarget);
  3593. };
  3594. _proto.show = function show(relatedTarget) {
  3595. var _this = this;
  3596. if (this._isShown || this._isTransitioning) {
  3597. return;
  3598. }
  3599. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3600. this._isTransitioning = true;
  3601. }
  3602. var showEvent = $.Event(Event$5.SHOW, {
  3603. relatedTarget: relatedTarget
  3604. });
  3605. $(this._element).trigger(showEvent);
  3606. if (this._isShown || showEvent.isDefaultPrevented()) {
  3607. return;
  3608. }
  3609. this._isShown = true;
  3610. this._checkScrollbar();
  3611. this._setScrollbar();
  3612. this._adjustDialog();
  3613. this._setEscapeEvent();
  3614. this._setResizeEvent();
  3615. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3616. return _this.hide(event);
  3617. });
  3618. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3619. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3620. if ($(event.target).is(_this._element)) {
  3621. _this._ignoreBackdropClick = true;
  3622. }
  3623. });
  3624. });
  3625. this._showBackdrop(function () {
  3626. return _this._showElement(relatedTarget);
  3627. });
  3628. };
  3629. _proto.hide = function hide(event) {
  3630. var _this2 = this;
  3631. if (event) {
  3632. event.preventDefault();
  3633. }
  3634. if (!this._isShown || this._isTransitioning) {
  3635. return;
  3636. }
  3637. var hideEvent = $.Event(Event$5.HIDE);
  3638. $(this._element).trigger(hideEvent);
  3639. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3640. return;
  3641. }
  3642. this._isShown = false;
  3643. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3644. if (transition) {
  3645. this._isTransitioning = true;
  3646. }
  3647. this._setEscapeEvent();
  3648. this._setResizeEvent();
  3649. $(document).off(Event$5.FOCUSIN);
  3650. $(this._element).removeClass(ClassName$5.SHOW);
  3651. $(this._element).off(Event$5.CLICK_DISMISS);
  3652. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3653. if (transition) {
  3654. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3655. $(this._element).one(Util.TRANSITION_END, function (event) {
  3656. return _this2._hideModal(event);
  3657. }).emulateTransitionEnd(transitionDuration);
  3658. } else {
  3659. this._hideModal();
  3660. }
  3661. };
  3662. _proto.dispose = function dispose() {
  3663. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3664. return $(htmlElement).off(EVENT_KEY$5);
  3665. });
  3666. /**
  3667. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3668. * Do not move `document` in `htmlElements` array
  3669. * It will remove `Event.CLICK_DATA_API` event that should remain
  3670. */
  3671. $(document).off(Event$5.FOCUSIN);
  3672. $.removeData(this._element, DATA_KEY$5);
  3673. this._config = null;
  3674. this._element = null;
  3675. this._dialog = null;
  3676. this._backdrop = null;
  3677. this._isShown = null;
  3678. this._isBodyOverflowing = null;
  3679. this._ignoreBackdropClick = null;
  3680. this._isTransitioning = null;
  3681. this._scrollbarWidth = null;
  3682. };
  3683. _proto.handleUpdate = function handleUpdate() {
  3684. this._adjustDialog();
  3685. } // Private
  3686. ;
  3687. _proto._getConfig = function _getConfig(config) {
  3688. config = _objectSpread2({}, Default$3, {}, config);
  3689. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3690. return config;
  3691. };
  3692. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3693. var _this3 = this;
  3694. if (this._config.backdrop === 'static') {
  3695. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3696. $(this._element).trigger(hideEventPrevented);
  3697. if (hideEventPrevented.defaultPrevented) {
  3698. return;
  3699. }
  3700. this._element.classList.add(ClassName$5.STATIC);
  3701. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3702. $(this._element).one(Util.TRANSITION_END, function () {
  3703. _this3._element.classList.remove(ClassName$5.STATIC);
  3704. }).emulateTransitionEnd(modalTransitionDuration);
  3705. this._element.focus();
  3706. } else {
  3707. this.hide();
  3708. }
  3709. };
  3710. _proto._showElement = function _showElement(relatedTarget) {
  3711. var _this4 = this;
  3712. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3713. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3714. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3715. // Don't move modal's DOM position
  3716. document.body.appendChild(this._element);
  3717. }
  3718. this._element.style.display = 'block';
  3719. this._element.removeAttribute('aria-hidden');
  3720. this._element.setAttribute('aria-modal', true);
  3721. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3722. modalBody.scrollTop = 0;
  3723. } else {
  3724. this._element.scrollTop = 0;
  3725. }
  3726. if (transition) {
  3727. Util.reflow(this._element);
  3728. }
  3729. $(this._element).addClass(ClassName$5.SHOW);
  3730. if (this._config.focus) {
  3731. this._enforceFocus();
  3732. }
  3733. var shownEvent = $.Event(Event$5.SHOWN, {
  3734. relatedTarget: relatedTarget
  3735. });
  3736. var transitionComplete = function transitionComplete() {
  3737. if (_this4._config.focus) {
  3738. _this4._element.focus();
  3739. }
  3740. _this4._isTransitioning = false;
  3741. $(_this4._element).trigger(shownEvent);
  3742. };
  3743. if (transition) {
  3744. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3745. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3746. } else {
  3747. transitionComplete();
  3748. }
  3749. };
  3750. _proto._enforceFocus = function _enforceFocus() {
  3751. var _this5 = this;
  3752. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3753. .on(Event$5.FOCUSIN, function (event) {
  3754. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3755. _this5._element.focus();
  3756. }
  3757. });
  3758. };
  3759. _proto._setEscapeEvent = function _setEscapeEvent() {
  3760. var _this6 = this;
  3761. if (this._isShown && this._config.keyboard) {
  3762. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3763. if (event.which === ESCAPE_KEYCODE$1) {
  3764. _this6._triggerBackdropTransition();
  3765. }
  3766. });
  3767. } else if (!this._isShown) {
  3768. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3769. }
  3770. };
  3771. _proto._setResizeEvent = function _setResizeEvent() {
  3772. var _this7 = this;
  3773. if (this._isShown) {
  3774. $(window).on(Event$5.RESIZE, function (event) {
  3775. return _this7.handleUpdate(event);
  3776. });
  3777. } else {
  3778. $(window).off(Event$5.RESIZE);
  3779. }
  3780. };
  3781. _proto._hideModal = function _hideModal() {
  3782. var _this8 = this;
  3783. this._element.style.display = 'none';
  3784. this._element.setAttribute('aria-hidden', true);
  3785. this._element.removeAttribute('aria-modal');
  3786. this._isTransitioning = false;
  3787. this._showBackdrop(function () {
  3788. $(document.body).removeClass(ClassName$5.OPEN);
  3789. _this8._resetAdjustments();
  3790. _this8._resetScrollbar();
  3791. $(_this8._element).trigger(Event$5.HIDDEN);
  3792. });
  3793. };
  3794. _proto._removeBackdrop = function _removeBackdrop() {
  3795. if (this._backdrop) {
  3796. $(this._backdrop).remove();
  3797. this._backdrop = null;
  3798. }
  3799. };
  3800. _proto._showBackdrop = function _showBackdrop(callback) {
  3801. var _this9 = this;
  3802. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3803. if (this._isShown && this._config.backdrop) {
  3804. this._backdrop = document.createElement('div');
  3805. this._backdrop.className = ClassName$5.BACKDROP;
  3806. if (animate) {
  3807. this._backdrop.classList.add(animate);
  3808. }
  3809. $(this._backdrop).appendTo(document.body);
  3810. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3811. if (_this9._ignoreBackdropClick) {
  3812. _this9._ignoreBackdropClick = false;
  3813. return;
  3814. }
  3815. if (event.target !== event.currentTarget) {
  3816. return;
  3817. }
  3818. _this9._triggerBackdropTransition();
  3819. });
  3820. if (animate) {
  3821. Util.reflow(this._backdrop);
  3822. }
  3823. $(this._backdrop).addClass(ClassName$5.SHOW);
  3824. if (!callback) {
  3825. return;
  3826. }
  3827. if (!animate) {
  3828. callback();
  3829. return;
  3830. }
  3831. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3832. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3833. } else if (!this._isShown && this._backdrop) {
  3834. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3835. var callbackRemove = function callbackRemove() {
  3836. _this9._removeBackdrop();
  3837. if (callback) {
  3838. callback();
  3839. }
  3840. };
  3841. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3842. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3843. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3844. } else {
  3845. callbackRemove();
  3846. }
  3847. } else if (callback) {
  3848. callback();
  3849. }
  3850. } // ----------------------------------------------------------------------
  3851. // the following methods are used to handle overflowing modals
  3852. // todo (fat): these should probably be refactored out of modal.js
  3853. // ----------------------------------------------------------------------
  3854. ;
  3855. _proto._adjustDialog = function _adjustDialog() {
  3856. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3857. if (!this._isBodyOverflowing && isModalOverflowing) {
  3858. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3859. }
  3860. if (this._isBodyOverflowing && !isModalOverflowing) {
  3861. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3862. }
  3863. };
  3864. _proto._resetAdjustments = function _resetAdjustments() {
  3865. this._element.style.paddingLeft = '';
  3866. this._element.style.paddingRight = '';
  3867. };
  3868. _proto._checkScrollbar = function _checkScrollbar() {
  3869. var rect = document.body.getBoundingClientRect();
  3870. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3871. this._scrollbarWidth = this._getScrollbarWidth();
  3872. };
  3873. _proto._setScrollbar = function _setScrollbar() {
  3874. var _this10 = this;
  3875. if (this._isBodyOverflowing) {
  3876. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3877. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3878. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3879. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3880. $(fixedContent).each(function (index, element) {
  3881. var actualPadding = element.style.paddingRight;
  3882. var calculatedPadding = $(element).css('padding-right');
  3883. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3884. }); // Adjust sticky content margin
  3885. $(stickyContent).each(function (index, element) {
  3886. var actualMargin = element.style.marginRight;
  3887. var calculatedMargin = $(element).css('margin-right');
  3888. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3889. }); // Adjust body padding
  3890. var actualPadding = document.body.style.paddingRight;
  3891. var calculatedPadding = $(document.body).css('padding-right');
  3892. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3893. }
  3894. $(document.body).addClass(ClassName$5.OPEN);
  3895. };
  3896. _proto._resetScrollbar = function _resetScrollbar() {
  3897. // Restore fixed content padding
  3898. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3899. $(fixedContent).each(function (index, element) {
  3900. var padding = $(element).data('padding-right');
  3901. $(element).removeData('padding-right');
  3902. element.style.paddingRight = padding ? padding : '';
  3903. }); // Restore sticky content
  3904. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3905. $(elements).each(function (index, element) {
  3906. var margin = $(element).data('margin-right');
  3907. if (typeof margin !== 'undefined') {
  3908. $(element).css('margin-right', margin).removeData('margin-right');
  3909. }
  3910. }); // Restore body padding
  3911. var padding = $(document.body).data('padding-right');
  3912. $(document.body).removeData('padding-right');
  3913. document.body.style.paddingRight = padding ? padding : '';
  3914. };
  3915. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3916. // thx d.walsh
  3917. var scrollDiv = document.createElement('div');
  3918. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3919. document.body.appendChild(scrollDiv);
  3920. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3921. document.body.removeChild(scrollDiv);
  3922. return scrollbarWidth;
  3923. } // Static
  3924. ;
  3925. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3926. return this.each(function () {
  3927. var data = $(this).data(DATA_KEY$5);
  3928. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3929. if (!data) {
  3930. data = new Modal(this, _config);
  3931. $(this).data(DATA_KEY$5, data);
  3932. }
  3933. if (typeof config === 'string') {
  3934. if (typeof data[config] === 'undefined') {
  3935. throw new TypeError("No method named \"" + config + "\"");
  3936. }
  3937. data[config](relatedTarget);
  3938. } else if (_config.show) {
  3939. data.show(relatedTarget);
  3940. }
  3941. });
  3942. };
  3943. _createClass(Modal, null, [{
  3944. key: "VERSION",
  3945. get: function get() {
  3946. return VERSION$5;
  3947. }
  3948. }, {
  3949. key: "Default",
  3950. get: function get() {
  3951. return Default$3;
  3952. }
  3953. }]);
  3954. return Modal;
  3955. }();
  3956. /**
  3957. * ------------------------------------------------------------------------
  3958. * Data Api implementation
  3959. * ------------------------------------------------------------------------
  3960. */
  3961. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3962. var _this11 = this;
  3963. var target;
  3964. var selector = Util.getSelectorFromElement(this);
  3965. if (selector) {
  3966. target = document.querySelector(selector);
  3967. }
  3968. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3969. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3970. event.preventDefault();
  3971. }
  3972. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3973. if (showEvent.isDefaultPrevented()) {
  3974. // Only register focus restorer if modal will actually get shown
  3975. return;
  3976. }
  3977. $target.one(Event$5.HIDDEN, function () {
  3978. if ($(_this11).is(':visible')) {
  3979. _this11.focus();
  3980. }
  3981. });
  3982. });
  3983. Modal._jQueryInterface.call($(target), config, this);
  3984. });
  3985. /**
  3986. * ------------------------------------------------------------------------
  3987. * jQuery
  3988. * ------------------------------------------------------------------------
  3989. */
  3990. $.fn[NAME$5] = Modal._jQueryInterface;
  3991. $.fn[NAME$5].Constructor = Modal;
  3992. $.fn[NAME$5].noConflict = function () {
  3993. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  3994. return Modal._jQueryInterface;
  3995. };
  3996. /**
  3997. * --------------------------------------------------------------------------
  3998. * Bootstrap (v4.4.1): tools/sanitizer.js
  3999. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4000. * --------------------------------------------------------------------------
  4001. */
  4002. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4003. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4004. var DefaultWhitelist = {
  4005. // Global attributes allowed on any supplied element below.
  4006. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4007. a: ['target', 'href', 'title', 'rel'],
  4008. area: [],
  4009. b: [],
  4010. br: [],
  4011. col: [],
  4012. code: [],
  4013. div: [],
  4014. em: [],
  4015. hr: [],
  4016. h1: [],
  4017. h2: [],
  4018. h3: [],
  4019. h4: [],
  4020. h5: [],
  4021. h6: [],
  4022. i: [],
  4023. img: ['src', 'alt', 'title', 'width', 'height'],
  4024. li: [],
  4025. ol: [],
  4026. p: [],
  4027. pre: [],
  4028. s: [],
  4029. small: [],
  4030. span: [],
  4031. sub: [],
  4032. sup: [],
  4033. strong: [],
  4034. u: [],
  4035. ul: []
  4036. };
  4037. /**
  4038. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4039. *
  4040. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4041. */
  4042. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4043. /**
  4044. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4045. *
  4046. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4047. */
  4048. 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;
  4049. function allowedAttribute(attr, allowedAttributeList) {
  4050. var attrName = attr.nodeName.toLowerCase();
  4051. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4052. if (uriAttrs.indexOf(attrName) !== -1) {
  4053. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4054. }
  4055. return true;
  4056. }
  4057. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4058. return attrRegex instanceof RegExp;
  4059. }); // Check if a regular expression validates the attribute.
  4060. for (var i = 0, l = regExp.length; i < l; i++) {
  4061. if (attrName.match(regExp[i])) {
  4062. return true;
  4063. }
  4064. }
  4065. return false;
  4066. }
  4067. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4068. if (unsafeHtml.length === 0) {
  4069. return unsafeHtml;
  4070. }
  4071. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4072. return sanitizeFn(unsafeHtml);
  4073. }
  4074. var domParser = new window.DOMParser();
  4075. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4076. var whitelistKeys = Object.keys(whiteList);
  4077. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4078. var _loop = function _loop(i, len) {
  4079. var el = elements[i];
  4080. var elName = el.nodeName.toLowerCase();
  4081. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4082. el.parentNode.removeChild(el);
  4083. return "continue";
  4084. }
  4085. var attributeList = [].slice.call(el.attributes);
  4086. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4087. attributeList.forEach(function (attr) {
  4088. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4089. el.removeAttribute(attr.nodeName);
  4090. }
  4091. });
  4092. };
  4093. for (var i = 0, len = elements.length; i < len; i++) {
  4094. var _ret = _loop(i);
  4095. if (_ret === "continue") continue;
  4096. }
  4097. return createdDocument.body.innerHTML;
  4098. }
  4099. /**
  4100. * ------------------------------------------------------------------------
  4101. * Constants
  4102. * ------------------------------------------------------------------------
  4103. */
  4104. var NAME$6 = 'tooltip';
  4105. var VERSION$6 = '4.4.1';
  4106. var DATA_KEY$6 = 'bs.tooltip';
  4107. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4108. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4109. var CLASS_PREFIX = 'bs-tooltip';
  4110. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4111. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4112. var DefaultType$4 = {
  4113. animation: 'boolean',
  4114. template: 'string',
  4115. title: '(string|element|function)',
  4116. trigger: 'string',
  4117. delay: '(number|object)',
  4118. html: 'boolean',
  4119. selector: '(string|boolean)',
  4120. placement: '(string|function)',
  4121. offset: '(number|string|function)',
  4122. container: '(string|element|boolean)',
  4123. fallbackPlacement: '(string|array)',
  4124. boundary: '(string|element)',
  4125. sanitize: 'boolean',
  4126. sanitizeFn: '(null|function)',
  4127. whiteList: 'object',
  4128. popperConfig: '(null|object)'
  4129. };
  4130. var AttachmentMap$1 = {
  4131. AUTO: 'auto',
  4132. TOP: 'top',
  4133. RIGHT: 'right',
  4134. BOTTOM: 'bottom',
  4135. LEFT: 'left'
  4136. };
  4137. var Default$4 = {
  4138. animation: true,
  4139. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4140. trigger: 'hover focus',
  4141. title: '',
  4142. delay: 0,
  4143. html: false,
  4144. selector: false,
  4145. placement: 'top',
  4146. offset: 0,
  4147. container: false,
  4148. fallbackPlacement: 'flip',
  4149. boundary: 'scrollParent',
  4150. sanitize: true,
  4151. sanitizeFn: null,
  4152. whiteList: DefaultWhitelist,
  4153. popperConfig: null
  4154. };
  4155. var HoverState = {
  4156. SHOW: 'show',
  4157. OUT: 'out'
  4158. };
  4159. var Event$6 = {
  4160. HIDE: "hide" + EVENT_KEY$6,
  4161. HIDDEN: "hidden" + EVENT_KEY$6,
  4162. SHOW: "show" + EVENT_KEY$6,
  4163. SHOWN: "shown" + EVENT_KEY$6,
  4164. INSERTED: "inserted" + EVENT_KEY$6,
  4165. CLICK: "click" + EVENT_KEY$6,
  4166. FOCUSIN: "focusin" + EVENT_KEY$6,
  4167. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4168. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4169. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4170. };
  4171. var ClassName$6 = {
  4172. FADE: 'fade',
  4173. SHOW: 'show'
  4174. };
  4175. var Selector$6 = {
  4176. TOOLTIP: '.tooltip',
  4177. TOOLTIP_INNER: '.tooltip-inner',
  4178. ARROW: '.arrow'
  4179. };
  4180. var Trigger = {
  4181. HOVER: 'hover',
  4182. FOCUS: 'focus',
  4183. CLICK: 'click',
  4184. MANUAL: 'manual'
  4185. };
  4186. /**
  4187. * ------------------------------------------------------------------------
  4188. * Class Definition
  4189. * ------------------------------------------------------------------------
  4190. */
  4191. var Tooltip =
  4192. /*#__PURE__*/
  4193. function () {
  4194. function Tooltip(element, config) {
  4195. if (typeof Popper === 'undefined') {
  4196. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4197. } // private
  4198. this._isEnabled = true;
  4199. this._timeout = 0;
  4200. this._hoverState = '';
  4201. this._activeTrigger = {};
  4202. this._popper = null; // Protected
  4203. this.element = element;
  4204. this.config = this._getConfig(config);
  4205. this.tip = null;
  4206. this._setListeners();
  4207. } // Getters
  4208. var _proto = Tooltip.prototype;
  4209. // Public
  4210. _proto.enable = function enable() {
  4211. this._isEnabled = true;
  4212. };
  4213. _proto.disable = function disable() {
  4214. this._isEnabled = false;
  4215. };
  4216. _proto.toggleEnabled = function toggleEnabled() {
  4217. this._isEnabled = !this._isEnabled;
  4218. };
  4219. _proto.toggle = function toggle(event) {
  4220. if (!this._isEnabled) {
  4221. return;
  4222. }
  4223. if (event) {
  4224. var dataKey = this.constructor.DATA_KEY;
  4225. var context = $(event.currentTarget).data(dataKey);
  4226. if (!context) {
  4227. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4228. $(event.currentTarget).data(dataKey, context);
  4229. }
  4230. context._activeTrigger.click = !context._activeTrigger.click;
  4231. if (context._isWithActiveTrigger()) {
  4232. context._enter(null, context);
  4233. } else {
  4234. context._leave(null, context);
  4235. }
  4236. } else {
  4237. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4238. this._leave(null, this);
  4239. return;
  4240. }
  4241. this._enter(null, this);
  4242. }
  4243. };
  4244. _proto.dispose = function dispose() {
  4245. clearTimeout(this._timeout);
  4246. $.removeData(this.element, this.constructor.DATA_KEY);
  4247. $(this.element).off(this.constructor.EVENT_KEY);
  4248. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4249. if (this.tip) {
  4250. $(this.tip).remove();
  4251. }
  4252. this._isEnabled = null;
  4253. this._timeout = null;
  4254. this._hoverState = null;
  4255. this._activeTrigger = null;
  4256. if (this._popper) {
  4257. this._popper.destroy();
  4258. }
  4259. this._popper = null;
  4260. this.element = null;
  4261. this.config = null;
  4262. this.tip = null;
  4263. };
  4264. _proto.show = function show() {
  4265. var _this = this;
  4266. if ($(this.element).css('display') === 'none') {
  4267. throw new Error('Please use show on visible elements');
  4268. }
  4269. var showEvent = $.Event(this.constructor.Event.SHOW);
  4270. if (this.isWithContent() && this._isEnabled) {
  4271. $(this.element).trigger(showEvent);
  4272. var shadowRoot = Util.findShadowRoot(this.element);
  4273. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4274. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4275. return;
  4276. }
  4277. var tip = this.getTipElement();
  4278. var tipId = Util.getUID(this.constructor.NAME);
  4279. tip.setAttribute('id', tipId);
  4280. this.element.setAttribute('aria-describedby', tipId);
  4281. this.setContent();
  4282. if (this.config.animation) {
  4283. $(tip).addClass(ClassName$6.FADE);
  4284. }
  4285. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4286. var attachment = this._getAttachment(placement);
  4287. this.addAttachmentClass(attachment);
  4288. var container = this._getContainer();
  4289. $(tip).data(this.constructor.DATA_KEY, this);
  4290. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4291. $(tip).appendTo(container);
  4292. }
  4293. $(this.element).trigger(this.constructor.Event.INSERTED);
  4294. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4295. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4296. // empty mouseover listeners to the body's immediate children;
  4297. // only needed because of broken event delegation on iOS
  4298. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4299. if ('ontouchstart' in document.documentElement) {
  4300. $(document.body).children().on('mouseover', null, $.noop);
  4301. }
  4302. var complete = function complete() {
  4303. if (_this.config.animation) {
  4304. _this._fixTransition();
  4305. }
  4306. var prevHoverState = _this._hoverState;
  4307. _this._hoverState = null;
  4308. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4309. if (prevHoverState === HoverState.OUT) {
  4310. _this._leave(null, _this);
  4311. }
  4312. };
  4313. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4314. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4315. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4316. } else {
  4317. complete();
  4318. }
  4319. }
  4320. };
  4321. _proto.hide = function hide(callback) {
  4322. var _this2 = this;
  4323. var tip = this.getTipElement();
  4324. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4325. var complete = function complete() {
  4326. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4327. tip.parentNode.removeChild(tip);
  4328. }
  4329. _this2._cleanTipClass();
  4330. _this2.element.removeAttribute('aria-describedby');
  4331. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4332. if (_this2._popper !== null) {
  4333. _this2._popper.destroy();
  4334. }
  4335. if (callback) {
  4336. callback();
  4337. }
  4338. };
  4339. $(this.element).trigger(hideEvent);
  4340. if (hideEvent.isDefaultPrevented()) {
  4341. return;
  4342. }
  4343. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4344. // empty mouseover listeners we added for iOS support
  4345. if ('ontouchstart' in document.documentElement) {
  4346. $(document.body).children().off('mouseover', null, $.noop);
  4347. }
  4348. this._activeTrigger[Trigger.CLICK] = false;
  4349. this._activeTrigger[Trigger.FOCUS] = false;
  4350. this._activeTrigger[Trigger.HOVER] = false;
  4351. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4352. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4353. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4354. } else {
  4355. complete();
  4356. }
  4357. this._hoverState = '';
  4358. };
  4359. _proto.update = function update() {
  4360. if (this._popper !== null) {
  4361. this._popper.scheduleUpdate();
  4362. }
  4363. } // Protected
  4364. ;
  4365. _proto.isWithContent = function isWithContent() {
  4366. return Boolean(this.getTitle());
  4367. };
  4368. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4369. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4370. };
  4371. _proto.getTipElement = function getTipElement() {
  4372. this.tip = this.tip || $(this.config.template)[0];
  4373. return this.tip;
  4374. };
  4375. _proto.setContent = function setContent() {
  4376. var tip = this.getTipElement();
  4377. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4378. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4379. };
  4380. _proto.setElementContent = function setElementContent($element, content) {
  4381. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4382. // Content is a DOM node or a jQuery
  4383. if (this.config.html) {
  4384. if (!$(content).parent().is($element)) {
  4385. $element.empty().append(content);
  4386. }
  4387. } else {
  4388. $element.text($(content).text());
  4389. }
  4390. return;
  4391. }
  4392. if (this.config.html) {
  4393. if (this.config.sanitize) {
  4394. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4395. }
  4396. $element.html(content);
  4397. } else {
  4398. $element.text(content);
  4399. }
  4400. };
  4401. _proto.getTitle = function getTitle() {
  4402. var title = this.element.getAttribute('data-original-title');
  4403. if (!title) {
  4404. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4405. }
  4406. return title;
  4407. } // Private
  4408. ;
  4409. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4410. var _this3 = this;
  4411. var defaultBsConfig = {
  4412. placement: attachment,
  4413. modifiers: {
  4414. offset: this._getOffset(),
  4415. flip: {
  4416. behavior: this.config.fallbackPlacement
  4417. },
  4418. arrow: {
  4419. element: Selector$6.ARROW
  4420. },
  4421. preventOverflow: {
  4422. boundariesElement: this.config.boundary
  4423. }
  4424. },
  4425. onCreate: function onCreate(data) {
  4426. if (data.originalPlacement !== data.placement) {
  4427. _this3._handlePopperPlacementChange(data);
  4428. }
  4429. },
  4430. onUpdate: function onUpdate(data) {
  4431. return _this3._handlePopperPlacementChange(data);
  4432. }
  4433. };
  4434. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4435. };
  4436. _proto._getOffset = function _getOffset() {
  4437. var _this4 = this;
  4438. var offset = {};
  4439. if (typeof this.config.offset === 'function') {
  4440. offset.fn = function (data) {
  4441. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4442. return data;
  4443. };
  4444. } else {
  4445. offset.offset = this.config.offset;
  4446. }
  4447. return offset;
  4448. };
  4449. _proto._getContainer = function _getContainer() {
  4450. if (this.config.container === false) {
  4451. return document.body;
  4452. }
  4453. if (Util.isElement(this.config.container)) {
  4454. return $(this.config.container);
  4455. }
  4456. return $(document).find(this.config.container);
  4457. };
  4458. _proto._getAttachment = function _getAttachment(placement) {
  4459. return AttachmentMap$1[placement.toUpperCase()];
  4460. };
  4461. _proto._setListeners = function _setListeners() {
  4462. var _this5 = this;
  4463. var triggers = this.config.trigger.split(' ');
  4464. triggers.forEach(function (trigger) {
  4465. if (trigger === 'click') {
  4466. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4467. return _this5.toggle(event);
  4468. });
  4469. } else if (trigger !== Trigger.MANUAL) {
  4470. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4471. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4472. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4473. return _this5._enter(event);
  4474. }).on(eventOut, _this5.config.selector, function (event) {
  4475. return _this5._leave(event);
  4476. });
  4477. }
  4478. });
  4479. this._hideModalHandler = function () {
  4480. if (_this5.element) {
  4481. _this5.hide();
  4482. }
  4483. };
  4484. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4485. if (this.config.selector) {
  4486. this.config = _objectSpread2({}, this.config, {
  4487. trigger: 'manual',
  4488. selector: ''
  4489. });
  4490. } else {
  4491. this._fixTitle();
  4492. }
  4493. };
  4494. _proto._fixTitle = function _fixTitle() {
  4495. var titleType = typeof this.element.getAttribute('data-original-title');
  4496. if (this.element.getAttribute('title') || titleType !== 'string') {
  4497. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4498. this.element.setAttribute('title', '');
  4499. }
  4500. };
  4501. _proto._enter = function _enter(event, context) {
  4502. var dataKey = this.constructor.DATA_KEY;
  4503. context = context || $(event.currentTarget).data(dataKey);
  4504. if (!context) {
  4505. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4506. $(event.currentTarget).data(dataKey, context);
  4507. }
  4508. if (event) {
  4509. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4510. }
  4511. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4512. context._hoverState = HoverState.SHOW;
  4513. return;
  4514. }
  4515. clearTimeout(context._timeout);
  4516. context._hoverState = HoverState.SHOW;
  4517. if (!context.config.delay || !context.config.delay.show) {
  4518. context.show();
  4519. return;
  4520. }
  4521. context._timeout = setTimeout(function () {
  4522. if (context._hoverState === HoverState.SHOW) {
  4523. context.show();
  4524. }
  4525. }, context.config.delay.show);
  4526. };
  4527. _proto._leave = function _leave(event, context) {
  4528. var dataKey = this.constructor.DATA_KEY;
  4529. context = context || $(event.currentTarget).data(dataKey);
  4530. if (!context) {
  4531. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4532. $(event.currentTarget).data(dataKey, context);
  4533. }
  4534. if (event) {
  4535. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4536. }
  4537. if (context._isWithActiveTrigger()) {
  4538. return;
  4539. }
  4540. clearTimeout(context._timeout);
  4541. context._hoverState = HoverState.OUT;
  4542. if (!context.config.delay || !context.config.delay.hide) {
  4543. context.hide();
  4544. return;
  4545. }
  4546. context._timeout = setTimeout(function () {
  4547. if (context._hoverState === HoverState.OUT) {
  4548. context.hide();
  4549. }
  4550. }, context.config.delay.hide);
  4551. };
  4552. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4553. for (var trigger in this._activeTrigger) {
  4554. if (this._activeTrigger[trigger]) {
  4555. return true;
  4556. }
  4557. }
  4558. return false;
  4559. };
  4560. _proto._getConfig = function _getConfig(config) {
  4561. var dataAttributes = $(this.element).data();
  4562. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4563. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4564. delete dataAttributes[dataAttr];
  4565. }
  4566. });
  4567. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4568. if (typeof config.delay === 'number') {
  4569. config.delay = {
  4570. show: config.delay,
  4571. hide: config.delay
  4572. };
  4573. }
  4574. if (typeof config.title === 'number') {
  4575. config.title = config.title.toString();
  4576. }
  4577. if (typeof config.content === 'number') {
  4578. config.content = config.content.toString();
  4579. }
  4580. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4581. if (config.sanitize) {
  4582. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4583. }
  4584. return config;
  4585. };
  4586. _proto._getDelegateConfig = function _getDelegateConfig() {
  4587. var config = {};
  4588. if (this.config) {
  4589. for (var key in this.config) {
  4590. if (this.constructor.Default[key] !== this.config[key]) {
  4591. config[key] = this.config[key];
  4592. }
  4593. }
  4594. }
  4595. return config;
  4596. };
  4597. _proto._cleanTipClass = function _cleanTipClass() {
  4598. var $tip = $(this.getTipElement());
  4599. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4600. if (tabClass !== null && tabClass.length) {
  4601. $tip.removeClass(tabClass.join(''));
  4602. }
  4603. };
  4604. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4605. var popperInstance = popperData.instance;
  4606. this.tip = popperInstance.popper;
  4607. this._cleanTipClass();
  4608. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4609. };
  4610. _proto._fixTransition = function _fixTransition() {
  4611. var tip = this.getTipElement();
  4612. var initConfigAnimation = this.config.animation;
  4613. if (tip.getAttribute('x-placement') !== null) {
  4614. return;
  4615. }
  4616. $(tip).removeClass(ClassName$6.FADE);
  4617. this.config.animation = false;
  4618. this.hide();
  4619. this.show();
  4620. this.config.animation = initConfigAnimation;
  4621. } // Static
  4622. ;
  4623. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4624. return this.each(function () {
  4625. var data = $(this).data(DATA_KEY$6);
  4626. var _config = typeof config === 'object' && config;
  4627. if (!data && /dispose|hide/.test(config)) {
  4628. return;
  4629. }
  4630. if (!data) {
  4631. data = new Tooltip(this, _config);
  4632. $(this).data(DATA_KEY$6, data);
  4633. }
  4634. if (typeof config === 'string') {
  4635. if (typeof data[config] === 'undefined') {
  4636. throw new TypeError("No method named \"" + config + "\"");
  4637. }
  4638. data[config]();
  4639. }
  4640. });
  4641. };
  4642. _createClass(Tooltip, null, [{
  4643. key: "VERSION",
  4644. get: function get() {
  4645. return VERSION$6;
  4646. }
  4647. }, {
  4648. key: "Default",
  4649. get: function get() {
  4650. return Default$4;
  4651. }
  4652. }, {
  4653. key: "NAME",
  4654. get: function get() {
  4655. return NAME$6;
  4656. }
  4657. }, {
  4658. key: "DATA_KEY",
  4659. get: function get() {
  4660. return DATA_KEY$6;
  4661. }
  4662. }, {
  4663. key: "Event",
  4664. get: function get() {
  4665. return Event$6;
  4666. }
  4667. }, {
  4668. key: "EVENT_KEY",
  4669. get: function get() {
  4670. return EVENT_KEY$6;
  4671. }
  4672. }, {
  4673. key: "DefaultType",
  4674. get: function get() {
  4675. return DefaultType$4;
  4676. }
  4677. }]);
  4678. return Tooltip;
  4679. }();
  4680. /**
  4681. * ------------------------------------------------------------------------
  4682. * jQuery
  4683. * ------------------------------------------------------------------------
  4684. */
  4685. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4686. $.fn[NAME$6].Constructor = Tooltip;
  4687. $.fn[NAME$6].noConflict = function () {
  4688. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4689. return Tooltip._jQueryInterface;
  4690. };
  4691. /**
  4692. * ------------------------------------------------------------------------
  4693. * Constants
  4694. * ------------------------------------------------------------------------
  4695. */
  4696. var NAME$7 = 'popover';
  4697. var VERSION$7 = '4.4.1';
  4698. var DATA_KEY$7 = 'bs.popover';
  4699. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4700. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4701. var CLASS_PREFIX$1 = 'bs-popover';
  4702. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4703. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4704. placement: 'right',
  4705. trigger: 'click',
  4706. content: '',
  4707. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4708. });
  4709. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4710. content: '(string|element|function)'
  4711. });
  4712. var ClassName$7 = {
  4713. FADE: 'fade',
  4714. SHOW: 'show'
  4715. };
  4716. var Selector$7 = {
  4717. TITLE: '.popover-header',
  4718. CONTENT: '.popover-body'
  4719. };
  4720. var Event$7 = {
  4721. HIDE: "hide" + EVENT_KEY$7,
  4722. HIDDEN: "hidden" + EVENT_KEY$7,
  4723. SHOW: "show" + EVENT_KEY$7,
  4724. SHOWN: "shown" + EVENT_KEY$7,
  4725. INSERTED: "inserted" + EVENT_KEY$7,
  4726. CLICK: "click" + EVENT_KEY$7,
  4727. FOCUSIN: "focusin" + EVENT_KEY$7,
  4728. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4729. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4730. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4731. };
  4732. /**
  4733. * ------------------------------------------------------------------------
  4734. * Class Definition
  4735. * ------------------------------------------------------------------------
  4736. */
  4737. var Popover =
  4738. /*#__PURE__*/
  4739. function (_Tooltip) {
  4740. _inheritsLoose(Popover, _Tooltip);
  4741. function Popover() {
  4742. return _Tooltip.apply(this, arguments) || this;
  4743. }
  4744. var _proto = Popover.prototype;
  4745. // Overrides
  4746. _proto.isWithContent = function isWithContent() {
  4747. return this.getTitle() || this._getContent();
  4748. };
  4749. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4750. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4751. };
  4752. _proto.getTipElement = function getTipElement() {
  4753. this.tip = this.tip || $(this.config.template)[0];
  4754. return this.tip;
  4755. };
  4756. _proto.setContent = function setContent() {
  4757. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4758. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4759. var content = this._getContent();
  4760. if (typeof content === 'function') {
  4761. content = content.call(this.element);
  4762. }
  4763. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4764. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4765. } // Private
  4766. ;
  4767. _proto._getContent = function _getContent() {
  4768. return this.element.getAttribute('data-content') || this.config.content;
  4769. };
  4770. _proto._cleanTipClass = function _cleanTipClass() {
  4771. var $tip = $(this.getTipElement());
  4772. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4773. if (tabClass !== null && tabClass.length > 0) {
  4774. $tip.removeClass(tabClass.join(''));
  4775. }
  4776. } // Static
  4777. ;
  4778. Popover._jQueryInterface = function _jQueryInterface(config) {
  4779. return this.each(function () {
  4780. var data = $(this).data(DATA_KEY$7);
  4781. var _config = typeof config === 'object' ? config : null;
  4782. if (!data && /dispose|hide/.test(config)) {
  4783. return;
  4784. }
  4785. if (!data) {
  4786. data = new Popover(this, _config);
  4787. $(this).data(DATA_KEY$7, data);
  4788. }
  4789. if (typeof config === 'string') {
  4790. if (typeof data[config] === 'undefined') {
  4791. throw new TypeError("No method named \"" + config + "\"");
  4792. }
  4793. data[config]();
  4794. }
  4795. });
  4796. };
  4797. _createClass(Popover, null, [{
  4798. key: "VERSION",
  4799. // Getters
  4800. get: function get() {
  4801. return VERSION$7;
  4802. }
  4803. }, {
  4804. key: "Default",
  4805. get: function get() {
  4806. return Default$5;
  4807. }
  4808. }, {
  4809. key: "NAME",
  4810. get: function get() {
  4811. return NAME$7;
  4812. }
  4813. }, {
  4814. key: "DATA_KEY",
  4815. get: function get() {
  4816. return DATA_KEY$7;
  4817. }
  4818. }, {
  4819. key: "Event",
  4820. get: function get() {
  4821. return Event$7;
  4822. }
  4823. }, {
  4824. key: "EVENT_KEY",
  4825. get: function get() {
  4826. return EVENT_KEY$7;
  4827. }
  4828. }, {
  4829. key: "DefaultType",
  4830. get: function get() {
  4831. return DefaultType$5;
  4832. }
  4833. }]);
  4834. return Popover;
  4835. }(Tooltip);
  4836. /**
  4837. * ------------------------------------------------------------------------
  4838. * jQuery
  4839. * ------------------------------------------------------------------------
  4840. */
  4841. $.fn[NAME$7] = Popover._jQueryInterface;
  4842. $.fn[NAME$7].Constructor = Popover;
  4843. $.fn[NAME$7].noConflict = function () {
  4844. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4845. return Popover._jQueryInterface;
  4846. };
  4847. /**
  4848. * ------------------------------------------------------------------------
  4849. * Constants
  4850. * ------------------------------------------------------------------------
  4851. */
  4852. var NAME$8 = 'scrollspy';
  4853. var VERSION$8 = '4.4.1';
  4854. var DATA_KEY$8 = 'bs.scrollspy';
  4855. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4856. var DATA_API_KEY$6 = '.data-api';
  4857. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4858. var Default$6 = {
  4859. offset: 10,
  4860. method: 'auto',
  4861. target: ''
  4862. };
  4863. var DefaultType$6 = {
  4864. offset: 'number',
  4865. method: 'string',
  4866. target: '(string|element)'
  4867. };
  4868. var Event$8 = {
  4869. ACTIVATE: "activate" + EVENT_KEY$8,
  4870. SCROLL: "scroll" + EVENT_KEY$8,
  4871. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4872. };
  4873. var ClassName$8 = {
  4874. DROPDOWN_ITEM: 'dropdown-item',
  4875. DROPDOWN_MENU: 'dropdown-menu',
  4876. ACTIVE: 'active'
  4877. };
  4878. var Selector$8 = {
  4879. DATA_SPY: '[data-spy="scroll"]',
  4880. ACTIVE: '.active',
  4881. NAV_LIST_GROUP: '.nav, .list-group',
  4882. NAV_LINKS: '.nav-link',
  4883. NAV_ITEMS: '.nav-item',
  4884. LIST_ITEMS: '.list-group-item',
  4885. DROPDOWN: '.dropdown',
  4886. DROPDOWN_ITEMS: '.dropdown-item',
  4887. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4888. };
  4889. var OffsetMethod = {
  4890. OFFSET: 'offset',
  4891. POSITION: 'position'
  4892. };
  4893. /**
  4894. * ------------------------------------------------------------------------
  4895. * Class Definition
  4896. * ------------------------------------------------------------------------
  4897. */
  4898. var ScrollSpy =
  4899. /*#__PURE__*/
  4900. function () {
  4901. function ScrollSpy(element, config) {
  4902. var _this = this;
  4903. this._element = element;
  4904. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4905. this._config = this._getConfig(config);
  4906. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4907. this._offsets = [];
  4908. this._targets = [];
  4909. this._activeTarget = null;
  4910. this._scrollHeight = 0;
  4911. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4912. return _this._process(event);
  4913. });
  4914. this.refresh();
  4915. this._process();
  4916. } // Getters
  4917. var _proto = ScrollSpy.prototype;
  4918. // Public
  4919. _proto.refresh = function refresh() {
  4920. var _this2 = this;
  4921. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4922. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4923. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4924. this._offsets = [];
  4925. this._targets = [];
  4926. this._scrollHeight = this._getScrollHeight();
  4927. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4928. targets.map(function (element) {
  4929. var target;
  4930. var targetSelector = Util.getSelectorFromElement(element);
  4931. if (targetSelector) {
  4932. target = document.querySelector(targetSelector);
  4933. }
  4934. if (target) {
  4935. var targetBCR = target.getBoundingClientRect();
  4936. if (targetBCR.width || targetBCR.height) {
  4937. // TODO (fat): remove sketch reliance on jQuery position/offset
  4938. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4939. }
  4940. }
  4941. return null;
  4942. }).filter(function (item) {
  4943. return item;
  4944. }).sort(function (a, b) {
  4945. return a[0] - b[0];
  4946. }).forEach(function (item) {
  4947. _this2._offsets.push(item[0]);
  4948. _this2._targets.push(item[1]);
  4949. });
  4950. };
  4951. _proto.dispose = function dispose() {
  4952. $.removeData(this._element, DATA_KEY$8);
  4953. $(this._scrollElement).off(EVENT_KEY$8);
  4954. this._element = null;
  4955. this._scrollElement = null;
  4956. this._config = null;
  4957. this._selector = null;
  4958. this._offsets = null;
  4959. this._targets = null;
  4960. this._activeTarget = null;
  4961. this._scrollHeight = null;
  4962. } // Private
  4963. ;
  4964. _proto._getConfig = function _getConfig(config) {
  4965. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4966. if (typeof config.target !== 'string') {
  4967. var id = $(config.target).attr('id');
  4968. if (!id) {
  4969. id = Util.getUID(NAME$8);
  4970. $(config.target).attr('id', id);
  4971. }
  4972. config.target = "#" + id;
  4973. }
  4974. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4975. return config;
  4976. };
  4977. _proto._getScrollTop = function _getScrollTop() {
  4978. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4979. };
  4980. _proto._getScrollHeight = function _getScrollHeight() {
  4981. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4982. };
  4983. _proto._getOffsetHeight = function _getOffsetHeight() {
  4984. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4985. };
  4986. _proto._process = function _process() {
  4987. var scrollTop = this._getScrollTop() + this._config.offset;
  4988. var scrollHeight = this._getScrollHeight();
  4989. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4990. if (this._scrollHeight !== scrollHeight) {
  4991. this.refresh();
  4992. }
  4993. if (scrollTop >= maxScroll) {
  4994. var target = this._targets[this._targets.length - 1];
  4995. if (this._activeTarget !== target) {
  4996. this._activate(target);
  4997. }
  4998. return;
  4999. }
  5000. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5001. this._activeTarget = null;
  5002. this._clear();
  5003. return;
  5004. }
  5005. var offsetLength = this._offsets.length;
  5006. for (var i = offsetLength; i--;) {
  5007. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5008. if (isActiveTarget) {
  5009. this._activate(this._targets[i]);
  5010. }
  5011. }
  5012. };
  5013. _proto._activate = function _activate(target) {
  5014. this._activeTarget = target;
  5015. this._clear();
  5016. var queries = this._selector.split(',').map(function (selector) {
  5017. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5018. });
  5019. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5020. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5021. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5022. $link.addClass(ClassName$8.ACTIVE);
  5023. } else {
  5024. // Set triggered link as active
  5025. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5026. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5027. $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
  5028. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5029. }
  5030. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5031. relatedTarget: target
  5032. });
  5033. };
  5034. _proto._clear = function _clear() {
  5035. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5036. return node.classList.contains(ClassName$8.ACTIVE);
  5037. }).forEach(function (node) {
  5038. return node.classList.remove(ClassName$8.ACTIVE);
  5039. });
  5040. } // Static
  5041. ;
  5042. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5043. return this.each(function () {
  5044. var data = $(this).data(DATA_KEY$8);
  5045. var _config = typeof config === 'object' && config;
  5046. if (!data) {
  5047. data = new ScrollSpy(this, _config);
  5048. $(this).data(DATA_KEY$8, data);
  5049. }
  5050. if (typeof config === 'string') {
  5051. if (typeof data[config] === 'undefined') {
  5052. throw new TypeError("No method named \"" + config + "\"");
  5053. }
  5054. data[config]();
  5055. }
  5056. });
  5057. };
  5058. _createClass(ScrollSpy, null, [{
  5059. key: "VERSION",
  5060. get: function get() {
  5061. return VERSION$8;
  5062. }
  5063. }, {
  5064. key: "Default",
  5065. get: function get() {
  5066. return Default$6;
  5067. }
  5068. }]);
  5069. return ScrollSpy;
  5070. }();
  5071. /**
  5072. * ------------------------------------------------------------------------
  5073. * Data Api implementation
  5074. * ------------------------------------------------------------------------
  5075. */
  5076. $(window).on(Event$8.LOAD_DATA_API, function () {
  5077. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5078. var scrollSpysLength = scrollSpys.length;
  5079. for (var i = scrollSpysLength; i--;) {
  5080. var $spy = $(scrollSpys[i]);
  5081. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5082. }
  5083. });
  5084. /**
  5085. * ------------------------------------------------------------------------
  5086. * jQuery
  5087. * ------------------------------------------------------------------------
  5088. */
  5089. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5090. $.fn[NAME$8].Constructor = ScrollSpy;
  5091. $.fn[NAME$8].noConflict = function () {
  5092. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5093. return ScrollSpy._jQueryInterface;
  5094. };
  5095. /**
  5096. * ------------------------------------------------------------------------
  5097. * Constants
  5098. * ------------------------------------------------------------------------
  5099. */
  5100. var NAME$9 = 'tab';
  5101. var VERSION$9 = '4.4.1';
  5102. var DATA_KEY$9 = 'bs.tab';
  5103. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5104. var DATA_API_KEY$7 = '.data-api';
  5105. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5106. var Event$9 = {
  5107. HIDE: "hide" + EVENT_KEY$9,
  5108. HIDDEN: "hidden" + EVENT_KEY$9,
  5109. SHOW: "show" + EVENT_KEY$9,
  5110. SHOWN: "shown" + EVENT_KEY$9,
  5111. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5112. };
  5113. var ClassName$9 = {
  5114. DROPDOWN_MENU: 'dropdown-menu',
  5115. ACTIVE: 'active',
  5116. DISABLED: 'disabled',
  5117. FADE: 'fade',
  5118. SHOW: 'show'
  5119. };
  5120. var Selector$9 = {
  5121. DROPDOWN: '.dropdown',
  5122. NAV_LIST_GROUP: '.nav, .list-group',
  5123. ACTIVE: '.active',
  5124. ACTIVE_UL: '> li > .active',
  5125. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5126. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5127. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5128. };
  5129. /**
  5130. * ------------------------------------------------------------------------
  5131. * Class Definition
  5132. * ------------------------------------------------------------------------
  5133. */
  5134. var Tab =
  5135. /*#__PURE__*/
  5136. function () {
  5137. function Tab(element) {
  5138. this._element = element;
  5139. } // Getters
  5140. var _proto = Tab.prototype;
  5141. // Public
  5142. _proto.show = function show() {
  5143. var _this = this;
  5144. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5145. return;
  5146. }
  5147. var target;
  5148. var previous;
  5149. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5150. var selector = Util.getSelectorFromElement(this._element);
  5151. if (listElement) {
  5152. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5153. previous = $.makeArray($(listElement).find(itemSelector));
  5154. previous = previous[previous.length - 1];
  5155. }
  5156. var hideEvent = $.Event(Event$9.HIDE, {
  5157. relatedTarget: this._element
  5158. });
  5159. var showEvent = $.Event(Event$9.SHOW, {
  5160. relatedTarget: previous
  5161. });
  5162. if (previous) {
  5163. $(previous).trigger(hideEvent);
  5164. }
  5165. $(this._element).trigger(showEvent);
  5166. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5167. return;
  5168. }
  5169. if (selector) {
  5170. target = document.querySelector(selector);
  5171. }
  5172. this._activate(this._element, listElement);
  5173. var complete = function complete() {
  5174. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5175. relatedTarget: _this._element
  5176. });
  5177. var shownEvent = $.Event(Event$9.SHOWN, {
  5178. relatedTarget: previous
  5179. });
  5180. $(previous).trigger(hiddenEvent);
  5181. $(_this._element).trigger(shownEvent);
  5182. };
  5183. if (target) {
  5184. this._activate(target, target.parentNode, complete);
  5185. } else {
  5186. complete();
  5187. }
  5188. };
  5189. _proto.dispose = function dispose() {
  5190. $.removeData(this._element, DATA_KEY$9);
  5191. this._element = null;
  5192. } // Private
  5193. ;
  5194. _proto._activate = function _activate(element, container, callback) {
  5195. var _this2 = this;
  5196. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5197. var active = activeElements[0];
  5198. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5199. var complete = function complete() {
  5200. return _this2._transitionComplete(element, active, callback);
  5201. };
  5202. if (active && isTransitioning) {
  5203. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5204. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5205. } else {
  5206. complete();
  5207. }
  5208. };
  5209. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5210. if (active) {
  5211. $(active).removeClass(ClassName$9.ACTIVE);
  5212. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5213. if (dropdownChild) {
  5214. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5215. }
  5216. if (active.getAttribute('role') === 'tab') {
  5217. active.setAttribute('aria-selected', false);
  5218. }
  5219. }
  5220. $(element).addClass(ClassName$9.ACTIVE);
  5221. if (element.getAttribute('role') === 'tab') {
  5222. element.setAttribute('aria-selected', true);
  5223. }
  5224. Util.reflow(element);
  5225. if (element.classList.contains(ClassName$9.FADE)) {
  5226. element.classList.add(ClassName$9.SHOW);
  5227. }
  5228. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5229. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5230. if (dropdownElement) {
  5231. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5232. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5233. }
  5234. element.setAttribute('aria-expanded', true);
  5235. }
  5236. if (callback) {
  5237. callback();
  5238. }
  5239. } // Static
  5240. ;
  5241. Tab._jQueryInterface = function _jQueryInterface(config) {
  5242. return this.each(function () {
  5243. var $this = $(this);
  5244. var data = $this.data(DATA_KEY$9);
  5245. if (!data) {
  5246. data = new Tab(this);
  5247. $this.data(DATA_KEY$9, data);
  5248. }
  5249. if (typeof config === 'string') {
  5250. if (typeof data[config] === 'undefined') {
  5251. throw new TypeError("No method named \"" + config + "\"");
  5252. }
  5253. data[config]();
  5254. }
  5255. });
  5256. };
  5257. _createClass(Tab, null, [{
  5258. key: "VERSION",
  5259. get: function get() {
  5260. return VERSION$9;
  5261. }
  5262. }]);
  5263. return Tab;
  5264. }();
  5265. /**
  5266. * ------------------------------------------------------------------------
  5267. * Data Api implementation
  5268. * ------------------------------------------------------------------------
  5269. */
  5270. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5271. event.preventDefault();
  5272. Tab._jQueryInterface.call($(this), 'show');
  5273. });
  5274. /**
  5275. * ------------------------------------------------------------------------
  5276. * jQuery
  5277. * ------------------------------------------------------------------------
  5278. */
  5279. $.fn[NAME$9] = Tab._jQueryInterface;
  5280. $.fn[NAME$9].Constructor = Tab;
  5281. $.fn[NAME$9].noConflict = function () {
  5282. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5283. return Tab._jQueryInterface;
  5284. };
  5285. /**
  5286. * ------------------------------------------------------------------------
  5287. * Constants
  5288. * ------------------------------------------------------------------------
  5289. */
  5290. var NAME$a = 'toast';
  5291. var VERSION$a = '4.4.1';
  5292. var DATA_KEY$a = 'bs.toast';
  5293. var EVENT_KEY$a = "." + DATA_KEY$a;
  5294. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5295. var Event$a = {
  5296. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5297. HIDE: "hide" + EVENT_KEY$a,
  5298. HIDDEN: "hidden" + EVENT_KEY$a,
  5299. SHOW: "show" + EVENT_KEY$a,
  5300. SHOWN: "shown" + EVENT_KEY$a
  5301. };
  5302. var ClassName$a = {
  5303. FADE: 'fade',
  5304. HIDE: 'hide',
  5305. SHOW: 'show',
  5306. SHOWING: 'showing'
  5307. };
  5308. var DefaultType$7 = {
  5309. animation: 'boolean',
  5310. autohide: 'boolean',
  5311. delay: 'number'
  5312. };
  5313. var Default$7 = {
  5314. animation: true,
  5315. autohide: true,
  5316. delay: 500
  5317. };
  5318. var Selector$a = {
  5319. DATA_DISMISS: '[data-dismiss="toast"]'
  5320. };
  5321. /**
  5322. * ------------------------------------------------------------------------
  5323. * Class Definition
  5324. * ------------------------------------------------------------------------
  5325. */
  5326. var Toast =
  5327. /*#__PURE__*/
  5328. function () {
  5329. function Toast(element, config) {
  5330. this._element = element;
  5331. this._config = this._getConfig(config);
  5332. this._timeout = null;
  5333. this._setListeners();
  5334. } // Getters
  5335. var _proto = Toast.prototype;
  5336. // Public
  5337. _proto.show = function show() {
  5338. var _this = this;
  5339. var showEvent = $.Event(Event$a.SHOW);
  5340. $(this._element).trigger(showEvent);
  5341. if (showEvent.isDefaultPrevented()) {
  5342. return;
  5343. }
  5344. if (this._config.animation) {
  5345. this._element.classList.add(ClassName$a.FADE);
  5346. }
  5347. var complete = function complete() {
  5348. _this._element.classList.remove(ClassName$a.SHOWING);
  5349. _this._element.classList.add(ClassName$a.SHOW);
  5350. $(_this._element).trigger(Event$a.SHOWN);
  5351. if (_this._config.autohide) {
  5352. _this._timeout = setTimeout(function () {
  5353. _this.hide();
  5354. }, _this._config.delay);
  5355. }
  5356. };
  5357. this._element.classList.remove(ClassName$a.HIDE);
  5358. Util.reflow(this._element);
  5359. this._element.classList.add(ClassName$a.SHOWING);
  5360. if (this._config.animation) {
  5361. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5362. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5363. } else {
  5364. complete();
  5365. }
  5366. };
  5367. _proto.hide = function hide() {
  5368. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5369. return;
  5370. }
  5371. var hideEvent = $.Event(Event$a.HIDE);
  5372. $(this._element).trigger(hideEvent);
  5373. if (hideEvent.isDefaultPrevented()) {
  5374. return;
  5375. }
  5376. this._close();
  5377. };
  5378. _proto.dispose = function dispose() {
  5379. clearTimeout(this._timeout);
  5380. this._timeout = null;
  5381. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5382. this._element.classList.remove(ClassName$a.SHOW);
  5383. }
  5384. $(this._element).off(Event$a.CLICK_DISMISS);
  5385. $.removeData(this._element, DATA_KEY$a);
  5386. this._element = null;
  5387. this._config = null;
  5388. } // Private
  5389. ;
  5390. _proto._getConfig = function _getConfig(config) {
  5391. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5392. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5393. return config;
  5394. };
  5395. _proto._setListeners = function _setListeners() {
  5396. var _this2 = this;
  5397. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5398. return _this2.hide();
  5399. });
  5400. };
  5401. _proto._close = function _close() {
  5402. var _this3 = this;
  5403. var complete = function complete() {
  5404. _this3._element.classList.add(ClassName$a.HIDE);
  5405. $(_this3._element).trigger(Event$a.HIDDEN);
  5406. };
  5407. this._element.classList.remove(ClassName$a.SHOW);
  5408. if (this._config.animation) {
  5409. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5410. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5411. } else {
  5412. complete();
  5413. }
  5414. } // Static
  5415. ;
  5416. Toast._jQueryInterface = function _jQueryInterface(config) {
  5417. return this.each(function () {
  5418. var $element = $(this);
  5419. var data = $element.data(DATA_KEY$a);
  5420. var _config = typeof config === 'object' && config;
  5421. if (!data) {
  5422. data = new Toast(this, _config);
  5423. $element.data(DATA_KEY$a, data);
  5424. }
  5425. if (typeof config === 'string') {
  5426. if (typeof data[config] === 'undefined') {
  5427. throw new TypeError("No method named \"" + config + "\"");
  5428. }
  5429. data[config](this);
  5430. }
  5431. });
  5432. };
  5433. _createClass(Toast, null, [{
  5434. key: "VERSION",
  5435. get: function get() {
  5436. return VERSION$a;
  5437. }
  5438. }, {
  5439. key: "DefaultType",
  5440. get: function get() {
  5441. return DefaultType$7;
  5442. }
  5443. }, {
  5444. key: "Default",
  5445. get: function get() {
  5446. return Default$7;
  5447. }
  5448. }]);
  5449. return Toast;
  5450. }();
  5451. /**
  5452. * ------------------------------------------------------------------------
  5453. * jQuery
  5454. * ------------------------------------------------------------------------
  5455. */
  5456. $.fn[NAME$a] = Toast._jQueryInterface;
  5457. $.fn[NAME$a].Constructor = Toast;
  5458. $.fn[NAME$a].noConflict = function () {
  5459. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5460. return Toast._jQueryInterface;
  5461. };
  5462. exports.Alert = Alert;
  5463. exports.Button = Button;
  5464. exports.Carousel = Carousel;
  5465. exports.Collapse = Collapse;
  5466. exports.Dropdown = Dropdown;
  5467. exports.Modal = Modal;
  5468. exports.Popover = Popover;
  5469. exports.Scrollspy = ScrollSpy;
  5470. exports.Tab = Tab;
  5471. exports.Toast = Toast;
  5472. exports.Tooltip = Tooltip;
  5473. exports.Util = Util;
  5474. Object.defineProperty(exports, '__esModule', { value: true });
  5475. })));
  5476. //# sourceMappingURL=bootstrap.js.map
  5477. /***/ }),
  5478. /***/ "./node_modules/buffer/index.js":
  5479. /*!**************************************!*\
  5480. !*** ./node_modules/buffer/index.js ***!
  5481. \**************************************/
  5482. /*! no static exports found */
  5483. /***/ (function(module, exports, __webpack_require__) {
  5484. "use strict";
  5485. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5486. * The buffer module from node.js, for the browser.
  5487. *
  5488. * @author Feross Aboukhadijeh <http://feross.org>
  5489. * @license MIT
  5490. */
  5491. /* eslint-disable no-proto */
  5492. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5493. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5494. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5495. exports.Buffer = Buffer
  5496. exports.SlowBuffer = SlowBuffer
  5497. exports.INSPECT_MAX_BYTES = 50
  5498. /**
  5499. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5500. * === true Use Uint8Array implementation (fastest)
  5501. * === false Use Object implementation (most compatible, even IE6)
  5502. *
  5503. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5504. * Opera 11.6+, iOS 4.2+.
  5505. *
  5506. * Due to various browser bugs, sometimes the Object implementation will be used even
  5507. * when the browser supports typed arrays.
  5508. *
  5509. * Note:
  5510. *
  5511. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5512. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5513. *
  5514. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5515. *
  5516. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5517. * incorrect length in some situations.
  5518. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5519. * get the Object implementation, which is slower but behaves correctly.
  5520. */
  5521. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5522. ? global.TYPED_ARRAY_SUPPORT
  5523. : typedArraySupport()
  5524. /*
  5525. * Export kMaxLength after typed array support is determined.
  5526. */
  5527. exports.kMaxLength = kMaxLength()
  5528. function typedArraySupport () {
  5529. try {
  5530. var arr = new Uint8Array(1)
  5531. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5532. return arr.foo() === 42 && // typed array instances can be augmented
  5533. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5534. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5535. } catch (e) {
  5536. return false
  5537. }
  5538. }
  5539. function kMaxLength () {
  5540. return Buffer.TYPED_ARRAY_SUPPORT
  5541. ? 0x7fffffff
  5542. : 0x3fffffff
  5543. }
  5544. function createBuffer (that, length) {
  5545. if (kMaxLength() < length) {
  5546. throw new RangeError('Invalid typed array length')
  5547. }
  5548. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5549. // Return an augmented `Uint8Array` instance, for best performance
  5550. that = new Uint8Array(length)
  5551. that.__proto__ = Buffer.prototype
  5552. } else {
  5553. // Fallback: Return an object instance of the Buffer class
  5554. if (that === null) {
  5555. that = new Buffer(length)
  5556. }
  5557. that.length = length
  5558. }
  5559. return that
  5560. }
  5561. /**
  5562. * The Buffer constructor returns instances of `Uint8Array` that have their
  5563. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5564. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5565. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5566. * returns a single octet.
  5567. *
  5568. * The `Uint8Array` prototype remains unmodified.
  5569. */
  5570. function Buffer (arg, encodingOrOffset, length) {
  5571. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5572. return new Buffer(arg, encodingOrOffset, length)
  5573. }
  5574. // Common case.
  5575. if (typeof arg === 'number') {
  5576. if (typeof encodingOrOffset === 'string') {
  5577. throw new Error(
  5578. 'If encoding is specified then the first argument must be a string'
  5579. )
  5580. }
  5581. return allocUnsafe(this, arg)
  5582. }
  5583. return from(this, arg, encodingOrOffset, length)
  5584. }
  5585. Buffer.poolSize = 8192 // not used by this implementation
  5586. // TODO: Legacy, not needed anymore. Remove in next major version.
  5587. Buffer._augment = function (arr) {
  5588. arr.__proto__ = Buffer.prototype
  5589. return arr
  5590. }
  5591. function from (that, value, encodingOrOffset, length) {
  5592. if (typeof value === 'number') {
  5593. throw new TypeError('"value" argument must not be a number')
  5594. }
  5595. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5596. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5597. }
  5598. if (typeof value === 'string') {
  5599. return fromString(that, value, encodingOrOffset)
  5600. }
  5601. return fromObject(that, value)
  5602. }
  5603. /**
  5604. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5605. * if value is a number.
  5606. * Buffer.from(str[, encoding])
  5607. * Buffer.from(array)
  5608. * Buffer.from(buffer)
  5609. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5610. **/
  5611. Buffer.from = function (value, encodingOrOffset, length) {
  5612. return from(null, value, encodingOrOffset, length)
  5613. }
  5614. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5615. Buffer.prototype.__proto__ = Uint8Array.prototype
  5616. Buffer.__proto__ = Uint8Array
  5617. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5618. Buffer[Symbol.species] === Buffer) {
  5619. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5620. Object.defineProperty(Buffer, Symbol.species, {
  5621. value: null,
  5622. configurable: true
  5623. })
  5624. }
  5625. }
  5626. function assertSize (size) {
  5627. if (typeof size !== 'number') {
  5628. throw new TypeError('"size" argument must be a number')
  5629. } else if (size < 0) {
  5630. throw new RangeError('"size" argument must not be negative')
  5631. }
  5632. }
  5633. function alloc (that, size, fill, encoding) {
  5634. assertSize(size)
  5635. if (size <= 0) {
  5636. return createBuffer(that, size)
  5637. }
  5638. if (fill !== undefined) {
  5639. // Only pay attention to encoding if it's a string. This
  5640. // prevents accidentally sending in a number that would
  5641. // be interpretted as a start offset.
  5642. return typeof encoding === 'string'
  5643. ? createBuffer(that, size).fill(fill, encoding)
  5644. : createBuffer(that, size).fill(fill)
  5645. }
  5646. return createBuffer(that, size)
  5647. }
  5648. /**
  5649. * Creates a new filled Buffer instance.
  5650. * alloc(size[, fill[, encoding]])
  5651. **/
  5652. Buffer.alloc = function (size, fill, encoding) {
  5653. return alloc(null, size, fill, encoding)
  5654. }
  5655. function allocUnsafe (that, size) {
  5656. assertSize(size)
  5657. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5658. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5659. for (var i = 0; i < size; ++i) {
  5660. that[i] = 0
  5661. }
  5662. }
  5663. return that
  5664. }
  5665. /**
  5666. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5667. * */
  5668. Buffer.allocUnsafe = function (size) {
  5669. return allocUnsafe(null, size)
  5670. }
  5671. /**
  5672. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5673. */
  5674. Buffer.allocUnsafeSlow = function (size) {
  5675. return allocUnsafe(null, size)
  5676. }
  5677. function fromString (that, string, encoding) {
  5678. if (typeof encoding !== 'string' || encoding === '') {
  5679. encoding = 'utf8'
  5680. }
  5681. if (!Buffer.isEncoding(encoding)) {
  5682. throw new TypeError('"encoding" must be a valid string encoding')
  5683. }
  5684. var length = byteLength(string, encoding) | 0
  5685. that = createBuffer(that, length)
  5686. var actual = that.write(string, encoding)
  5687. if (actual !== length) {
  5688. // Writing a hex string, for example, that contains invalid characters will
  5689. // cause everything after the first invalid character to be ignored. (e.g.
  5690. // 'abxxcd' will be treated as 'ab')
  5691. that = that.slice(0, actual)
  5692. }
  5693. return that
  5694. }
  5695. function fromArrayLike (that, array) {
  5696. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5697. that = createBuffer(that, length)
  5698. for (var i = 0; i < length; i += 1) {
  5699. that[i] = array[i] & 255
  5700. }
  5701. return that
  5702. }
  5703. function fromArrayBuffer (that, array, byteOffset, length) {
  5704. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5705. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5706. throw new RangeError('\'offset\' is out of bounds')
  5707. }
  5708. if (array.byteLength < byteOffset + (length || 0)) {
  5709. throw new RangeError('\'length\' is out of bounds')
  5710. }
  5711. if (byteOffset === undefined && length === undefined) {
  5712. array = new Uint8Array(array)
  5713. } else if (length === undefined) {
  5714. array = new Uint8Array(array, byteOffset)
  5715. } else {
  5716. array = new Uint8Array(array, byteOffset, length)
  5717. }
  5718. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5719. // Return an augmented `Uint8Array` instance, for best performance
  5720. that = array
  5721. that.__proto__ = Buffer.prototype
  5722. } else {
  5723. // Fallback: Return an object instance of the Buffer class
  5724. that = fromArrayLike(that, array)
  5725. }
  5726. return that
  5727. }
  5728. function fromObject (that, obj) {
  5729. if (Buffer.isBuffer(obj)) {
  5730. var len = checked(obj.length) | 0
  5731. that = createBuffer(that, len)
  5732. if (that.length === 0) {
  5733. return that
  5734. }
  5735. obj.copy(that, 0, 0, len)
  5736. return that
  5737. }
  5738. if (obj) {
  5739. if ((typeof ArrayBuffer !== 'undefined' &&
  5740. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5741. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5742. return createBuffer(that, 0)
  5743. }
  5744. return fromArrayLike(that, obj)
  5745. }
  5746. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5747. return fromArrayLike(that, obj.data)
  5748. }
  5749. }
  5750. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5751. }
  5752. function checked (length) {
  5753. // Note: cannot use `length < kMaxLength()` here because that fails when
  5754. // length is NaN (which is otherwise coerced to zero.)
  5755. if (length >= kMaxLength()) {
  5756. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5757. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5758. }
  5759. return length | 0
  5760. }
  5761. function SlowBuffer (length) {
  5762. if (+length != length) { // eslint-disable-line eqeqeq
  5763. length = 0
  5764. }
  5765. return Buffer.alloc(+length)
  5766. }
  5767. Buffer.isBuffer = function isBuffer (b) {
  5768. return !!(b != null && b._isBuffer)
  5769. }
  5770. Buffer.compare = function compare (a, b) {
  5771. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5772. throw new TypeError('Arguments must be Buffers')
  5773. }
  5774. if (a === b) return 0
  5775. var x = a.length
  5776. var y = b.length
  5777. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5778. if (a[i] !== b[i]) {
  5779. x = a[i]
  5780. y = b[i]
  5781. break
  5782. }
  5783. }
  5784. if (x < y) return -1
  5785. if (y < x) return 1
  5786. return 0
  5787. }
  5788. Buffer.isEncoding = function isEncoding (encoding) {
  5789. switch (String(encoding).toLowerCase()) {
  5790. case 'hex':
  5791. case 'utf8':
  5792. case 'utf-8':
  5793. case 'ascii':
  5794. case 'latin1':
  5795. case 'binary':
  5796. case 'base64':
  5797. case 'ucs2':
  5798. case 'ucs-2':
  5799. case 'utf16le':
  5800. case 'utf-16le':
  5801. return true
  5802. default:
  5803. return false
  5804. }
  5805. }
  5806. Buffer.concat = function concat (list, length) {
  5807. if (!isArray(list)) {
  5808. throw new TypeError('"list" argument must be an Array of Buffers')
  5809. }
  5810. if (list.length === 0) {
  5811. return Buffer.alloc(0)
  5812. }
  5813. var i
  5814. if (length === undefined) {
  5815. length = 0
  5816. for (i = 0; i < list.length; ++i) {
  5817. length += list[i].length
  5818. }
  5819. }
  5820. var buffer = Buffer.allocUnsafe(length)
  5821. var pos = 0
  5822. for (i = 0; i < list.length; ++i) {
  5823. var buf = list[i]
  5824. if (!Buffer.isBuffer(buf)) {
  5825. throw new TypeError('"list" argument must be an Array of Buffers')
  5826. }
  5827. buf.copy(buffer, pos)
  5828. pos += buf.length
  5829. }
  5830. return buffer
  5831. }
  5832. function byteLength (string, encoding) {
  5833. if (Buffer.isBuffer(string)) {
  5834. return string.length
  5835. }
  5836. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5837. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5838. return string.byteLength
  5839. }
  5840. if (typeof string !== 'string') {
  5841. string = '' + string
  5842. }
  5843. var len = string.length
  5844. if (len === 0) return 0
  5845. // Use a for loop to avoid recursion
  5846. var loweredCase = false
  5847. for (;;) {
  5848. switch (encoding) {
  5849. case 'ascii':
  5850. case 'latin1':
  5851. case 'binary':
  5852. return len
  5853. case 'utf8':
  5854. case 'utf-8':
  5855. case undefined:
  5856. return utf8ToBytes(string).length
  5857. case 'ucs2':
  5858. case 'ucs-2':
  5859. case 'utf16le':
  5860. case 'utf-16le':
  5861. return len * 2
  5862. case 'hex':
  5863. return len >>> 1
  5864. case 'base64':
  5865. return base64ToBytes(string).length
  5866. default:
  5867. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5868. encoding = ('' + encoding).toLowerCase()
  5869. loweredCase = true
  5870. }
  5871. }
  5872. }
  5873. Buffer.byteLength = byteLength
  5874. function slowToString (encoding, start, end) {
  5875. var loweredCase = false
  5876. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5877. // property of a typed array.
  5878. // This behaves neither like String nor Uint8Array in that we set start/end
  5879. // to their upper/lower bounds if the value passed is out of range.
  5880. // undefined is handled specially as per ECMA-262 6th Edition,
  5881. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5882. if (start === undefined || start < 0) {
  5883. start = 0
  5884. }
  5885. // Return early if start > this.length. Done here to prevent potential uint32
  5886. // coercion fail below.
  5887. if (start > this.length) {
  5888. return ''
  5889. }
  5890. if (end === undefined || end > this.length) {
  5891. end = this.length
  5892. }
  5893. if (end <= 0) {
  5894. return ''
  5895. }
  5896. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5897. end >>>= 0
  5898. start >>>= 0
  5899. if (end <= start) {
  5900. return ''
  5901. }
  5902. if (!encoding) encoding = 'utf8'
  5903. while (true) {
  5904. switch (encoding) {
  5905. case 'hex':
  5906. return hexSlice(this, start, end)
  5907. case 'utf8':
  5908. case 'utf-8':
  5909. return utf8Slice(this, start, end)
  5910. case 'ascii':
  5911. return asciiSlice(this, start, end)
  5912. case 'latin1':
  5913. case 'binary':
  5914. return latin1Slice(this, start, end)
  5915. case 'base64':
  5916. return base64Slice(this, start, end)
  5917. case 'ucs2':
  5918. case 'ucs-2':
  5919. case 'utf16le':
  5920. case 'utf-16le':
  5921. return utf16leSlice(this, start, end)
  5922. default:
  5923. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5924. encoding = (encoding + '').toLowerCase()
  5925. loweredCase = true
  5926. }
  5927. }
  5928. }
  5929. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5930. // Buffer instances.
  5931. Buffer.prototype._isBuffer = true
  5932. function swap (b, n, m) {
  5933. var i = b[n]
  5934. b[n] = b[m]
  5935. b[m] = i
  5936. }
  5937. Buffer.prototype.swap16 = function swap16 () {
  5938. var len = this.length
  5939. if (len % 2 !== 0) {
  5940. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5941. }
  5942. for (var i = 0; i < len; i += 2) {
  5943. swap(this, i, i + 1)
  5944. }
  5945. return this
  5946. }
  5947. Buffer.prototype.swap32 = function swap32 () {
  5948. var len = this.length
  5949. if (len % 4 !== 0) {
  5950. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5951. }
  5952. for (var i = 0; i < len; i += 4) {
  5953. swap(this, i, i + 3)
  5954. swap(this, i + 1, i + 2)
  5955. }
  5956. return this
  5957. }
  5958. Buffer.prototype.swap64 = function swap64 () {
  5959. var len = this.length
  5960. if (len % 8 !== 0) {
  5961. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5962. }
  5963. for (var i = 0; i < len; i += 8) {
  5964. swap(this, i, i + 7)
  5965. swap(this, i + 1, i + 6)
  5966. swap(this, i + 2, i + 5)
  5967. swap(this, i + 3, i + 4)
  5968. }
  5969. return this
  5970. }
  5971. Buffer.prototype.toString = function toString () {
  5972. var length = this.length | 0
  5973. if (length === 0) return ''
  5974. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5975. return slowToString.apply(this, arguments)
  5976. }
  5977. Buffer.prototype.equals = function equals (b) {
  5978. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5979. if (this === b) return true
  5980. return Buffer.compare(this, b) === 0
  5981. }
  5982. Buffer.prototype.inspect = function inspect () {
  5983. var str = ''
  5984. var max = exports.INSPECT_MAX_BYTES
  5985. if (this.length > 0) {
  5986. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5987. if (this.length > max) str += ' ... '
  5988. }
  5989. return '<Buffer ' + str + '>'
  5990. }
  5991. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  5992. if (!Buffer.isBuffer(target)) {
  5993. throw new TypeError('Argument must be a Buffer')
  5994. }
  5995. if (start === undefined) {
  5996. start = 0
  5997. }
  5998. if (end === undefined) {
  5999. end = target ? target.length : 0
  6000. }
  6001. if (thisStart === undefined) {
  6002. thisStart = 0
  6003. }
  6004. if (thisEnd === undefined) {
  6005. thisEnd = this.length
  6006. }
  6007. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6008. throw new RangeError('out of range index')
  6009. }
  6010. if (thisStart >= thisEnd && start >= end) {
  6011. return 0
  6012. }
  6013. if (thisStart >= thisEnd) {
  6014. return -1
  6015. }
  6016. if (start >= end) {
  6017. return 1
  6018. }
  6019. start >>>= 0
  6020. end >>>= 0
  6021. thisStart >>>= 0
  6022. thisEnd >>>= 0
  6023. if (this === target) return 0
  6024. var x = thisEnd - thisStart
  6025. var y = end - start
  6026. var len = Math.min(x, y)
  6027. var thisCopy = this.slice(thisStart, thisEnd)
  6028. var targetCopy = target.slice(start, end)
  6029. for (var i = 0; i < len; ++i) {
  6030. if (thisCopy[i] !== targetCopy[i]) {
  6031. x = thisCopy[i]
  6032. y = targetCopy[i]
  6033. break
  6034. }
  6035. }
  6036. if (x < y) return -1
  6037. if (y < x) return 1
  6038. return 0
  6039. }
  6040. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6041. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6042. //
  6043. // Arguments:
  6044. // - buffer - a Buffer to search
  6045. // - val - a string, Buffer, or number
  6046. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6047. // - encoding - an optional encoding, relevant is val is a string
  6048. // - dir - true for indexOf, false for lastIndexOf
  6049. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6050. // Empty buffer means no match
  6051. if (buffer.length === 0) return -1
  6052. // Normalize byteOffset
  6053. if (typeof byteOffset === 'string') {
  6054. encoding = byteOffset
  6055. byteOffset = 0
  6056. } else if (byteOffset > 0x7fffffff) {
  6057. byteOffset = 0x7fffffff
  6058. } else if (byteOffset < -0x80000000) {
  6059. byteOffset = -0x80000000
  6060. }
  6061. byteOffset = +byteOffset // Coerce to Number.
  6062. if (isNaN(byteOffset)) {
  6063. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6064. byteOffset = dir ? 0 : (buffer.length - 1)
  6065. }
  6066. // Normalize byteOffset: negative offsets start from the end of the buffer
  6067. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6068. if (byteOffset >= buffer.length) {
  6069. if (dir) return -1
  6070. else byteOffset = buffer.length - 1
  6071. } else if (byteOffset < 0) {
  6072. if (dir) byteOffset = 0
  6073. else return -1
  6074. }
  6075. // Normalize val
  6076. if (typeof val === 'string') {
  6077. val = Buffer.from(val, encoding)
  6078. }
  6079. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6080. if (Buffer.isBuffer(val)) {
  6081. // Special case: looking for empty string/buffer always fails
  6082. if (val.length === 0) {
  6083. return -1
  6084. }
  6085. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6086. } else if (typeof val === 'number') {
  6087. val = val & 0xFF // Search for a byte value [0-255]
  6088. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6089. typeof Uint8Array.prototype.indexOf === 'function') {
  6090. if (dir) {
  6091. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6092. } else {
  6093. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6094. }
  6095. }
  6096. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6097. }
  6098. throw new TypeError('val must be string, number or Buffer')
  6099. }
  6100. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6101. var indexSize = 1
  6102. var arrLength = arr.length
  6103. var valLength = val.length
  6104. if (encoding !== undefined) {
  6105. encoding = String(encoding).toLowerCase()
  6106. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6107. encoding === 'utf16le' || encoding === 'utf-16le') {
  6108. if (arr.length < 2 || val.length < 2) {
  6109. return -1
  6110. }
  6111. indexSize = 2
  6112. arrLength /= 2
  6113. valLength /= 2
  6114. byteOffset /= 2
  6115. }
  6116. }
  6117. function read (buf, i) {
  6118. if (indexSize === 1) {
  6119. return buf[i]
  6120. } else {
  6121. return buf.readUInt16BE(i * indexSize)
  6122. }
  6123. }
  6124. var i
  6125. if (dir) {
  6126. var foundIndex = -1
  6127. for (i = byteOffset; i < arrLength; i++) {
  6128. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6129. if (foundIndex === -1) foundIndex = i
  6130. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6131. } else {
  6132. if (foundIndex !== -1) i -= i - foundIndex
  6133. foundIndex = -1
  6134. }
  6135. }
  6136. } else {
  6137. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6138. for (i = byteOffset; i >= 0; i--) {
  6139. var found = true
  6140. for (var j = 0; j < valLength; j++) {
  6141. if (read(arr, i + j) !== read(val, j)) {
  6142. found = false
  6143. break
  6144. }
  6145. }
  6146. if (found) return i
  6147. }
  6148. }
  6149. return -1
  6150. }
  6151. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6152. return this.indexOf(val, byteOffset, encoding) !== -1
  6153. }
  6154. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6155. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6156. }
  6157. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6158. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6159. }
  6160. function hexWrite (buf, string, offset, length) {
  6161. offset = Number(offset) || 0
  6162. var remaining = buf.length - offset
  6163. if (!length) {
  6164. length = remaining
  6165. } else {
  6166. length = Number(length)
  6167. if (length > remaining) {
  6168. length = remaining
  6169. }
  6170. }
  6171. // must be an even number of digits
  6172. var strLen = string.length
  6173. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6174. if (length > strLen / 2) {
  6175. length = strLen / 2
  6176. }
  6177. for (var i = 0; i < length; ++i) {
  6178. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6179. if (isNaN(parsed)) return i
  6180. buf[offset + i] = parsed
  6181. }
  6182. return i
  6183. }
  6184. function utf8Write (buf, string, offset, length) {
  6185. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6186. }
  6187. function asciiWrite (buf, string, offset, length) {
  6188. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6189. }
  6190. function latin1Write (buf, string, offset, length) {
  6191. return asciiWrite(buf, string, offset, length)
  6192. }
  6193. function base64Write (buf, string, offset, length) {
  6194. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6195. }
  6196. function ucs2Write (buf, string, offset, length) {
  6197. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6198. }
  6199. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6200. // Buffer#write(string)
  6201. if (offset === undefined) {
  6202. encoding = 'utf8'
  6203. length = this.length
  6204. offset = 0
  6205. // Buffer#write(string, encoding)
  6206. } else if (length === undefined && typeof offset === 'string') {
  6207. encoding = offset
  6208. length = this.length
  6209. offset = 0
  6210. // Buffer#write(string, offset[, length][, encoding])
  6211. } else if (isFinite(offset)) {
  6212. offset = offset | 0
  6213. if (isFinite(length)) {
  6214. length = length | 0
  6215. if (encoding === undefined) encoding = 'utf8'
  6216. } else {
  6217. encoding = length
  6218. length = undefined
  6219. }
  6220. // legacy write(string, encoding, offset, length) - remove in v0.13
  6221. } else {
  6222. throw new Error(
  6223. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6224. )
  6225. }
  6226. var remaining = this.length - offset
  6227. if (length === undefined || length > remaining) length = remaining
  6228. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6229. throw new RangeError('Attempt to write outside buffer bounds')
  6230. }
  6231. if (!encoding) encoding = 'utf8'
  6232. var loweredCase = false
  6233. for (;;) {
  6234. switch (encoding) {
  6235. case 'hex':
  6236. return hexWrite(this, string, offset, length)
  6237. case 'utf8':
  6238. case 'utf-8':
  6239. return utf8Write(this, string, offset, length)
  6240. case 'ascii':
  6241. return asciiWrite(this, string, offset, length)
  6242. case 'latin1':
  6243. case 'binary':
  6244. return latin1Write(this, string, offset, length)
  6245. case 'base64':
  6246. // Warning: maxLength not taken into account in base64Write
  6247. return base64Write(this, string, offset, length)
  6248. case 'ucs2':
  6249. case 'ucs-2':
  6250. case 'utf16le':
  6251. case 'utf-16le':
  6252. return ucs2Write(this, string, offset, length)
  6253. default:
  6254. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6255. encoding = ('' + encoding).toLowerCase()
  6256. loweredCase = true
  6257. }
  6258. }
  6259. }
  6260. Buffer.prototype.toJSON = function toJSON () {
  6261. return {
  6262. type: 'Buffer',
  6263. data: Array.prototype.slice.call(this._arr || this, 0)
  6264. }
  6265. }
  6266. function base64Slice (buf, start, end) {
  6267. if (start === 0 && end === buf.length) {
  6268. return base64.fromByteArray(buf)
  6269. } else {
  6270. return base64.fromByteArray(buf.slice(start, end))
  6271. }
  6272. }
  6273. function utf8Slice (buf, start, end) {
  6274. end = Math.min(buf.length, end)
  6275. var res = []
  6276. var i = start
  6277. while (i < end) {
  6278. var firstByte = buf[i]
  6279. var codePoint = null
  6280. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6281. : (firstByte > 0xDF) ? 3
  6282. : (firstByte > 0xBF) ? 2
  6283. : 1
  6284. if (i + bytesPerSequence <= end) {
  6285. var secondByte, thirdByte, fourthByte, tempCodePoint
  6286. switch (bytesPerSequence) {
  6287. case 1:
  6288. if (firstByte < 0x80) {
  6289. codePoint = firstByte
  6290. }
  6291. break
  6292. case 2:
  6293. secondByte = buf[i + 1]
  6294. if ((secondByte & 0xC0) === 0x80) {
  6295. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6296. if (tempCodePoint > 0x7F) {
  6297. codePoint = tempCodePoint
  6298. }
  6299. }
  6300. break
  6301. case 3:
  6302. secondByte = buf[i + 1]
  6303. thirdByte = buf[i + 2]
  6304. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6305. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6306. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6307. codePoint = tempCodePoint
  6308. }
  6309. }
  6310. break
  6311. case 4:
  6312. secondByte = buf[i + 1]
  6313. thirdByte = buf[i + 2]
  6314. fourthByte = buf[i + 3]
  6315. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6316. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6317. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6318. codePoint = tempCodePoint
  6319. }
  6320. }
  6321. }
  6322. }
  6323. if (codePoint === null) {
  6324. // we did not generate a valid codePoint so insert a
  6325. // replacement char (U+FFFD) and advance only 1 byte
  6326. codePoint = 0xFFFD
  6327. bytesPerSequence = 1
  6328. } else if (codePoint > 0xFFFF) {
  6329. // encode to utf16 (surrogate pair dance)
  6330. codePoint -= 0x10000
  6331. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6332. codePoint = 0xDC00 | codePoint & 0x3FF
  6333. }
  6334. res.push(codePoint)
  6335. i += bytesPerSequence
  6336. }
  6337. return decodeCodePointsArray(res)
  6338. }
  6339. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6340. // the lowest limit is Chrome, with 0x10000 args.
  6341. // We go 1 magnitude less, for safety
  6342. var MAX_ARGUMENTS_LENGTH = 0x1000
  6343. function decodeCodePointsArray (codePoints) {
  6344. var len = codePoints.length
  6345. if (len <= MAX_ARGUMENTS_LENGTH) {
  6346. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6347. }
  6348. // Decode in chunks to avoid "call stack size exceeded".
  6349. var res = ''
  6350. var i = 0
  6351. while (i < len) {
  6352. res += String.fromCharCode.apply(
  6353. String,
  6354. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6355. )
  6356. }
  6357. return res
  6358. }
  6359. function asciiSlice (buf, start, end) {
  6360. var ret = ''
  6361. end = Math.min(buf.length, end)
  6362. for (var i = start; i < end; ++i) {
  6363. ret += String.fromCharCode(buf[i] & 0x7F)
  6364. }
  6365. return ret
  6366. }
  6367. function latin1Slice (buf, start, end) {
  6368. var ret = ''
  6369. end = Math.min(buf.length, end)
  6370. for (var i = start; i < end; ++i) {
  6371. ret += String.fromCharCode(buf[i])
  6372. }
  6373. return ret
  6374. }
  6375. function hexSlice (buf, start, end) {
  6376. var len = buf.length
  6377. if (!start || start < 0) start = 0
  6378. if (!end || end < 0 || end > len) end = len
  6379. var out = ''
  6380. for (var i = start; i < end; ++i) {
  6381. out += toHex(buf[i])
  6382. }
  6383. return out
  6384. }
  6385. function utf16leSlice (buf, start, end) {
  6386. var bytes = buf.slice(start, end)
  6387. var res = ''
  6388. for (var i = 0; i < bytes.length; i += 2) {
  6389. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6390. }
  6391. return res
  6392. }
  6393. Buffer.prototype.slice = function slice (start, end) {
  6394. var len = this.length
  6395. start = ~~start
  6396. end = end === undefined ? len : ~~end
  6397. if (start < 0) {
  6398. start += len
  6399. if (start < 0) start = 0
  6400. } else if (start > len) {
  6401. start = len
  6402. }
  6403. if (end < 0) {
  6404. end += len
  6405. if (end < 0) end = 0
  6406. } else if (end > len) {
  6407. end = len
  6408. }
  6409. if (end < start) end = start
  6410. var newBuf
  6411. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6412. newBuf = this.subarray(start, end)
  6413. newBuf.__proto__ = Buffer.prototype
  6414. } else {
  6415. var sliceLen = end - start
  6416. newBuf = new Buffer(sliceLen, undefined)
  6417. for (var i = 0; i < sliceLen; ++i) {
  6418. newBuf[i] = this[i + start]
  6419. }
  6420. }
  6421. return newBuf
  6422. }
  6423. /*
  6424. * Need to make sure that buffer isn't trying to write out of bounds.
  6425. */
  6426. function checkOffset (offset, ext, length) {
  6427. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6428. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6429. }
  6430. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6431. offset = offset | 0
  6432. byteLength = byteLength | 0
  6433. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6434. var val = this[offset]
  6435. var mul = 1
  6436. var i = 0
  6437. while (++i < byteLength && (mul *= 0x100)) {
  6438. val += this[offset + i] * mul
  6439. }
  6440. return val
  6441. }
  6442. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6443. offset = offset | 0
  6444. byteLength = byteLength | 0
  6445. if (!noAssert) {
  6446. checkOffset(offset, byteLength, this.length)
  6447. }
  6448. var val = this[offset + --byteLength]
  6449. var mul = 1
  6450. while (byteLength > 0 && (mul *= 0x100)) {
  6451. val += this[offset + --byteLength] * mul
  6452. }
  6453. return val
  6454. }
  6455. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6456. if (!noAssert) checkOffset(offset, 1, this.length)
  6457. return this[offset]
  6458. }
  6459. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6460. if (!noAssert) checkOffset(offset, 2, this.length)
  6461. return this[offset] | (this[offset + 1] << 8)
  6462. }
  6463. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6464. if (!noAssert) checkOffset(offset, 2, this.length)
  6465. return (this[offset] << 8) | this[offset + 1]
  6466. }
  6467. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6468. if (!noAssert) checkOffset(offset, 4, this.length)
  6469. return ((this[offset]) |
  6470. (this[offset + 1] << 8) |
  6471. (this[offset + 2] << 16)) +
  6472. (this[offset + 3] * 0x1000000)
  6473. }
  6474. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6475. if (!noAssert) checkOffset(offset, 4, this.length)
  6476. return (this[offset] * 0x1000000) +
  6477. ((this[offset + 1] << 16) |
  6478. (this[offset + 2] << 8) |
  6479. this[offset + 3])
  6480. }
  6481. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6482. offset = offset | 0
  6483. byteLength = byteLength | 0
  6484. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6485. var val = this[offset]
  6486. var mul = 1
  6487. var i = 0
  6488. while (++i < byteLength && (mul *= 0x100)) {
  6489. val += this[offset + i] * mul
  6490. }
  6491. mul *= 0x80
  6492. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6493. return val
  6494. }
  6495. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6496. offset = offset | 0
  6497. byteLength = byteLength | 0
  6498. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6499. var i = byteLength
  6500. var mul = 1
  6501. var val = this[offset + --i]
  6502. while (i > 0 && (mul *= 0x100)) {
  6503. val += this[offset + --i] * mul
  6504. }
  6505. mul *= 0x80
  6506. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6507. return val
  6508. }
  6509. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6510. if (!noAssert) checkOffset(offset, 1, this.length)
  6511. if (!(this[offset] & 0x80)) return (this[offset])
  6512. return ((0xff - this[offset] + 1) * -1)
  6513. }
  6514. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6515. if (!noAssert) checkOffset(offset, 2, this.length)
  6516. var val = this[offset] | (this[offset + 1] << 8)
  6517. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6518. }
  6519. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6520. if (!noAssert) checkOffset(offset, 2, this.length)
  6521. var val = this[offset + 1] | (this[offset] << 8)
  6522. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6523. }
  6524. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6525. if (!noAssert) checkOffset(offset, 4, this.length)
  6526. return (this[offset]) |
  6527. (this[offset + 1] << 8) |
  6528. (this[offset + 2] << 16) |
  6529. (this[offset + 3] << 24)
  6530. }
  6531. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6532. if (!noAssert) checkOffset(offset, 4, this.length)
  6533. return (this[offset] << 24) |
  6534. (this[offset + 1] << 16) |
  6535. (this[offset + 2] << 8) |
  6536. (this[offset + 3])
  6537. }
  6538. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6539. if (!noAssert) checkOffset(offset, 4, this.length)
  6540. return ieee754.read(this, offset, true, 23, 4)
  6541. }
  6542. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6543. if (!noAssert) checkOffset(offset, 4, this.length)
  6544. return ieee754.read(this, offset, false, 23, 4)
  6545. }
  6546. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6547. if (!noAssert) checkOffset(offset, 8, this.length)
  6548. return ieee754.read(this, offset, true, 52, 8)
  6549. }
  6550. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6551. if (!noAssert) checkOffset(offset, 8, this.length)
  6552. return ieee754.read(this, offset, false, 52, 8)
  6553. }
  6554. function checkInt (buf, value, offset, ext, max, min) {
  6555. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6556. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6557. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6558. }
  6559. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6560. value = +value
  6561. offset = offset | 0
  6562. byteLength = byteLength | 0
  6563. if (!noAssert) {
  6564. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6565. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6566. }
  6567. var mul = 1
  6568. var i = 0
  6569. this[offset] = value & 0xFF
  6570. while (++i < byteLength && (mul *= 0x100)) {
  6571. this[offset + i] = (value / mul) & 0xFF
  6572. }
  6573. return offset + byteLength
  6574. }
  6575. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6576. value = +value
  6577. offset = offset | 0
  6578. byteLength = byteLength | 0
  6579. if (!noAssert) {
  6580. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6581. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6582. }
  6583. var i = byteLength - 1
  6584. var mul = 1
  6585. this[offset + i] = value & 0xFF
  6586. while (--i >= 0 && (mul *= 0x100)) {
  6587. this[offset + i] = (value / mul) & 0xFF
  6588. }
  6589. return offset + byteLength
  6590. }
  6591. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6592. value = +value
  6593. offset = offset | 0
  6594. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6595. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6596. this[offset] = (value & 0xff)
  6597. return offset + 1
  6598. }
  6599. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6600. if (value < 0) value = 0xffff + value + 1
  6601. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6602. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6603. (littleEndian ? i : 1 - i) * 8
  6604. }
  6605. }
  6606. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6607. value = +value
  6608. offset = offset | 0
  6609. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6610. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6611. this[offset] = (value & 0xff)
  6612. this[offset + 1] = (value >>> 8)
  6613. } else {
  6614. objectWriteUInt16(this, value, offset, true)
  6615. }
  6616. return offset + 2
  6617. }
  6618. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6619. value = +value
  6620. offset = offset | 0
  6621. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6622. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6623. this[offset] = (value >>> 8)
  6624. this[offset + 1] = (value & 0xff)
  6625. } else {
  6626. objectWriteUInt16(this, value, offset, false)
  6627. }
  6628. return offset + 2
  6629. }
  6630. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6631. if (value < 0) value = 0xffffffff + value + 1
  6632. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6633. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6634. }
  6635. }
  6636. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6637. value = +value
  6638. offset = offset | 0
  6639. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6640. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6641. this[offset + 3] = (value >>> 24)
  6642. this[offset + 2] = (value >>> 16)
  6643. this[offset + 1] = (value >>> 8)
  6644. this[offset] = (value & 0xff)
  6645. } else {
  6646. objectWriteUInt32(this, value, offset, true)
  6647. }
  6648. return offset + 4
  6649. }
  6650. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6651. value = +value
  6652. offset = offset | 0
  6653. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6654. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6655. this[offset] = (value >>> 24)
  6656. this[offset + 1] = (value >>> 16)
  6657. this[offset + 2] = (value >>> 8)
  6658. this[offset + 3] = (value & 0xff)
  6659. } else {
  6660. objectWriteUInt32(this, value, offset, false)
  6661. }
  6662. return offset + 4
  6663. }
  6664. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6665. value = +value
  6666. offset = offset | 0
  6667. if (!noAssert) {
  6668. var limit = Math.pow(2, 8 * byteLength - 1)
  6669. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6670. }
  6671. var i = 0
  6672. var mul = 1
  6673. var sub = 0
  6674. this[offset] = value & 0xFF
  6675. while (++i < byteLength && (mul *= 0x100)) {
  6676. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6677. sub = 1
  6678. }
  6679. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6680. }
  6681. return offset + byteLength
  6682. }
  6683. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6684. value = +value
  6685. offset = offset | 0
  6686. if (!noAssert) {
  6687. var limit = Math.pow(2, 8 * byteLength - 1)
  6688. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6689. }
  6690. var i = byteLength - 1
  6691. var mul = 1
  6692. var sub = 0
  6693. this[offset + i] = value & 0xFF
  6694. while (--i >= 0 && (mul *= 0x100)) {
  6695. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6696. sub = 1
  6697. }
  6698. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6699. }
  6700. return offset + byteLength
  6701. }
  6702. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6703. value = +value
  6704. offset = offset | 0
  6705. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6706. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6707. if (value < 0) value = 0xff + value + 1
  6708. this[offset] = (value & 0xff)
  6709. return offset + 1
  6710. }
  6711. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6712. value = +value
  6713. offset = offset | 0
  6714. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6715. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6716. this[offset] = (value & 0xff)
  6717. this[offset + 1] = (value >>> 8)
  6718. } else {
  6719. objectWriteUInt16(this, value, offset, true)
  6720. }
  6721. return offset + 2
  6722. }
  6723. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6724. value = +value
  6725. offset = offset | 0
  6726. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6727. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6728. this[offset] = (value >>> 8)
  6729. this[offset + 1] = (value & 0xff)
  6730. } else {
  6731. objectWriteUInt16(this, value, offset, false)
  6732. }
  6733. return offset + 2
  6734. }
  6735. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6736. value = +value
  6737. offset = offset | 0
  6738. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6739. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6740. this[offset] = (value & 0xff)
  6741. this[offset + 1] = (value >>> 8)
  6742. this[offset + 2] = (value >>> 16)
  6743. this[offset + 3] = (value >>> 24)
  6744. } else {
  6745. objectWriteUInt32(this, value, offset, true)
  6746. }
  6747. return offset + 4
  6748. }
  6749. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6750. value = +value
  6751. offset = offset | 0
  6752. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6753. if (value < 0) value = 0xffffffff + value + 1
  6754. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6755. this[offset] = (value >>> 24)
  6756. this[offset + 1] = (value >>> 16)
  6757. this[offset + 2] = (value >>> 8)
  6758. this[offset + 3] = (value & 0xff)
  6759. } else {
  6760. objectWriteUInt32(this, value, offset, false)
  6761. }
  6762. return offset + 4
  6763. }
  6764. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6765. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6766. if (offset < 0) throw new RangeError('Index out of range')
  6767. }
  6768. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6769. if (!noAssert) {
  6770. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6771. }
  6772. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6773. return offset + 4
  6774. }
  6775. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6776. return writeFloat(this, value, offset, true, noAssert)
  6777. }
  6778. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6779. return writeFloat(this, value, offset, false, noAssert)
  6780. }
  6781. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6782. if (!noAssert) {
  6783. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6784. }
  6785. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6786. return offset + 8
  6787. }
  6788. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6789. return writeDouble(this, value, offset, true, noAssert)
  6790. }
  6791. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6792. return writeDouble(this, value, offset, false, noAssert)
  6793. }
  6794. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6795. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6796. if (!start) start = 0
  6797. if (!end && end !== 0) end = this.length
  6798. if (targetStart >= target.length) targetStart = target.length
  6799. if (!targetStart) targetStart = 0
  6800. if (end > 0 && end < start) end = start
  6801. // Copy 0 bytes; we're done
  6802. if (end === start) return 0
  6803. if (target.length === 0 || this.length === 0) return 0
  6804. // Fatal error conditions
  6805. if (targetStart < 0) {
  6806. throw new RangeError('targetStart out of bounds')
  6807. }
  6808. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6809. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6810. // Are we oob?
  6811. if (end > this.length) end = this.length
  6812. if (target.length - targetStart < end - start) {
  6813. end = target.length - targetStart + start
  6814. }
  6815. var len = end - start
  6816. var i
  6817. if (this === target && start < targetStart && targetStart < end) {
  6818. // descending copy from end
  6819. for (i = len - 1; i >= 0; --i) {
  6820. target[i + targetStart] = this[i + start]
  6821. }
  6822. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6823. // ascending copy from start
  6824. for (i = 0; i < len; ++i) {
  6825. target[i + targetStart] = this[i + start]
  6826. }
  6827. } else {
  6828. Uint8Array.prototype.set.call(
  6829. target,
  6830. this.subarray(start, start + len),
  6831. targetStart
  6832. )
  6833. }
  6834. return len
  6835. }
  6836. // Usage:
  6837. // buffer.fill(number[, offset[, end]])
  6838. // buffer.fill(buffer[, offset[, end]])
  6839. // buffer.fill(string[, offset[, end]][, encoding])
  6840. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6841. // Handle string cases:
  6842. if (typeof val === 'string') {
  6843. if (typeof start === 'string') {
  6844. encoding = start
  6845. start = 0
  6846. end = this.length
  6847. } else if (typeof end === 'string') {
  6848. encoding = end
  6849. end = this.length
  6850. }
  6851. if (val.length === 1) {
  6852. var code = val.charCodeAt(0)
  6853. if (code < 256) {
  6854. val = code
  6855. }
  6856. }
  6857. if (encoding !== undefined && typeof encoding !== 'string') {
  6858. throw new TypeError('encoding must be a string')
  6859. }
  6860. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6861. throw new TypeError('Unknown encoding: ' + encoding)
  6862. }
  6863. } else if (typeof val === 'number') {
  6864. val = val & 255
  6865. }
  6866. // Invalid ranges are not set to a default, so can range check early.
  6867. if (start < 0 || this.length < start || this.length < end) {
  6868. throw new RangeError('Out of range index')
  6869. }
  6870. if (end <= start) {
  6871. return this
  6872. }
  6873. start = start >>> 0
  6874. end = end === undefined ? this.length : end >>> 0
  6875. if (!val) val = 0
  6876. var i
  6877. if (typeof val === 'number') {
  6878. for (i = start; i < end; ++i) {
  6879. this[i] = val
  6880. }
  6881. } else {
  6882. var bytes = Buffer.isBuffer(val)
  6883. ? val
  6884. : utf8ToBytes(new Buffer(val, encoding).toString())
  6885. var len = bytes.length
  6886. for (i = 0; i < end - start; ++i) {
  6887. this[i + start] = bytes[i % len]
  6888. }
  6889. }
  6890. return this
  6891. }
  6892. // HELPER FUNCTIONS
  6893. // ================
  6894. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6895. function base64clean (str) {
  6896. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6897. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6898. // Node converts strings with length < 2 to ''
  6899. if (str.length < 2) return ''
  6900. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6901. while (str.length % 4 !== 0) {
  6902. str = str + '='
  6903. }
  6904. return str
  6905. }
  6906. function stringtrim (str) {
  6907. if (str.trim) return str.trim()
  6908. return str.replace(/^\s+|\s+$/g, '')
  6909. }
  6910. function toHex (n) {
  6911. if (n < 16) return '0' + n.toString(16)
  6912. return n.toString(16)
  6913. }
  6914. function utf8ToBytes (string, units) {
  6915. units = units || Infinity
  6916. var codePoint
  6917. var length = string.length
  6918. var leadSurrogate = null
  6919. var bytes = []
  6920. for (var i = 0; i < length; ++i) {
  6921. codePoint = string.charCodeAt(i)
  6922. // is surrogate component
  6923. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6924. // last char was a lead
  6925. if (!leadSurrogate) {
  6926. // no lead yet
  6927. if (codePoint > 0xDBFF) {
  6928. // unexpected trail
  6929. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6930. continue
  6931. } else if (i + 1 === length) {
  6932. // unpaired lead
  6933. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6934. continue
  6935. }
  6936. // valid lead
  6937. leadSurrogate = codePoint
  6938. continue
  6939. }
  6940. // 2 leads in a row
  6941. if (codePoint < 0xDC00) {
  6942. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6943. leadSurrogate = codePoint
  6944. continue
  6945. }
  6946. // valid surrogate pair
  6947. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6948. } else if (leadSurrogate) {
  6949. // valid bmp char, but last char was a lead
  6950. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6951. }
  6952. leadSurrogate = null
  6953. // encode utf8
  6954. if (codePoint < 0x80) {
  6955. if ((units -= 1) < 0) break
  6956. bytes.push(codePoint)
  6957. } else if (codePoint < 0x800) {
  6958. if ((units -= 2) < 0) break
  6959. bytes.push(
  6960. codePoint >> 0x6 | 0xC0,
  6961. codePoint & 0x3F | 0x80
  6962. )
  6963. } else if (codePoint < 0x10000) {
  6964. if ((units -= 3) < 0) break
  6965. bytes.push(
  6966. codePoint >> 0xC | 0xE0,
  6967. codePoint >> 0x6 & 0x3F | 0x80,
  6968. codePoint & 0x3F | 0x80
  6969. )
  6970. } else if (codePoint < 0x110000) {
  6971. if ((units -= 4) < 0) break
  6972. bytes.push(
  6973. codePoint >> 0x12 | 0xF0,
  6974. codePoint >> 0xC & 0x3F | 0x80,
  6975. codePoint >> 0x6 & 0x3F | 0x80,
  6976. codePoint & 0x3F | 0x80
  6977. )
  6978. } else {
  6979. throw new Error('Invalid code point')
  6980. }
  6981. }
  6982. return bytes
  6983. }
  6984. function asciiToBytes (str) {
  6985. var byteArray = []
  6986. for (var i = 0; i < str.length; ++i) {
  6987. // Node's code seems to be doing this and not & 0x7F..
  6988. byteArray.push(str.charCodeAt(i) & 0xFF)
  6989. }
  6990. return byteArray
  6991. }
  6992. function utf16leToBytes (str, units) {
  6993. var c, hi, lo
  6994. var byteArray = []
  6995. for (var i = 0; i < str.length; ++i) {
  6996. if ((units -= 2) < 0) break
  6997. c = str.charCodeAt(i)
  6998. hi = c >> 8
  6999. lo = c % 256
  7000. byteArray.push(lo)
  7001. byteArray.push(hi)
  7002. }
  7003. return byteArray
  7004. }
  7005. function base64ToBytes (str) {
  7006. return base64.toByteArray(base64clean(str))
  7007. }
  7008. function blitBuffer (src, dst, offset, length) {
  7009. for (var i = 0; i < length; ++i) {
  7010. if ((i + offset >= dst.length) || (i >= src.length)) break
  7011. dst[i + offset] = src[i]
  7012. }
  7013. return i
  7014. }
  7015. function isnan (val) {
  7016. return val !== val // eslint-disable-line no-self-compare
  7017. }
  7018. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7019. /***/ }),
  7020. /***/ "./node_modules/ieee754/index.js":
  7021. /*!***************************************!*\
  7022. !*** ./node_modules/ieee754/index.js ***!
  7023. \***************************************/
  7024. /*! no static exports found */
  7025. /***/ (function(module, exports) {
  7026. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7027. var e, m
  7028. var eLen = (nBytes * 8) - mLen - 1
  7029. var eMax = (1 << eLen) - 1
  7030. var eBias = eMax >> 1
  7031. var nBits = -7
  7032. var i = isLE ? (nBytes - 1) : 0
  7033. var d = isLE ? -1 : 1
  7034. var s = buffer[offset + i]
  7035. i += d
  7036. e = s & ((1 << (-nBits)) - 1)
  7037. s >>= (-nBits)
  7038. nBits += eLen
  7039. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7040. m = e & ((1 << (-nBits)) - 1)
  7041. e >>= (-nBits)
  7042. nBits += mLen
  7043. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7044. if (e === 0) {
  7045. e = 1 - eBias
  7046. } else if (e === eMax) {
  7047. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7048. } else {
  7049. m = m + Math.pow(2, mLen)
  7050. e = e - eBias
  7051. }
  7052. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7053. }
  7054. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7055. var e, m, c
  7056. var eLen = (nBytes * 8) - mLen - 1
  7057. var eMax = (1 << eLen) - 1
  7058. var eBias = eMax >> 1
  7059. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7060. var i = isLE ? 0 : (nBytes - 1)
  7061. var d = isLE ? 1 : -1
  7062. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7063. value = Math.abs(value)
  7064. if (isNaN(value) || value === Infinity) {
  7065. m = isNaN(value) ? 1 : 0
  7066. e = eMax
  7067. } else {
  7068. e = Math.floor(Math.log(value) / Math.LN2)
  7069. if (value * (c = Math.pow(2, -e)) < 1) {
  7070. e--
  7071. c *= 2
  7072. }
  7073. if (e + eBias >= 1) {
  7074. value += rt / c
  7075. } else {
  7076. value += rt * Math.pow(2, 1 - eBias)
  7077. }
  7078. if (value * c >= 2) {
  7079. e++
  7080. c /= 2
  7081. }
  7082. if (e + eBias >= eMax) {
  7083. m = 0
  7084. e = eMax
  7085. } else if (e + eBias >= 1) {
  7086. m = ((value * c) - 1) * Math.pow(2, mLen)
  7087. e = e + eBias
  7088. } else {
  7089. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7090. e = 0
  7091. }
  7092. }
  7093. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7094. e = (e << mLen) | m
  7095. eLen += mLen
  7096. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7097. buffer[offset + i - d] |= s * 128
  7098. }
  7099. /***/ }),
  7100. /***/ "./node_modules/isarray/index.js":
  7101. /*!***************************************!*\
  7102. !*** ./node_modules/isarray/index.js ***!
  7103. \***************************************/
  7104. /*! no static exports found */
  7105. /***/ (function(module, exports) {
  7106. var toString = {}.toString;
  7107. module.exports = Array.isArray || function (arr) {
  7108. return toString.call(arr) == '[object Array]';
  7109. };
  7110. /***/ }),
  7111. /***/ "./node_modules/jquery/dist/jquery.js":
  7112. /*!********************************************!*\
  7113. !*** ./node_modules/jquery/dist/jquery.js ***!
  7114. \********************************************/
  7115. /*! no static exports found */
  7116. /***/ (function(module, exports, __webpack_require__) {
  7117. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7118. * jQuery JavaScript Library v3.4.1
  7119. * https://jquery.com/
  7120. *
  7121. * Includes Sizzle.js
  7122. * https://sizzlejs.com/
  7123. *
  7124. * Copyright JS Foundation and other contributors
  7125. * Released under the MIT license
  7126. * https://jquery.org/license
  7127. *
  7128. * Date: 2019-05-01T21:04Z
  7129. */
  7130. ( function( global, factory ) {
  7131. "use strict";
  7132. if ( true && typeof module.exports === "object" ) {
  7133. // For CommonJS and CommonJS-like environments where a proper `window`
  7134. // is present, execute the factory and get jQuery.
  7135. // For environments that do not have a `window` with a `document`
  7136. // (such as Node.js), expose a factory as module.exports.
  7137. // This accentuates the need for the creation of a real `window`.
  7138. // e.g. var jQuery = require("jquery")(window);
  7139. // See ticket #14549 for more info.
  7140. module.exports = global.document ?
  7141. factory( global, true ) :
  7142. function( w ) {
  7143. if ( !w.document ) {
  7144. throw new Error( "jQuery requires a window with a document" );
  7145. }
  7146. return factory( w );
  7147. };
  7148. } else {
  7149. factory( global );
  7150. }
  7151. // Pass this if window is not defined yet
  7152. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7153. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7154. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7155. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7156. // enough that all such attempts are guarded in a try block.
  7157. "use strict";
  7158. var arr = [];
  7159. var document = window.document;
  7160. var getProto = Object.getPrototypeOf;
  7161. var slice = arr.slice;
  7162. var concat = arr.concat;
  7163. var push = arr.push;
  7164. var indexOf = arr.indexOf;
  7165. var class2type = {};
  7166. var toString = class2type.toString;
  7167. var hasOwn = class2type.hasOwnProperty;
  7168. var fnToString = hasOwn.toString;
  7169. var ObjectFunctionString = fnToString.call( Object );
  7170. var support = {};
  7171. var isFunction = function isFunction( obj ) {
  7172. // Support: Chrome <=57, Firefox <=52
  7173. // In some browsers, typeof returns "function" for HTML <object> elements
  7174. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7175. // We don't want to classify *any* DOM node as a function.
  7176. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7177. };
  7178. var isWindow = function isWindow( obj ) {
  7179. return obj != null && obj === obj.window;
  7180. };
  7181. var preservedScriptAttributes = {
  7182. type: true,
  7183. src: true,
  7184. nonce: true,
  7185. noModule: true
  7186. };
  7187. function DOMEval( code, node, doc ) {
  7188. doc = doc || document;
  7189. var i, val,
  7190. script = doc.createElement( "script" );
  7191. script.text = code;
  7192. if ( node ) {
  7193. for ( i in preservedScriptAttributes ) {
  7194. // Support: Firefox 64+, Edge 18+
  7195. // Some browsers don't support the "nonce" property on scripts.
  7196. // On the other hand, just using `getAttribute` is not enough as
  7197. // the `nonce` attribute is reset to an empty string whenever it
  7198. // becomes browsing-context connected.
  7199. // See https://github.com/whatwg/html/issues/2369
  7200. // See https://html.spec.whatwg.org/#nonce-attributes
  7201. // The `node.getAttribute` check was added for the sake of
  7202. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7203. // via an object.
  7204. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7205. if ( val ) {
  7206. script.setAttribute( i, val );
  7207. }
  7208. }
  7209. }
  7210. doc.head.appendChild( script ).parentNode.removeChild( script );
  7211. }
  7212. function toType( obj ) {
  7213. if ( obj == null ) {
  7214. return obj + "";
  7215. }
  7216. // Support: Android <=2.3 only (functionish RegExp)
  7217. return typeof obj === "object" || typeof obj === "function" ?
  7218. class2type[ toString.call( obj ) ] || "object" :
  7219. typeof obj;
  7220. }
  7221. /* global Symbol */
  7222. // Defining this global in .eslintrc.json would create a danger of using the global
  7223. // unguarded in another place, it seems safer to define global only for this module
  7224. var
  7225. version = "3.4.1",
  7226. // Define a local copy of jQuery
  7227. jQuery = function( selector, context ) {
  7228. // The jQuery object is actually just the init constructor 'enhanced'
  7229. // Need init if jQuery is called (just allow error to be thrown if not included)
  7230. return new jQuery.fn.init( selector, context );
  7231. },
  7232. // Support: Android <=4.0 only
  7233. // Make sure we trim BOM and NBSP
  7234. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7235. jQuery.fn = jQuery.prototype = {
  7236. // The current version of jQuery being used
  7237. jquery: version,
  7238. constructor: jQuery,
  7239. // The default length of a jQuery object is 0
  7240. length: 0,
  7241. toArray: function() {
  7242. return slice.call( this );
  7243. },
  7244. // Get the Nth element in the matched element set OR
  7245. // Get the whole matched element set as a clean array
  7246. get: function( num ) {
  7247. // Return all the elements in a clean array
  7248. if ( num == null ) {
  7249. return slice.call( this );
  7250. }
  7251. // Return just the one element from the set
  7252. return num < 0 ? this[ num + this.length ] : this[ num ];
  7253. },
  7254. // Take an array of elements and push it onto the stack
  7255. // (returning the new matched element set)
  7256. pushStack: function( elems ) {
  7257. // Build a new jQuery matched element set
  7258. var ret = jQuery.merge( this.constructor(), elems );
  7259. // Add the old object onto the stack (as a reference)
  7260. ret.prevObject = this;
  7261. // Return the newly-formed element set
  7262. return ret;
  7263. },
  7264. // Execute a callback for every element in the matched set.
  7265. each: function( callback ) {
  7266. return jQuery.each( this, callback );
  7267. },
  7268. map: function( callback ) {
  7269. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7270. return callback.call( elem, i, elem );
  7271. } ) );
  7272. },
  7273. slice: function() {
  7274. return this.pushStack( slice.apply( this, arguments ) );
  7275. },
  7276. first: function() {
  7277. return this.eq( 0 );
  7278. },
  7279. last: function() {
  7280. return this.eq( -1 );
  7281. },
  7282. eq: function( i ) {
  7283. var len = this.length,
  7284. j = +i + ( i < 0 ? len : 0 );
  7285. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7286. },
  7287. end: function() {
  7288. return this.prevObject || this.constructor();
  7289. },
  7290. // For internal use only.
  7291. // Behaves like an Array's method, not like a jQuery method.
  7292. push: push,
  7293. sort: arr.sort,
  7294. splice: arr.splice
  7295. };
  7296. jQuery.extend = jQuery.fn.extend = function() {
  7297. var options, name, src, copy, copyIsArray, clone,
  7298. target = arguments[ 0 ] || {},
  7299. i = 1,
  7300. length = arguments.length,
  7301. deep = false;
  7302. // Handle a deep copy situation
  7303. if ( typeof target === "boolean" ) {
  7304. deep = target;
  7305. // Skip the boolean and the target
  7306. target = arguments[ i ] || {};
  7307. i++;
  7308. }
  7309. // Handle case when target is a string or something (possible in deep copy)
  7310. if ( typeof target !== "object" && !isFunction( target ) ) {
  7311. target = {};
  7312. }
  7313. // Extend jQuery itself if only one argument is passed
  7314. if ( i === length ) {
  7315. target = this;
  7316. i--;
  7317. }
  7318. for ( ; i < length; i++ ) {
  7319. // Only deal with non-null/undefined values
  7320. if ( ( options = arguments[ i ] ) != null ) {
  7321. // Extend the base object
  7322. for ( name in options ) {
  7323. copy = options[ name ];
  7324. // Prevent Object.prototype pollution
  7325. // Prevent never-ending loop
  7326. if ( name === "__proto__" || target === copy ) {
  7327. continue;
  7328. }
  7329. // Recurse if we're merging plain objects or arrays
  7330. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7331. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7332. src = target[ name ];
  7333. // Ensure proper type for the source value
  7334. if ( copyIsArray && !Array.isArray( src ) ) {
  7335. clone = [];
  7336. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7337. clone = {};
  7338. } else {
  7339. clone = src;
  7340. }
  7341. copyIsArray = false;
  7342. // Never move original objects, clone them
  7343. target[ name ] = jQuery.extend( deep, clone, copy );
  7344. // Don't bring in undefined values
  7345. } else if ( copy !== undefined ) {
  7346. target[ name ] = copy;
  7347. }
  7348. }
  7349. }
  7350. }
  7351. // Return the modified object
  7352. return target;
  7353. };
  7354. jQuery.extend( {
  7355. // Unique for each copy of jQuery on the page
  7356. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7357. // Assume jQuery is ready without the ready module
  7358. isReady: true,
  7359. error: function( msg ) {
  7360. throw new Error( msg );
  7361. },
  7362. noop: function() {},
  7363. isPlainObject: function( obj ) {
  7364. var proto, Ctor;
  7365. // Detect obvious negatives
  7366. // Use toString instead of jQuery.type to catch host objects
  7367. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7368. return false;
  7369. }
  7370. proto = getProto( obj );
  7371. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7372. if ( !proto ) {
  7373. return true;
  7374. }
  7375. // Objects with prototype are plain iff they were constructed by a global Object function
  7376. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7377. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7378. },
  7379. isEmptyObject: function( obj ) {
  7380. var name;
  7381. for ( name in obj ) {
  7382. return false;
  7383. }
  7384. return true;
  7385. },
  7386. // Evaluates a script in a global context
  7387. globalEval: function( code, options ) {
  7388. DOMEval( code, { nonce: options && options.nonce } );
  7389. },
  7390. each: function( obj, callback ) {
  7391. var length, i = 0;
  7392. if ( isArrayLike( obj ) ) {
  7393. length = obj.length;
  7394. for ( ; i < length; i++ ) {
  7395. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7396. break;
  7397. }
  7398. }
  7399. } else {
  7400. for ( i in obj ) {
  7401. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7402. break;
  7403. }
  7404. }
  7405. }
  7406. return obj;
  7407. },
  7408. // Support: Android <=4.0 only
  7409. trim: function( text ) {
  7410. return text == null ?
  7411. "" :
  7412. ( text + "" ).replace( rtrim, "" );
  7413. },
  7414. // results is for internal usage only
  7415. makeArray: function( arr, results ) {
  7416. var ret = results || [];
  7417. if ( arr != null ) {
  7418. if ( isArrayLike( Object( arr ) ) ) {
  7419. jQuery.merge( ret,
  7420. typeof arr === "string" ?
  7421. [ arr ] : arr
  7422. );
  7423. } else {
  7424. push.call( ret, arr );
  7425. }
  7426. }
  7427. return ret;
  7428. },
  7429. inArray: function( elem, arr, i ) {
  7430. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7431. },
  7432. // Support: Android <=4.0 only, PhantomJS 1 only
  7433. // push.apply(_, arraylike) throws on ancient WebKit
  7434. merge: function( first, second ) {
  7435. var len = +second.length,
  7436. j = 0,
  7437. i = first.length;
  7438. for ( ; j < len; j++ ) {
  7439. first[ i++ ] = second[ j ];
  7440. }
  7441. first.length = i;
  7442. return first;
  7443. },
  7444. grep: function( elems, callback, invert ) {
  7445. var callbackInverse,
  7446. matches = [],
  7447. i = 0,
  7448. length = elems.length,
  7449. callbackExpect = !invert;
  7450. // Go through the array, only saving the items
  7451. // that pass the validator function
  7452. for ( ; i < length; i++ ) {
  7453. callbackInverse = !callback( elems[ i ], i );
  7454. if ( callbackInverse !== callbackExpect ) {
  7455. matches.push( elems[ i ] );
  7456. }
  7457. }
  7458. return matches;
  7459. },
  7460. // arg is for internal usage only
  7461. map: function( elems, callback, arg ) {
  7462. var length, value,
  7463. i = 0,
  7464. ret = [];
  7465. // Go through the array, translating each of the items to their new values
  7466. if ( isArrayLike( elems ) ) {
  7467. length = elems.length;
  7468. for ( ; i < length; i++ ) {
  7469. value = callback( elems[ i ], i, arg );
  7470. if ( value != null ) {
  7471. ret.push( value );
  7472. }
  7473. }
  7474. // Go through every key on the object,
  7475. } else {
  7476. for ( i in elems ) {
  7477. value = callback( elems[ i ], i, arg );
  7478. if ( value != null ) {
  7479. ret.push( value );
  7480. }
  7481. }
  7482. }
  7483. // Flatten any nested arrays
  7484. return concat.apply( [], ret );
  7485. },
  7486. // A global GUID counter for objects
  7487. guid: 1,
  7488. // jQuery.support is not used in Core but other projects attach their
  7489. // properties to it so it needs to exist.
  7490. support: support
  7491. } );
  7492. if ( typeof Symbol === "function" ) {
  7493. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7494. }
  7495. // Populate the class2type map
  7496. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7497. function( i, name ) {
  7498. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7499. } );
  7500. function isArrayLike( obj ) {
  7501. // Support: real iOS 8.2 only (not reproducible in simulator)
  7502. // `in` check used to prevent JIT error (gh-2145)
  7503. // hasOwn isn't used here due to false negatives
  7504. // regarding Nodelist length in IE
  7505. var length = !!obj && "length" in obj && obj.length,
  7506. type = toType( obj );
  7507. if ( isFunction( obj ) || isWindow( obj ) ) {
  7508. return false;
  7509. }
  7510. return type === "array" || length === 0 ||
  7511. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7512. }
  7513. var Sizzle =
  7514. /*!
  7515. * Sizzle CSS Selector Engine v2.3.4
  7516. * https://sizzlejs.com/
  7517. *
  7518. * Copyright JS Foundation and other contributors
  7519. * Released under the MIT license
  7520. * https://js.foundation/
  7521. *
  7522. * Date: 2019-04-08
  7523. */
  7524. (function( window ) {
  7525. var i,
  7526. support,
  7527. Expr,
  7528. getText,
  7529. isXML,
  7530. tokenize,
  7531. compile,
  7532. select,
  7533. outermostContext,
  7534. sortInput,
  7535. hasDuplicate,
  7536. // Local document vars
  7537. setDocument,
  7538. document,
  7539. docElem,
  7540. documentIsHTML,
  7541. rbuggyQSA,
  7542. rbuggyMatches,
  7543. matches,
  7544. contains,
  7545. // Instance-specific data
  7546. expando = "sizzle" + 1 * new Date(),
  7547. preferredDoc = window.document,
  7548. dirruns = 0,
  7549. done = 0,
  7550. classCache = createCache(),
  7551. tokenCache = createCache(),
  7552. compilerCache = createCache(),
  7553. nonnativeSelectorCache = createCache(),
  7554. sortOrder = function( a, b ) {
  7555. if ( a === b ) {
  7556. hasDuplicate = true;
  7557. }
  7558. return 0;
  7559. },
  7560. // Instance methods
  7561. hasOwn = ({}).hasOwnProperty,
  7562. arr = [],
  7563. pop = arr.pop,
  7564. push_native = arr.push,
  7565. push = arr.push,
  7566. slice = arr.slice,
  7567. // Use a stripped-down indexOf as it's faster than native
  7568. // https://jsperf.com/thor-indexof-vs-for/5
  7569. indexOf = function( list, elem ) {
  7570. var i = 0,
  7571. len = list.length;
  7572. for ( ; i < len; i++ ) {
  7573. if ( list[i] === elem ) {
  7574. return i;
  7575. }
  7576. }
  7577. return -1;
  7578. },
  7579. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7580. // Regular expressions
  7581. // http://www.w3.org/TR/css3-selectors/#whitespace
  7582. whitespace = "[\\x20\\t\\r\\n\\f]",
  7583. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7584. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7585. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7586. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7587. // Operator (capture 2)
  7588. "*([*^$|!~]?=)" + whitespace +
  7589. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7590. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7591. "*\\]",
  7592. pseudos = ":(" + identifier + ")(?:\\((" +
  7593. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7594. // 1. quoted (capture 3; capture 4 or capture 5)
  7595. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7596. // 2. simple (capture 6)
  7597. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7598. // 3. anything else (capture 2)
  7599. ".*" +
  7600. ")\\)|)",
  7601. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7602. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7603. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7604. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7605. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7606. rdescend = new RegExp( whitespace + "|>" ),
  7607. rpseudo = new RegExp( pseudos ),
  7608. ridentifier = new RegExp( "^" + identifier + "$" ),
  7609. matchExpr = {
  7610. "ID": new RegExp( "^#(" + identifier + ")" ),
  7611. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7612. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7613. "ATTR": new RegExp( "^" + attributes ),
  7614. "PSEUDO": new RegExp( "^" + pseudos ),
  7615. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7616. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7617. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7618. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7619. // For use in libraries implementing .is()
  7620. // We use this for POS matching in `select`
  7621. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7622. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7623. },
  7624. rhtml = /HTML$/i,
  7625. rinputs = /^(?:input|select|textarea|button)$/i,
  7626. rheader = /^h\d$/i,
  7627. rnative = /^[^{]+\{\s*\[native \w/,
  7628. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7629. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7630. rsibling = /[+~]/,
  7631. // CSS escapes
  7632. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7633. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7634. funescape = function( _, escaped, escapedWhitespace ) {
  7635. var high = "0x" + escaped - 0x10000;
  7636. // NaN means non-codepoint
  7637. // Support: Firefox<24
  7638. // Workaround erroneous numeric interpretation of +"0x"
  7639. return high !== high || escapedWhitespace ?
  7640. escaped :
  7641. high < 0 ?
  7642. // BMP codepoint
  7643. String.fromCharCode( high + 0x10000 ) :
  7644. // Supplemental Plane codepoint (surrogate pair)
  7645. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7646. },
  7647. // CSS string/identifier serialization
  7648. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7649. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7650. fcssescape = function( ch, asCodePoint ) {
  7651. if ( asCodePoint ) {
  7652. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7653. if ( ch === "\0" ) {
  7654. return "\uFFFD";
  7655. }
  7656. // Control characters and (dependent upon position) numbers get escaped as code points
  7657. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7658. }
  7659. // Other potentially-special ASCII characters get backslash-escaped
  7660. return "\\" + ch;
  7661. },
  7662. // Used for iframes
  7663. // See setDocument()
  7664. // Removing the function wrapper causes a "Permission Denied"
  7665. // error in IE
  7666. unloadHandler = function() {
  7667. setDocument();
  7668. },
  7669. inDisabledFieldset = addCombinator(
  7670. function( elem ) {
  7671. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7672. },
  7673. { dir: "parentNode", next: "legend" }
  7674. );
  7675. // Optimize for push.apply( _, NodeList )
  7676. try {
  7677. push.apply(
  7678. (arr = slice.call( preferredDoc.childNodes )),
  7679. preferredDoc.childNodes
  7680. );
  7681. // Support: Android<4.0
  7682. // Detect silently failing push.apply
  7683. arr[ preferredDoc.childNodes.length ].nodeType;
  7684. } catch ( e ) {
  7685. push = { apply: arr.length ?
  7686. // Leverage slice if possible
  7687. function( target, els ) {
  7688. push_native.apply( target, slice.call(els) );
  7689. } :
  7690. // Support: IE<9
  7691. // Otherwise append directly
  7692. function( target, els ) {
  7693. var j = target.length,
  7694. i = 0;
  7695. // Can't trust NodeList.length
  7696. while ( (target[j++] = els[i++]) ) {}
  7697. target.length = j - 1;
  7698. }
  7699. };
  7700. }
  7701. function Sizzle( selector, context, results, seed ) {
  7702. var m, i, elem, nid, match, groups, newSelector,
  7703. newContext = context && context.ownerDocument,
  7704. // nodeType defaults to 9, since context defaults to document
  7705. nodeType = context ? context.nodeType : 9;
  7706. results = results || [];
  7707. // Return early from calls with invalid selector or context
  7708. if ( typeof selector !== "string" || !selector ||
  7709. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7710. return results;
  7711. }
  7712. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7713. if ( !seed ) {
  7714. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7715. setDocument( context );
  7716. }
  7717. context = context || document;
  7718. if ( documentIsHTML ) {
  7719. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7720. // (excepting DocumentFragment context, where the methods don't exist)
  7721. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7722. // ID selector
  7723. if ( (m = match[1]) ) {
  7724. // Document context
  7725. if ( nodeType === 9 ) {
  7726. if ( (elem = context.getElementById( m )) ) {
  7727. // Support: IE, Opera, Webkit
  7728. // TODO: identify versions
  7729. // getElementById can match elements by name instead of ID
  7730. if ( elem.id === m ) {
  7731. results.push( elem );
  7732. return results;
  7733. }
  7734. } else {
  7735. return results;
  7736. }
  7737. // Element context
  7738. } else {
  7739. // Support: IE, Opera, Webkit
  7740. // TODO: identify versions
  7741. // getElementById can match elements by name instead of ID
  7742. if ( newContext && (elem = newContext.getElementById( m )) &&
  7743. contains( context, elem ) &&
  7744. elem.id === m ) {
  7745. results.push( elem );
  7746. return results;
  7747. }
  7748. }
  7749. // Type selector
  7750. } else if ( match[2] ) {
  7751. push.apply( results, context.getElementsByTagName( selector ) );
  7752. return results;
  7753. // Class selector
  7754. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7755. context.getElementsByClassName ) {
  7756. push.apply( results, context.getElementsByClassName( m ) );
  7757. return results;
  7758. }
  7759. }
  7760. // Take advantage of querySelectorAll
  7761. if ( support.qsa &&
  7762. !nonnativeSelectorCache[ selector + " " ] &&
  7763. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7764. // Support: IE 8 only
  7765. // Exclude object elements
  7766. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7767. newSelector = selector;
  7768. newContext = context;
  7769. // qSA considers elements outside a scoping root when evaluating child or
  7770. // descendant combinators, which is not what we want.
  7771. // In such cases, we work around the behavior by prefixing every selector in the
  7772. // list with an ID selector referencing the scope context.
  7773. // Thanks to Andrew Dupont for this technique.
  7774. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7775. // Capture the context ID, setting it first if necessary
  7776. if ( (nid = context.getAttribute( "id" )) ) {
  7777. nid = nid.replace( rcssescape, fcssescape );
  7778. } else {
  7779. context.setAttribute( "id", (nid = expando) );
  7780. }
  7781. // Prefix every selector in the list
  7782. groups = tokenize( selector );
  7783. i = groups.length;
  7784. while ( i-- ) {
  7785. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7786. }
  7787. newSelector = groups.join( "," );
  7788. // Expand context for sibling selectors
  7789. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7790. context;
  7791. }
  7792. try {
  7793. push.apply( results,
  7794. newContext.querySelectorAll( newSelector )
  7795. );
  7796. return results;
  7797. } catch ( qsaError ) {
  7798. nonnativeSelectorCache( selector, true );
  7799. } finally {
  7800. if ( nid === expando ) {
  7801. context.removeAttribute( "id" );
  7802. }
  7803. }
  7804. }
  7805. }
  7806. }
  7807. // All others
  7808. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7809. }
  7810. /**
  7811. * Create key-value caches of limited size
  7812. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7813. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7814. * deleting the oldest entry
  7815. */
  7816. function createCache() {
  7817. var keys = [];
  7818. function cache( key, value ) {
  7819. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7820. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7821. // Only keep the most recent entries
  7822. delete cache[ keys.shift() ];
  7823. }
  7824. return (cache[ key + " " ] = value);
  7825. }
  7826. return cache;
  7827. }
  7828. /**
  7829. * Mark a function for special use by Sizzle
  7830. * @param {Function} fn The function to mark
  7831. */
  7832. function markFunction( fn ) {
  7833. fn[ expando ] = true;
  7834. return fn;
  7835. }
  7836. /**
  7837. * Support testing using an element
  7838. * @param {Function} fn Passed the created element and returns a boolean result
  7839. */
  7840. function assert( fn ) {
  7841. var el = document.createElement("fieldset");
  7842. try {
  7843. return !!fn( el );
  7844. } catch (e) {
  7845. return false;
  7846. } finally {
  7847. // Remove from its parent by default
  7848. if ( el.parentNode ) {
  7849. el.parentNode.removeChild( el );
  7850. }
  7851. // release memory in IE
  7852. el = null;
  7853. }
  7854. }
  7855. /**
  7856. * Adds the same handler for all of the specified attrs
  7857. * @param {String} attrs Pipe-separated list of attributes
  7858. * @param {Function} handler The method that will be applied
  7859. */
  7860. function addHandle( attrs, handler ) {
  7861. var arr = attrs.split("|"),
  7862. i = arr.length;
  7863. while ( i-- ) {
  7864. Expr.attrHandle[ arr[i] ] = handler;
  7865. }
  7866. }
  7867. /**
  7868. * Checks document order of two siblings
  7869. * @param {Element} a
  7870. * @param {Element} b
  7871. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7872. */
  7873. function siblingCheck( a, b ) {
  7874. var cur = b && a,
  7875. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7876. a.sourceIndex - b.sourceIndex;
  7877. // Use IE sourceIndex if available on both nodes
  7878. if ( diff ) {
  7879. return diff;
  7880. }
  7881. // Check if b follows a
  7882. if ( cur ) {
  7883. while ( (cur = cur.nextSibling) ) {
  7884. if ( cur === b ) {
  7885. return -1;
  7886. }
  7887. }
  7888. }
  7889. return a ? 1 : -1;
  7890. }
  7891. /**
  7892. * Returns a function to use in pseudos for input types
  7893. * @param {String} type
  7894. */
  7895. function createInputPseudo( type ) {
  7896. return function( elem ) {
  7897. var name = elem.nodeName.toLowerCase();
  7898. return name === "input" && elem.type === type;
  7899. };
  7900. }
  7901. /**
  7902. * Returns a function to use in pseudos for buttons
  7903. * @param {String} type
  7904. */
  7905. function createButtonPseudo( type ) {
  7906. return function( elem ) {
  7907. var name = elem.nodeName.toLowerCase();
  7908. return (name === "input" || name === "button") && elem.type === type;
  7909. };
  7910. }
  7911. /**
  7912. * Returns a function to use in pseudos for :enabled/:disabled
  7913. * @param {Boolean} disabled true for :disabled; false for :enabled
  7914. */
  7915. function createDisabledPseudo( disabled ) {
  7916. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7917. return function( elem ) {
  7918. // Only certain elements can match :enabled or :disabled
  7919. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7920. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7921. if ( "form" in elem ) {
  7922. // Check for inherited disabledness on relevant non-disabled elements:
  7923. // * listed form-associated elements in a disabled fieldset
  7924. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7925. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7926. // * option elements in a disabled optgroup
  7927. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7928. // All such elements have a "form" property.
  7929. if ( elem.parentNode && elem.disabled === false ) {
  7930. // Option elements defer to a parent optgroup if present
  7931. if ( "label" in elem ) {
  7932. if ( "label" in elem.parentNode ) {
  7933. return elem.parentNode.disabled === disabled;
  7934. } else {
  7935. return elem.disabled === disabled;
  7936. }
  7937. }
  7938. // Support: IE 6 - 11
  7939. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7940. return elem.isDisabled === disabled ||
  7941. // Where there is no isDisabled, check manually
  7942. /* jshint -W018 */
  7943. elem.isDisabled !== !disabled &&
  7944. inDisabledFieldset( elem ) === disabled;
  7945. }
  7946. return elem.disabled === disabled;
  7947. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7948. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7949. // even exist on them, let alone have a boolean value.
  7950. } else if ( "label" in elem ) {
  7951. return elem.disabled === disabled;
  7952. }
  7953. // Remaining elements are neither :enabled nor :disabled
  7954. return false;
  7955. };
  7956. }
  7957. /**
  7958. * Returns a function to use in pseudos for positionals
  7959. * @param {Function} fn
  7960. */
  7961. function createPositionalPseudo( fn ) {
  7962. return markFunction(function( argument ) {
  7963. argument = +argument;
  7964. return markFunction(function( seed, matches ) {
  7965. var j,
  7966. matchIndexes = fn( [], seed.length, argument ),
  7967. i = matchIndexes.length;
  7968. // Match elements found at the specified indexes
  7969. while ( i-- ) {
  7970. if ( seed[ (j = matchIndexes[i]) ] ) {
  7971. seed[j] = !(matches[j] = seed[j]);
  7972. }
  7973. }
  7974. });
  7975. });
  7976. }
  7977. /**
  7978. * Checks a node for validity as a Sizzle context
  7979. * @param {Element|Object=} context
  7980. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  7981. */
  7982. function testContext( context ) {
  7983. return context && typeof context.getElementsByTagName !== "undefined" && context;
  7984. }
  7985. // Expose support vars for convenience
  7986. support = Sizzle.support = {};
  7987. /**
  7988. * Detects XML nodes
  7989. * @param {Element|Object} elem An element or a document
  7990. * @returns {Boolean} True iff elem is a non-HTML XML node
  7991. */
  7992. isXML = Sizzle.isXML = function( elem ) {
  7993. var namespace = elem.namespaceURI,
  7994. docElem = (elem.ownerDocument || elem).documentElement;
  7995. // Support: IE <=8
  7996. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  7997. // https://bugs.jquery.com/ticket/4833
  7998. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  7999. };
  8000. /**
  8001. * Sets document-related variables once based on the current document
  8002. * @param {Element|Object} [doc] An element or document object to use to set the document
  8003. * @returns {Object} Returns the current document
  8004. */
  8005. setDocument = Sizzle.setDocument = function( node ) {
  8006. var hasCompare, subWindow,
  8007. doc = node ? node.ownerDocument || node : preferredDoc;
  8008. // Return early if doc is invalid or already selected
  8009. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8010. return document;
  8011. }
  8012. // Update global variables
  8013. document = doc;
  8014. docElem = document.documentElement;
  8015. documentIsHTML = !isXML( document );
  8016. // Support: IE 9-11, Edge
  8017. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8018. if ( preferredDoc !== document &&
  8019. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8020. // Support: IE 11, Edge
  8021. if ( subWindow.addEventListener ) {
  8022. subWindow.addEventListener( "unload", unloadHandler, false );
  8023. // Support: IE 9 - 10 only
  8024. } else if ( subWindow.attachEvent ) {
  8025. subWindow.attachEvent( "onunload", unloadHandler );
  8026. }
  8027. }
  8028. /* Attributes
  8029. ---------------------------------------------------------------------- */
  8030. // Support: IE<8
  8031. // Verify that getAttribute really returns attributes and not properties
  8032. // (excepting IE8 booleans)
  8033. support.attributes = assert(function( el ) {
  8034. el.className = "i";
  8035. return !el.getAttribute("className");
  8036. });
  8037. /* getElement(s)By*
  8038. ---------------------------------------------------------------------- */
  8039. // Check if getElementsByTagName("*") returns only elements
  8040. support.getElementsByTagName = assert(function( el ) {
  8041. el.appendChild( document.createComment("") );
  8042. return !el.getElementsByTagName("*").length;
  8043. });
  8044. // Support: IE<9
  8045. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8046. // Support: IE<10
  8047. // Check if getElementById returns elements by name
  8048. // The broken getElementById methods don't pick up programmatically-set names,
  8049. // so use a roundabout getElementsByName test
  8050. support.getById = assert(function( el ) {
  8051. docElem.appendChild( el ).id = expando;
  8052. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8053. });
  8054. // ID filter and find
  8055. if ( support.getById ) {
  8056. Expr.filter["ID"] = function( id ) {
  8057. var attrId = id.replace( runescape, funescape );
  8058. return function( elem ) {
  8059. return elem.getAttribute("id") === attrId;
  8060. };
  8061. };
  8062. Expr.find["ID"] = function( id, context ) {
  8063. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8064. var elem = context.getElementById( id );
  8065. return elem ? [ elem ] : [];
  8066. }
  8067. };
  8068. } else {
  8069. Expr.filter["ID"] = function( id ) {
  8070. var attrId = id.replace( runescape, funescape );
  8071. return function( elem ) {
  8072. var node = typeof elem.getAttributeNode !== "undefined" &&
  8073. elem.getAttributeNode("id");
  8074. return node && node.value === attrId;
  8075. };
  8076. };
  8077. // Support: IE 6 - 7 only
  8078. // getElementById is not reliable as a find shortcut
  8079. Expr.find["ID"] = function( id, context ) {
  8080. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8081. var node, i, elems,
  8082. elem = context.getElementById( id );
  8083. if ( elem ) {
  8084. // Verify the id attribute
  8085. node = elem.getAttributeNode("id");
  8086. if ( node && node.value === id ) {
  8087. return [ elem ];
  8088. }
  8089. // Fall back on getElementsByName
  8090. elems = context.getElementsByName( id );
  8091. i = 0;
  8092. while ( (elem = elems[i++]) ) {
  8093. node = elem.getAttributeNode("id");
  8094. if ( node && node.value === id ) {
  8095. return [ elem ];
  8096. }
  8097. }
  8098. }
  8099. return [];
  8100. }
  8101. };
  8102. }
  8103. // Tag
  8104. Expr.find["TAG"] = support.getElementsByTagName ?
  8105. function( tag, context ) {
  8106. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8107. return context.getElementsByTagName( tag );
  8108. // DocumentFragment nodes don't have gEBTN
  8109. } else if ( support.qsa ) {
  8110. return context.querySelectorAll( tag );
  8111. }
  8112. } :
  8113. function( tag, context ) {
  8114. var elem,
  8115. tmp = [],
  8116. i = 0,
  8117. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8118. results = context.getElementsByTagName( tag );
  8119. // Filter out possible comments
  8120. if ( tag === "*" ) {
  8121. while ( (elem = results[i++]) ) {
  8122. if ( elem.nodeType === 1 ) {
  8123. tmp.push( elem );
  8124. }
  8125. }
  8126. return tmp;
  8127. }
  8128. return results;
  8129. };
  8130. // Class
  8131. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8132. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8133. return context.getElementsByClassName( className );
  8134. }
  8135. };
  8136. /* QSA/matchesSelector
  8137. ---------------------------------------------------------------------- */
  8138. // QSA and matchesSelector support
  8139. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8140. rbuggyMatches = [];
  8141. // qSa(:focus) reports false when true (Chrome 21)
  8142. // We allow this because of a bug in IE8/9 that throws an error
  8143. // whenever `document.activeElement` is accessed on an iframe
  8144. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8145. // See https://bugs.jquery.com/ticket/13378
  8146. rbuggyQSA = [];
  8147. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8148. // Build QSA regex
  8149. // Regex strategy adopted from Diego Perini
  8150. assert(function( el ) {
  8151. // Select is set to empty string on purpose
  8152. // This is to test IE's treatment of not explicitly
  8153. // setting a boolean content attribute,
  8154. // since its presence should be enough
  8155. // https://bugs.jquery.com/ticket/12359
  8156. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8157. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8158. "<option selected=''></option></select>";
  8159. // Support: IE8, Opera 11-12.16
  8160. // Nothing should be selected when empty strings follow ^= or $= or *=
  8161. // The test attribute must be unknown in Opera but "safe" for WinRT
  8162. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8163. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8164. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8165. }
  8166. // Support: IE8
  8167. // Boolean attributes and "value" are not treated correctly
  8168. if ( !el.querySelectorAll("[selected]").length ) {
  8169. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8170. }
  8171. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8172. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8173. rbuggyQSA.push("~=");
  8174. }
  8175. // Webkit/Opera - :checked should return selected option elements
  8176. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8177. // IE8 throws error here and will not see later tests
  8178. if ( !el.querySelectorAll(":checked").length ) {
  8179. rbuggyQSA.push(":checked");
  8180. }
  8181. // Support: Safari 8+, iOS 8+
  8182. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8183. // In-page `selector#id sibling-combinator selector` fails
  8184. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8185. rbuggyQSA.push(".#.+[+~]");
  8186. }
  8187. });
  8188. assert(function( el ) {
  8189. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8190. "<select disabled='disabled'><option/></select>";
  8191. // Support: Windows 8 Native Apps
  8192. // The type and name attributes are restricted during .innerHTML assignment
  8193. var input = document.createElement("input");
  8194. input.setAttribute( "type", "hidden" );
  8195. el.appendChild( input ).setAttribute( "name", "D" );
  8196. // Support: IE8
  8197. // Enforce case-sensitivity of name attribute
  8198. if ( el.querySelectorAll("[name=d]").length ) {
  8199. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8200. }
  8201. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8202. // IE8 throws error here and will not see later tests
  8203. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8204. rbuggyQSA.push( ":enabled", ":disabled" );
  8205. }
  8206. // Support: IE9-11+
  8207. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8208. docElem.appendChild( el ).disabled = true;
  8209. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8210. rbuggyQSA.push( ":enabled", ":disabled" );
  8211. }
  8212. // Opera 10-11 does not throw on post-comma invalid pseudos
  8213. el.querySelectorAll("*,:x");
  8214. rbuggyQSA.push(",.*:");
  8215. });
  8216. }
  8217. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8218. docElem.webkitMatchesSelector ||
  8219. docElem.mozMatchesSelector ||
  8220. docElem.oMatchesSelector ||
  8221. docElem.msMatchesSelector) )) ) {
  8222. assert(function( el ) {
  8223. // Check to see if it's possible to do matchesSelector
  8224. // on a disconnected node (IE 9)
  8225. support.disconnectedMatch = matches.call( el, "*" );
  8226. // This should fail with an exception
  8227. // Gecko does not error, returns false instead
  8228. matches.call( el, "[s!='']:x" );
  8229. rbuggyMatches.push( "!=", pseudos );
  8230. });
  8231. }
  8232. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8233. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8234. /* Contains
  8235. ---------------------------------------------------------------------- */
  8236. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8237. // Element contains another
  8238. // Purposefully self-exclusive
  8239. // As in, an element does not contain itself
  8240. contains = hasCompare || rnative.test( docElem.contains ) ?
  8241. function( a, b ) {
  8242. var adown = a.nodeType === 9 ? a.documentElement : a,
  8243. bup = b && b.parentNode;
  8244. return a === bup || !!( bup && bup.nodeType === 1 && (
  8245. adown.contains ?
  8246. adown.contains( bup ) :
  8247. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8248. ));
  8249. } :
  8250. function( a, b ) {
  8251. if ( b ) {
  8252. while ( (b = b.parentNode) ) {
  8253. if ( b === a ) {
  8254. return true;
  8255. }
  8256. }
  8257. }
  8258. return false;
  8259. };
  8260. /* Sorting
  8261. ---------------------------------------------------------------------- */
  8262. // Document order sorting
  8263. sortOrder = hasCompare ?
  8264. function( a, b ) {
  8265. // Flag for duplicate removal
  8266. if ( a === b ) {
  8267. hasDuplicate = true;
  8268. return 0;
  8269. }
  8270. // Sort on method existence if only one input has compareDocumentPosition
  8271. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8272. if ( compare ) {
  8273. return compare;
  8274. }
  8275. // Calculate position if both inputs belong to the same document
  8276. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8277. a.compareDocumentPosition( b ) :
  8278. // Otherwise we know they are disconnected
  8279. 1;
  8280. // Disconnected nodes
  8281. if ( compare & 1 ||
  8282. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8283. // Choose the first element that is related to our preferred document
  8284. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8285. return -1;
  8286. }
  8287. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8288. return 1;
  8289. }
  8290. // Maintain original order
  8291. return sortInput ?
  8292. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8293. 0;
  8294. }
  8295. return compare & 4 ? -1 : 1;
  8296. } :
  8297. function( a, b ) {
  8298. // Exit early if the nodes are identical
  8299. if ( a === b ) {
  8300. hasDuplicate = true;
  8301. return 0;
  8302. }
  8303. var cur,
  8304. i = 0,
  8305. aup = a.parentNode,
  8306. bup = b.parentNode,
  8307. ap = [ a ],
  8308. bp = [ b ];
  8309. // Parentless nodes are either documents or disconnected
  8310. if ( !aup || !bup ) {
  8311. return a === document ? -1 :
  8312. b === document ? 1 :
  8313. aup ? -1 :
  8314. bup ? 1 :
  8315. sortInput ?
  8316. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8317. 0;
  8318. // If the nodes are siblings, we can do a quick check
  8319. } else if ( aup === bup ) {
  8320. return siblingCheck( a, b );
  8321. }
  8322. // Otherwise we need full lists of their ancestors for comparison
  8323. cur = a;
  8324. while ( (cur = cur.parentNode) ) {
  8325. ap.unshift( cur );
  8326. }
  8327. cur = b;
  8328. while ( (cur = cur.parentNode) ) {
  8329. bp.unshift( cur );
  8330. }
  8331. // Walk down the tree looking for a discrepancy
  8332. while ( ap[i] === bp[i] ) {
  8333. i++;
  8334. }
  8335. return i ?
  8336. // Do a sibling check if the nodes have a common ancestor
  8337. siblingCheck( ap[i], bp[i] ) :
  8338. // Otherwise nodes in our document sort first
  8339. ap[i] === preferredDoc ? -1 :
  8340. bp[i] === preferredDoc ? 1 :
  8341. 0;
  8342. };
  8343. return document;
  8344. };
  8345. Sizzle.matches = function( expr, elements ) {
  8346. return Sizzle( expr, null, null, elements );
  8347. };
  8348. Sizzle.matchesSelector = function( elem, expr ) {
  8349. // Set document vars if needed
  8350. if ( ( elem.ownerDocument || elem ) !== document ) {
  8351. setDocument( elem );
  8352. }
  8353. if ( support.matchesSelector && documentIsHTML &&
  8354. !nonnativeSelectorCache[ expr + " " ] &&
  8355. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8356. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8357. try {
  8358. var ret = matches.call( elem, expr );
  8359. // IE 9's matchesSelector returns false on disconnected nodes
  8360. if ( ret || support.disconnectedMatch ||
  8361. // As well, disconnected nodes are said to be in a document
  8362. // fragment in IE 9
  8363. elem.document && elem.document.nodeType !== 11 ) {
  8364. return ret;
  8365. }
  8366. } catch (e) {
  8367. nonnativeSelectorCache( expr, true );
  8368. }
  8369. }
  8370. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8371. };
  8372. Sizzle.contains = function( context, elem ) {
  8373. // Set document vars if needed
  8374. if ( ( context.ownerDocument || context ) !== document ) {
  8375. setDocument( context );
  8376. }
  8377. return contains( context, elem );
  8378. };
  8379. Sizzle.attr = function( elem, name ) {
  8380. // Set document vars if needed
  8381. if ( ( elem.ownerDocument || elem ) !== document ) {
  8382. setDocument( elem );
  8383. }
  8384. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8385. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8386. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8387. fn( elem, name, !documentIsHTML ) :
  8388. undefined;
  8389. return val !== undefined ?
  8390. val :
  8391. support.attributes || !documentIsHTML ?
  8392. elem.getAttribute( name ) :
  8393. (val = elem.getAttributeNode(name)) && val.specified ?
  8394. val.value :
  8395. null;
  8396. };
  8397. Sizzle.escape = function( sel ) {
  8398. return (sel + "").replace( rcssescape, fcssescape );
  8399. };
  8400. Sizzle.error = function( msg ) {
  8401. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8402. };
  8403. /**
  8404. * Document sorting and removing duplicates
  8405. * @param {ArrayLike} results
  8406. */
  8407. Sizzle.uniqueSort = function( results ) {
  8408. var elem,
  8409. duplicates = [],
  8410. j = 0,
  8411. i = 0;
  8412. // Unless we *know* we can detect duplicates, assume their presence
  8413. hasDuplicate = !support.detectDuplicates;
  8414. sortInput = !support.sortStable && results.slice( 0 );
  8415. results.sort( sortOrder );
  8416. if ( hasDuplicate ) {
  8417. while ( (elem = results[i++]) ) {
  8418. if ( elem === results[ i ] ) {
  8419. j = duplicates.push( i );
  8420. }
  8421. }
  8422. while ( j-- ) {
  8423. results.splice( duplicates[ j ], 1 );
  8424. }
  8425. }
  8426. // Clear input after sorting to release objects
  8427. // See https://github.com/jquery/sizzle/pull/225
  8428. sortInput = null;
  8429. return results;
  8430. };
  8431. /**
  8432. * Utility function for retrieving the text value of an array of DOM nodes
  8433. * @param {Array|Element} elem
  8434. */
  8435. getText = Sizzle.getText = function( elem ) {
  8436. var node,
  8437. ret = "",
  8438. i = 0,
  8439. nodeType = elem.nodeType;
  8440. if ( !nodeType ) {
  8441. // If no nodeType, this is expected to be an array
  8442. while ( (node = elem[i++]) ) {
  8443. // Do not traverse comment nodes
  8444. ret += getText( node );
  8445. }
  8446. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8447. // Use textContent for elements
  8448. // innerText usage removed for consistency of new lines (jQuery #11153)
  8449. if ( typeof elem.textContent === "string" ) {
  8450. return elem.textContent;
  8451. } else {
  8452. // Traverse its children
  8453. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8454. ret += getText( elem );
  8455. }
  8456. }
  8457. } else if ( nodeType === 3 || nodeType === 4 ) {
  8458. return elem.nodeValue;
  8459. }
  8460. // Do not include comment or processing instruction nodes
  8461. return ret;
  8462. };
  8463. Expr = Sizzle.selectors = {
  8464. // Can be adjusted by the user
  8465. cacheLength: 50,
  8466. createPseudo: markFunction,
  8467. match: matchExpr,
  8468. attrHandle: {},
  8469. find: {},
  8470. relative: {
  8471. ">": { dir: "parentNode", first: true },
  8472. " ": { dir: "parentNode" },
  8473. "+": { dir: "previousSibling", first: true },
  8474. "~": { dir: "previousSibling" }
  8475. },
  8476. preFilter: {
  8477. "ATTR": function( match ) {
  8478. match[1] = match[1].replace( runescape, funescape );
  8479. // Move the given value to match[3] whether quoted or unquoted
  8480. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8481. if ( match[2] === "~=" ) {
  8482. match[3] = " " + match[3] + " ";
  8483. }
  8484. return match.slice( 0, 4 );
  8485. },
  8486. "CHILD": function( match ) {
  8487. /* matches from matchExpr["CHILD"]
  8488. 1 type (only|nth|...)
  8489. 2 what (child|of-type)
  8490. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8491. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8492. 5 sign of xn-component
  8493. 6 x of xn-component
  8494. 7 sign of y-component
  8495. 8 y of y-component
  8496. */
  8497. match[1] = match[1].toLowerCase();
  8498. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8499. // nth-* requires argument
  8500. if ( !match[3] ) {
  8501. Sizzle.error( match[0] );
  8502. }
  8503. // numeric x and y parameters for Expr.filter.CHILD
  8504. // remember that false/true cast respectively to 0/1
  8505. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8506. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8507. // other types prohibit arguments
  8508. } else if ( match[3] ) {
  8509. Sizzle.error( match[0] );
  8510. }
  8511. return match;
  8512. },
  8513. "PSEUDO": function( match ) {
  8514. var excess,
  8515. unquoted = !match[6] && match[2];
  8516. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8517. return null;
  8518. }
  8519. // Accept quoted arguments as-is
  8520. if ( match[3] ) {
  8521. match[2] = match[4] || match[5] || "";
  8522. // Strip excess characters from unquoted arguments
  8523. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8524. // Get excess from tokenize (recursively)
  8525. (excess = tokenize( unquoted, true )) &&
  8526. // advance to the next closing parenthesis
  8527. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8528. // excess is a negative index
  8529. match[0] = match[0].slice( 0, excess );
  8530. match[2] = unquoted.slice( 0, excess );
  8531. }
  8532. // Return only captures needed by the pseudo filter method (type and argument)
  8533. return match.slice( 0, 3 );
  8534. }
  8535. },
  8536. filter: {
  8537. "TAG": function( nodeNameSelector ) {
  8538. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8539. return nodeNameSelector === "*" ?
  8540. function() { return true; } :
  8541. function( elem ) {
  8542. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8543. };
  8544. },
  8545. "CLASS": function( className ) {
  8546. var pattern = classCache[ className + " " ];
  8547. return pattern ||
  8548. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8549. classCache( className, function( elem ) {
  8550. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8551. });
  8552. },
  8553. "ATTR": function( name, operator, check ) {
  8554. return function( elem ) {
  8555. var result = Sizzle.attr( elem, name );
  8556. if ( result == null ) {
  8557. return operator === "!=";
  8558. }
  8559. if ( !operator ) {
  8560. return true;
  8561. }
  8562. result += "";
  8563. return operator === "=" ? result === check :
  8564. operator === "!=" ? result !== check :
  8565. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8566. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8567. operator === "$=" ? check && result.slice( -check.length ) === check :
  8568. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8569. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8570. false;
  8571. };
  8572. },
  8573. "CHILD": function( type, what, argument, first, last ) {
  8574. var simple = type.slice( 0, 3 ) !== "nth",
  8575. forward = type.slice( -4 ) !== "last",
  8576. ofType = what === "of-type";
  8577. return first === 1 && last === 0 ?
  8578. // Shortcut for :nth-*(n)
  8579. function( elem ) {
  8580. return !!elem.parentNode;
  8581. } :
  8582. function( elem, context, xml ) {
  8583. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8584. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8585. parent = elem.parentNode,
  8586. name = ofType && elem.nodeName.toLowerCase(),
  8587. useCache = !xml && !ofType,
  8588. diff = false;
  8589. if ( parent ) {
  8590. // :(first|last|only)-(child|of-type)
  8591. if ( simple ) {
  8592. while ( dir ) {
  8593. node = elem;
  8594. while ( (node = node[ dir ]) ) {
  8595. if ( ofType ?
  8596. node.nodeName.toLowerCase() === name :
  8597. node.nodeType === 1 ) {
  8598. return false;
  8599. }
  8600. }
  8601. // Reverse direction for :only-* (if we haven't yet done so)
  8602. start = dir = type === "only" && !start && "nextSibling";
  8603. }
  8604. return true;
  8605. }
  8606. start = [ forward ? parent.firstChild : parent.lastChild ];
  8607. // non-xml :nth-child(...) stores cache data on `parent`
  8608. if ( forward && useCache ) {
  8609. // Seek `elem` from a previously-cached index
  8610. // ...in a gzip-friendly way
  8611. node = parent;
  8612. outerCache = node[ expando ] || (node[ expando ] = {});
  8613. // Support: IE <9 only
  8614. // Defend against cloned attroperties (jQuery gh-1709)
  8615. uniqueCache = outerCache[ node.uniqueID ] ||
  8616. (outerCache[ node.uniqueID ] = {});
  8617. cache = uniqueCache[ type ] || [];
  8618. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8619. diff = nodeIndex && cache[ 2 ];
  8620. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8621. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8622. // Fallback to seeking `elem` from the start
  8623. (diff = nodeIndex = 0) || start.pop()) ) {
  8624. // When found, cache indexes on `parent` and break
  8625. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8626. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8627. break;
  8628. }
  8629. }
  8630. } else {
  8631. // Use previously-cached element index if available
  8632. if ( useCache ) {
  8633. // ...in a gzip-friendly way
  8634. node = elem;
  8635. outerCache = node[ expando ] || (node[ expando ] = {});
  8636. // Support: IE <9 only
  8637. // Defend against cloned attroperties (jQuery gh-1709)
  8638. uniqueCache = outerCache[ node.uniqueID ] ||
  8639. (outerCache[ node.uniqueID ] = {});
  8640. cache = uniqueCache[ type ] || [];
  8641. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8642. diff = nodeIndex;
  8643. }
  8644. // xml :nth-child(...)
  8645. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8646. if ( diff === false ) {
  8647. // Use the same loop as above to seek `elem` from the start
  8648. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8649. (diff = nodeIndex = 0) || start.pop()) ) {
  8650. if ( ( ofType ?
  8651. node.nodeName.toLowerCase() === name :
  8652. node.nodeType === 1 ) &&
  8653. ++diff ) {
  8654. // Cache the index of each encountered element
  8655. if ( useCache ) {
  8656. outerCache = node[ expando ] || (node[ expando ] = {});
  8657. // Support: IE <9 only
  8658. // Defend against cloned attroperties (jQuery gh-1709)
  8659. uniqueCache = outerCache[ node.uniqueID ] ||
  8660. (outerCache[ node.uniqueID ] = {});
  8661. uniqueCache[ type ] = [ dirruns, diff ];
  8662. }
  8663. if ( node === elem ) {
  8664. break;
  8665. }
  8666. }
  8667. }
  8668. }
  8669. }
  8670. // Incorporate the offset, then check against cycle size
  8671. diff -= last;
  8672. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8673. }
  8674. };
  8675. },
  8676. "PSEUDO": function( pseudo, argument ) {
  8677. // pseudo-class names are case-insensitive
  8678. // http://www.w3.org/TR/selectors/#pseudo-classes
  8679. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8680. // Remember that setFilters inherits from pseudos
  8681. var args,
  8682. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8683. Sizzle.error( "unsupported pseudo: " + pseudo );
  8684. // The user may use createPseudo to indicate that
  8685. // arguments are needed to create the filter function
  8686. // just as Sizzle does
  8687. if ( fn[ expando ] ) {
  8688. return fn( argument );
  8689. }
  8690. // But maintain support for old signatures
  8691. if ( fn.length > 1 ) {
  8692. args = [ pseudo, pseudo, "", argument ];
  8693. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8694. markFunction(function( seed, matches ) {
  8695. var idx,
  8696. matched = fn( seed, argument ),
  8697. i = matched.length;
  8698. while ( i-- ) {
  8699. idx = indexOf( seed, matched[i] );
  8700. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8701. }
  8702. }) :
  8703. function( elem ) {
  8704. return fn( elem, 0, args );
  8705. };
  8706. }
  8707. return fn;
  8708. }
  8709. },
  8710. pseudos: {
  8711. // Potentially complex pseudos
  8712. "not": markFunction(function( selector ) {
  8713. // Trim the selector passed to compile
  8714. // to avoid treating leading and trailing
  8715. // spaces as combinators
  8716. var input = [],
  8717. results = [],
  8718. matcher = compile( selector.replace( rtrim, "$1" ) );
  8719. return matcher[ expando ] ?
  8720. markFunction(function( seed, matches, context, xml ) {
  8721. var elem,
  8722. unmatched = matcher( seed, null, xml, [] ),
  8723. i = seed.length;
  8724. // Match elements unmatched by `matcher`
  8725. while ( i-- ) {
  8726. if ( (elem = unmatched[i]) ) {
  8727. seed[i] = !(matches[i] = elem);
  8728. }
  8729. }
  8730. }) :
  8731. function( elem, context, xml ) {
  8732. input[0] = elem;
  8733. matcher( input, null, xml, results );
  8734. // Don't keep the element (issue #299)
  8735. input[0] = null;
  8736. return !results.pop();
  8737. };
  8738. }),
  8739. "has": markFunction(function( selector ) {
  8740. return function( elem ) {
  8741. return Sizzle( selector, elem ).length > 0;
  8742. };
  8743. }),
  8744. "contains": markFunction(function( text ) {
  8745. text = text.replace( runescape, funescape );
  8746. return function( elem ) {
  8747. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8748. };
  8749. }),
  8750. // "Whether an element is represented by a :lang() selector
  8751. // is based solely on the element's language value
  8752. // being equal to the identifier C,
  8753. // or beginning with the identifier C immediately followed by "-".
  8754. // The matching of C against the element's language value is performed case-insensitively.
  8755. // The identifier C does not have to be a valid language name."
  8756. // http://www.w3.org/TR/selectors/#lang-pseudo
  8757. "lang": markFunction( function( lang ) {
  8758. // lang value must be a valid identifier
  8759. if ( !ridentifier.test(lang || "") ) {
  8760. Sizzle.error( "unsupported lang: " + lang );
  8761. }
  8762. lang = lang.replace( runescape, funescape ).toLowerCase();
  8763. return function( elem ) {
  8764. var elemLang;
  8765. do {
  8766. if ( (elemLang = documentIsHTML ?
  8767. elem.lang :
  8768. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8769. elemLang = elemLang.toLowerCase();
  8770. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8771. }
  8772. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8773. return false;
  8774. };
  8775. }),
  8776. // Miscellaneous
  8777. "target": function( elem ) {
  8778. var hash = window.location && window.location.hash;
  8779. return hash && hash.slice( 1 ) === elem.id;
  8780. },
  8781. "root": function( elem ) {
  8782. return elem === docElem;
  8783. },
  8784. "focus": function( elem ) {
  8785. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8786. },
  8787. // Boolean properties
  8788. "enabled": createDisabledPseudo( false ),
  8789. "disabled": createDisabledPseudo( true ),
  8790. "checked": function( elem ) {
  8791. // In CSS3, :checked should return both checked and selected elements
  8792. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8793. var nodeName = elem.nodeName.toLowerCase();
  8794. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8795. },
  8796. "selected": function( elem ) {
  8797. // Accessing this property makes selected-by-default
  8798. // options in Safari work properly
  8799. if ( elem.parentNode ) {
  8800. elem.parentNode.selectedIndex;
  8801. }
  8802. return elem.selected === true;
  8803. },
  8804. // Contents
  8805. "empty": function( elem ) {
  8806. // http://www.w3.org/TR/selectors/#empty-pseudo
  8807. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8808. // but not by others (comment: 8; processing instruction: 7; etc.)
  8809. // nodeType < 6 works because attributes (2) do not appear as children
  8810. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8811. if ( elem.nodeType < 6 ) {
  8812. return false;
  8813. }
  8814. }
  8815. return true;
  8816. },
  8817. "parent": function( elem ) {
  8818. return !Expr.pseudos["empty"]( elem );
  8819. },
  8820. // Element/input types
  8821. "header": function( elem ) {
  8822. return rheader.test( elem.nodeName );
  8823. },
  8824. "input": function( elem ) {
  8825. return rinputs.test( elem.nodeName );
  8826. },
  8827. "button": function( elem ) {
  8828. var name = elem.nodeName.toLowerCase();
  8829. return name === "input" && elem.type === "button" || name === "button";
  8830. },
  8831. "text": function( elem ) {
  8832. var attr;
  8833. return elem.nodeName.toLowerCase() === "input" &&
  8834. elem.type === "text" &&
  8835. // Support: IE<8
  8836. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8837. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8838. },
  8839. // Position-in-collection
  8840. "first": createPositionalPseudo(function() {
  8841. return [ 0 ];
  8842. }),
  8843. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8844. return [ length - 1 ];
  8845. }),
  8846. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8847. return [ argument < 0 ? argument + length : argument ];
  8848. }),
  8849. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8850. var i = 0;
  8851. for ( ; i < length; i += 2 ) {
  8852. matchIndexes.push( i );
  8853. }
  8854. return matchIndexes;
  8855. }),
  8856. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8857. var i = 1;
  8858. for ( ; i < length; i += 2 ) {
  8859. matchIndexes.push( i );
  8860. }
  8861. return matchIndexes;
  8862. }),
  8863. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8864. var i = argument < 0 ?
  8865. argument + length :
  8866. argument > length ?
  8867. length :
  8868. argument;
  8869. for ( ; --i >= 0; ) {
  8870. matchIndexes.push( i );
  8871. }
  8872. return matchIndexes;
  8873. }),
  8874. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8875. var i = argument < 0 ? argument + length : argument;
  8876. for ( ; ++i < length; ) {
  8877. matchIndexes.push( i );
  8878. }
  8879. return matchIndexes;
  8880. })
  8881. }
  8882. };
  8883. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8884. // Add button/input type pseudos
  8885. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8886. Expr.pseudos[ i ] = createInputPseudo( i );
  8887. }
  8888. for ( i in { submit: true, reset: true } ) {
  8889. Expr.pseudos[ i ] = createButtonPseudo( i );
  8890. }
  8891. // Easy API for creating new setFilters
  8892. function setFilters() {}
  8893. setFilters.prototype = Expr.filters = Expr.pseudos;
  8894. Expr.setFilters = new setFilters();
  8895. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8896. var matched, match, tokens, type,
  8897. soFar, groups, preFilters,
  8898. cached = tokenCache[ selector + " " ];
  8899. if ( cached ) {
  8900. return parseOnly ? 0 : cached.slice( 0 );
  8901. }
  8902. soFar = selector;
  8903. groups = [];
  8904. preFilters = Expr.preFilter;
  8905. while ( soFar ) {
  8906. // Comma and first run
  8907. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8908. if ( match ) {
  8909. // Don't consume trailing commas as valid
  8910. soFar = soFar.slice( match[0].length ) || soFar;
  8911. }
  8912. groups.push( (tokens = []) );
  8913. }
  8914. matched = false;
  8915. // Combinators
  8916. if ( (match = rcombinators.exec( soFar )) ) {
  8917. matched = match.shift();
  8918. tokens.push({
  8919. value: matched,
  8920. // Cast descendant combinators to space
  8921. type: match[0].replace( rtrim, " " )
  8922. });
  8923. soFar = soFar.slice( matched.length );
  8924. }
  8925. // Filters
  8926. for ( type in Expr.filter ) {
  8927. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8928. (match = preFilters[ type ]( match ))) ) {
  8929. matched = match.shift();
  8930. tokens.push({
  8931. value: matched,
  8932. type: type,
  8933. matches: match
  8934. });
  8935. soFar = soFar.slice( matched.length );
  8936. }
  8937. }
  8938. if ( !matched ) {
  8939. break;
  8940. }
  8941. }
  8942. // Return the length of the invalid excess
  8943. // if we're just parsing
  8944. // Otherwise, throw an error or return tokens
  8945. return parseOnly ?
  8946. soFar.length :
  8947. soFar ?
  8948. Sizzle.error( selector ) :
  8949. // Cache the tokens
  8950. tokenCache( selector, groups ).slice( 0 );
  8951. };
  8952. function toSelector( tokens ) {
  8953. var i = 0,
  8954. len = tokens.length,
  8955. selector = "";
  8956. for ( ; i < len; i++ ) {
  8957. selector += tokens[i].value;
  8958. }
  8959. return selector;
  8960. }
  8961. function addCombinator( matcher, combinator, base ) {
  8962. var dir = combinator.dir,
  8963. skip = combinator.next,
  8964. key = skip || dir,
  8965. checkNonElements = base && key === "parentNode",
  8966. doneName = done++;
  8967. return combinator.first ?
  8968. // Check against closest ancestor/preceding element
  8969. function( elem, context, xml ) {
  8970. while ( (elem = elem[ dir ]) ) {
  8971. if ( elem.nodeType === 1 || checkNonElements ) {
  8972. return matcher( elem, context, xml );
  8973. }
  8974. }
  8975. return false;
  8976. } :
  8977. // Check against all ancestor/preceding elements
  8978. function( elem, context, xml ) {
  8979. var oldCache, uniqueCache, outerCache,
  8980. newCache = [ dirruns, doneName ];
  8981. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  8982. if ( xml ) {
  8983. while ( (elem = elem[ dir ]) ) {
  8984. if ( elem.nodeType === 1 || checkNonElements ) {
  8985. if ( matcher( elem, context, xml ) ) {
  8986. return true;
  8987. }
  8988. }
  8989. }
  8990. } else {
  8991. while ( (elem = elem[ dir ]) ) {
  8992. if ( elem.nodeType === 1 || checkNonElements ) {
  8993. outerCache = elem[ expando ] || (elem[ expando ] = {});
  8994. // Support: IE <9 only
  8995. // Defend against cloned attroperties (jQuery gh-1709)
  8996. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  8997. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  8998. elem = elem[ dir ] || elem;
  8999. } else if ( (oldCache = uniqueCache[ key ]) &&
  9000. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9001. // Assign to newCache so results back-propagate to previous elements
  9002. return (newCache[ 2 ] = oldCache[ 2 ]);
  9003. } else {
  9004. // Reuse newcache so results back-propagate to previous elements
  9005. uniqueCache[ key ] = newCache;
  9006. // A match means we're done; a fail means we have to keep checking
  9007. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9008. return true;
  9009. }
  9010. }
  9011. }
  9012. }
  9013. }
  9014. return false;
  9015. };
  9016. }
  9017. function elementMatcher( matchers ) {
  9018. return matchers.length > 1 ?
  9019. function( elem, context, xml ) {
  9020. var i = matchers.length;
  9021. while ( i-- ) {
  9022. if ( !matchers[i]( elem, context, xml ) ) {
  9023. return false;
  9024. }
  9025. }
  9026. return true;
  9027. } :
  9028. matchers[0];
  9029. }
  9030. function multipleContexts( selector, contexts, results ) {
  9031. var i = 0,
  9032. len = contexts.length;
  9033. for ( ; i < len; i++ ) {
  9034. Sizzle( selector, contexts[i], results );
  9035. }
  9036. return results;
  9037. }
  9038. function condense( unmatched, map, filter, context, xml ) {
  9039. var elem,
  9040. newUnmatched = [],
  9041. i = 0,
  9042. len = unmatched.length,
  9043. mapped = map != null;
  9044. for ( ; i < len; i++ ) {
  9045. if ( (elem = unmatched[i]) ) {
  9046. if ( !filter || filter( elem, context, xml ) ) {
  9047. newUnmatched.push( elem );
  9048. if ( mapped ) {
  9049. map.push( i );
  9050. }
  9051. }
  9052. }
  9053. }
  9054. return newUnmatched;
  9055. }
  9056. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9057. if ( postFilter && !postFilter[ expando ] ) {
  9058. postFilter = setMatcher( postFilter );
  9059. }
  9060. if ( postFinder && !postFinder[ expando ] ) {
  9061. postFinder = setMatcher( postFinder, postSelector );
  9062. }
  9063. return markFunction(function( seed, results, context, xml ) {
  9064. var temp, i, elem,
  9065. preMap = [],
  9066. postMap = [],
  9067. preexisting = results.length,
  9068. // Get initial elements from seed or context
  9069. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9070. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9071. matcherIn = preFilter && ( seed || !selector ) ?
  9072. condense( elems, preMap, preFilter, context, xml ) :
  9073. elems,
  9074. matcherOut = matcher ?
  9075. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9076. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9077. // ...intermediate processing is necessary
  9078. [] :
  9079. // ...otherwise use results directly
  9080. results :
  9081. matcherIn;
  9082. // Find primary matches
  9083. if ( matcher ) {
  9084. matcher( matcherIn, matcherOut, context, xml );
  9085. }
  9086. // Apply postFilter
  9087. if ( postFilter ) {
  9088. temp = condense( matcherOut, postMap );
  9089. postFilter( temp, [], context, xml );
  9090. // Un-match failing elements by moving them back to matcherIn
  9091. i = temp.length;
  9092. while ( i-- ) {
  9093. if ( (elem = temp[i]) ) {
  9094. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9095. }
  9096. }
  9097. }
  9098. if ( seed ) {
  9099. if ( postFinder || preFilter ) {
  9100. if ( postFinder ) {
  9101. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9102. temp = [];
  9103. i = matcherOut.length;
  9104. while ( i-- ) {
  9105. if ( (elem = matcherOut[i]) ) {
  9106. // Restore matcherIn since elem is not yet a final match
  9107. temp.push( (matcherIn[i] = elem) );
  9108. }
  9109. }
  9110. postFinder( null, (matcherOut = []), temp, xml );
  9111. }
  9112. // Move matched elements from seed to results to keep them synchronized
  9113. i = matcherOut.length;
  9114. while ( i-- ) {
  9115. if ( (elem = matcherOut[i]) &&
  9116. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9117. seed[temp] = !(results[temp] = elem);
  9118. }
  9119. }
  9120. }
  9121. // Add elements to results, through postFinder if defined
  9122. } else {
  9123. matcherOut = condense(
  9124. matcherOut === results ?
  9125. matcherOut.splice( preexisting, matcherOut.length ) :
  9126. matcherOut
  9127. );
  9128. if ( postFinder ) {
  9129. postFinder( null, results, matcherOut, xml );
  9130. } else {
  9131. push.apply( results, matcherOut );
  9132. }
  9133. }
  9134. });
  9135. }
  9136. function matcherFromTokens( tokens ) {
  9137. var checkContext, matcher, j,
  9138. len = tokens.length,
  9139. leadingRelative = Expr.relative[ tokens[0].type ],
  9140. implicitRelative = leadingRelative || Expr.relative[" "],
  9141. i = leadingRelative ? 1 : 0,
  9142. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9143. matchContext = addCombinator( function( elem ) {
  9144. return elem === checkContext;
  9145. }, implicitRelative, true ),
  9146. matchAnyContext = addCombinator( function( elem ) {
  9147. return indexOf( checkContext, elem ) > -1;
  9148. }, implicitRelative, true ),
  9149. matchers = [ function( elem, context, xml ) {
  9150. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9151. (checkContext = context).nodeType ?
  9152. matchContext( elem, context, xml ) :
  9153. matchAnyContext( elem, context, xml ) );
  9154. // Avoid hanging onto element (issue #299)
  9155. checkContext = null;
  9156. return ret;
  9157. } ];
  9158. for ( ; i < len; i++ ) {
  9159. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9160. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9161. } else {
  9162. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9163. // Return special upon seeing a positional matcher
  9164. if ( matcher[ expando ] ) {
  9165. // Find the next relative operator (if any) for proper handling
  9166. j = ++i;
  9167. for ( ; j < len; j++ ) {
  9168. if ( Expr.relative[ tokens[j].type ] ) {
  9169. break;
  9170. }
  9171. }
  9172. return setMatcher(
  9173. i > 1 && elementMatcher( matchers ),
  9174. i > 1 && toSelector(
  9175. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9176. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9177. ).replace( rtrim, "$1" ),
  9178. matcher,
  9179. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9180. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9181. j < len && toSelector( tokens )
  9182. );
  9183. }
  9184. matchers.push( matcher );
  9185. }
  9186. }
  9187. return elementMatcher( matchers );
  9188. }
  9189. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9190. var bySet = setMatchers.length > 0,
  9191. byElement = elementMatchers.length > 0,
  9192. superMatcher = function( seed, context, xml, results, outermost ) {
  9193. var elem, j, matcher,
  9194. matchedCount = 0,
  9195. i = "0",
  9196. unmatched = seed && [],
  9197. setMatched = [],
  9198. contextBackup = outermostContext,
  9199. // We must always have either seed elements or outermost context
  9200. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9201. // Use integer dirruns iff this is the outermost matcher
  9202. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9203. len = elems.length;
  9204. if ( outermost ) {
  9205. outermostContext = context === document || context || outermost;
  9206. }
  9207. // Add elements passing elementMatchers directly to results
  9208. // Support: IE<9, Safari
  9209. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9210. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9211. if ( byElement && elem ) {
  9212. j = 0;
  9213. if ( !context && elem.ownerDocument !== document ) {
  9214. setDocument( elem );
  9215. xml = !documentIsHTML;
  9216. }
  9217. while ( (matcher = elementMatchers[j++]) ) {
  9218. if ( matcher( elem, context || document, xml) ) {
  9219. results.push( elem );
  9220. break;
  9221. }
  9222. }
  9223. if ( outermost ) {
  9224. dirruns = dirrunsUnique;
  9225. }
  9226. }
  9227. // Track unmatched elements for set filters
  9228. if ( bySet ) {
  9229. // They will have gone through all possible matchers
  9230. if ( (elem = !matcher && elem) ) {
  9231. matchedCount--;
  9232. }
  9233. // Lengthen the array for every element, matched or not
  9234. if ( seed ) {
  9235. unmatched.push( elem );
  9236. }
  9237. }
  9238. }
  9239. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9240. // makes the latter nonnegative.
  9241. matchedCount += i;
  9242. // Apply set filters to unmatched elements
  9243. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9244. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9245. // no element matchers and no seed.
  9246. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9247. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9248. // numerically zero.
  9249. if ( bySet && i !== matchedCount ) {
  9250. j = 0;
  9251. while ( (matcher = setMatchers[j++]) ) {
  9252. matcher( unmatched, setMatched, context, xml );
  9253. }
  9254. if ( seed ) {
  9255. // Reintegrate element matches to eliminate the need for sorting
  9256. if ( matchedCount > 0 ) {
  9257. while ( i-- ) {
  9258. if ( !(unmatched[i] || setMatched[i]) ) {
  9259. setMatched[i] = pop.call( results );
  9260. }
  9261. }
  9262. }
  9263. // Discard index placeholder values to get only actual matches
  9264. setMatched = condense( setMatched );
  9265. }
  9266. // Add matches to results
  9267. push.apply( results, setMatched );
  9268. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9269. if ( outermost && !seed && setMatched.length > 0 &&
  9270. ( matchedCount + setMatchers.length ) > 1 ) {
  9271. Sizzle.uniqueSort( results );
  9272. }
  9273. }
  9274. // Override manipulation of globals by nested matchers
  9275. if ( outermost ) {
  9276. dirruns = dirrunsUnique;
  9277. outermostContext = contextBackup;
  9278. }
  9279. return unmatched;
  9280. };
  9281. return bySet ?
  9282. markFunction( superMatcher ) :
  9283. superMatcher;
  9284. }
  9285. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9286. var i,
  9287. setMatchers = [],
  9288. elementMatchers = [],
  9289. cached = compilerCache[ selector + " " ];
  9290. if ( !cached ) {
  9291. // Generate a function of recursive functions that can be used to check each element
  9292. if ( !match ) {
  9293. match = tokenize( selector );
  9294. }
  9295. i = match.length;
  9296. while ( i-- ) {
  9297. cached = matcherFromTokens( match[i] );
  9298. if ( cached[ expando ] ) {
  9299. setMatchers.push( cached );
  9300. } else {
  9301. elementMatchers.push( cached );
  9302. }
  9303. }
  9304. // Cache the compiled function
  9305. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9306. // Save selector and tokenization
  9307. cached.selector = selector;
  9308. }
  9309. return cached;
  9310. };
  9311. /**
  9312. * A low-level selection function that works with Sizzle's compiled
  9313. * selector functions
  9314. * @param {String|Function} selector A selector or a pre-compiled
  9315. * selector function built with Sizzle.compile
  9316. * @param {Element} context
  9317. * @param {Array} [results]
  9318. * @param {Array} [seed] A set of elements to match against
  9319. */
  9320. select = Sizzle.select = function( selector, context, results, seed ) {
  9321. var i, tokens, token, type, find,
  9322. compiled = typeof selector === "function" && selector,
  9323. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9324. results = results || [];
  9325. // Try to minimize operations if there is only one selector in the list and no seed
  9326. // (the latter of which guarantees us context)
  9327. if ( match.length === 1 ) {
  9328. // Reduce context if the leading compound selector is an ID
  9329. tokens = match[0] = match[0].slice( 0 );
  9330. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9331. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9332. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9333. if ( !context ) {
  9334. return results;
  9335. // Precompiled matchers will still verify ancestry, so step up a level
  9336. } else if ( compiled ) {
  9337. context = context.parentNode;
  9338. }
  9339. selector = selector.slice( tokens.shift().value.length );
  9340. }
  9341. // Fetch a seed set for right-to-left matching
  9342. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9343. while ( i-- ) {
  9344. token = tokens[i];
  9345. // Abort if we hit a combinator
  9346. if ( Expr.relative[ (type = token.type) ] ) {
  9347. break;
  9348. }
  9349. if ( (find = Expr.find[ type ]) ) {
  9350. // Search, expanding context for leading sibling combinators
  9351. if ( (seed = find(
  9352. token.matches[0].replace( runescape, funescape ),
  9353. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9354. )) ) {
  9355. // If seed is empty or no tokens remain, we can return early
  9356. tokens.splice( i, 1 );
  9357. selector = seed.length && toSelector( tokens );
  9358. if ( !selector ) {
  9359. push.apply( results, seed );
  9360. return results;
  9361. }
  9362. break;
  9363. }
  9364. }
  9365. }
  9366. }
  9367. // Compile and execute a filtering function if one is not provided
  9368. // Provide `match` to avoid retokenization if we modified the selector above
  9369. ( compiled || compile( selector, match ) )(
  9370. seed,
  9371. context,
  9372. !documentIsHTML,
  9373. results,
  9374. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9375. );
  9376. return results;
  9377. };
  9378. // One-time assignments
  9379. // Sort stability
  9380. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9381. // Support: Chrome 14-35+
  9382. // Always assume duplicates if they aren't passed to the comparison function
  9383. support.detectDuplicates = !!hasDuplicate;
  9384. // Initialize against the default document
  9385. setDocument();
  9386. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9387. // Detached nodes confoundingly follow *each other*
  9388. support.sortDetached = assert(function( el ) {
  9389. // Should return 1, but returns 4 (following)
  9390. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9391. });
  9392. // Support: IE<8
  9393. // Prevent attribute/property "interpolation"
  9394. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9395. if ( !assert(function( el ) {
  9396. el.innerHTML = "<a href='#'></a>";
  9397. return el.firstChild.getAttribute("href") === "#" ;
  9398. }) ) {
  9399. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9400. if ( !isXML ) {
  9401. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9402. }
  9403. });
  9404. }
  9405. // Support: IE<9
  9406. // Use defaultValue in place of getAttribute("value")
  9407. if ( !support.attributes || !assert(function( el ) {
  9408. el.innerHTML = "<input/>";
  9409. el.firstChild.setAttribute( "value", "" );
  9410. return el.firstChild.getAttribute( "value" ) === "";
  9411. }) ) {
  9412. addHandle( "value", function( elem, name, isXML ) {
  9413. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9414. return elem.defaultValue;
  9415. }
  9416. });
  9417. }
  9418. // Support: IE<9
  9419. // Use getAttributeNode to fetch booleans when getAttribute lies
  9420. if ( !assert(function( el ) {
  9421. return el.getAttribute("disabled") == null;
  9422. }) ) {
  9423. addHandle( booleans, function( elem, name, isXML ) {
  9424. var val;
  9425. if ( !isXML ) {
  9426. return elem[ name ] === true ? name.toLowerCase() :
  9427. (val = elem.getAttributeNode( name )) && val.specified ?
  9428. val.value :
  9429. null;
  9430. }
  9431. });
  9432. }
  9433. return Sizzle;
  9434. })( window );
  9435. jQuery.find = Sizzle;
  9436. jQuery.expr = Sizzle.selectors;
  9437. // Deprecated
  9438. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9439. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9440. jQuery.text = Sizzle.getText;
  9441. jQuery.isXMLDoc = Sizzle.isXML;
  9442. jQuery.contains = Sizzle.contains;
  9443. jQuery.escapeSelector = Sizzle.escape;
  9444. var dir = function( elem, dir, until ) {
  9445. var matched = [],
  9446. truncate = until !== undefined;
  9447. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9448. if ( elem.nodeType === 1 ) {
  9449. if ( truncate && jQuery( elem ).is( until ) ) {
  9450. break;
  9451. }
  9452. matched.push( elem );
  9453. }
  9454. }
  9455. return matched;
  9456. };
  9457. var siblings = function( n, elem ) {
  9458. var matched = [];
  9459. for ( ; n; n = n.nextSibling ) {
  9460. if ( n.nodeType === 1 && n !== elem ) {
  9461. matched.push( n );
  9462. }
  9463. }
  9464. return matched;
  9465. };
  9466. var rneedsContext = jQuery.expr.match.needsContext;
  9467. function nodeName( elem, name ) {
  9468. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9469. };
  9470. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9471. // Implement the identical functionality for filter and not
  9472. function winnow( elements, qualifier, not ) {
  9473. if ( isFunction( qualifier ) ) {
  9474. return jQuery.grep( elements, function( elem, i ) {
  9475. return !!qualifier.call( elem, i, elem ) !== not;
  9476. } );
  9477. }
  9478. // Single element
  9479. if ( qualifier.nodeType ) {
  9480. return jQuery.grep( elements, function( elem ) {
  9481. return ( elem === qualifier ) !== not;
  9482. } );
  9483. }
  9484. // Arraylike of elements (jQuery, arguments, Array)
  9485. if ( typeof qualifier !== "string" ) {
  9486. return jQuery.grep( elements, function( elem ) {
  9487. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9488. } );
  9489. }
  9490. // Filtered directly for both simple and complex selectors
  9491. return jQuery.filter( qualifier, elements, not );
  9492. }
  9493. jQuery.filter = function( expr, elems, not ) {
  9494. var elem = elems[ 0 ];
  9495. if ( not ) {
  9496. expr = ":not(" + expr + ")";
  9497. }
  9498. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9499. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9500. }
  9501. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9502. return elem.nodeType === 1;
  9503. } ) );
  9504. };
  9505. jQuery.fn.extend( {
  9506. find: function( selector ) {
  9507. var i, ret,
  9508. len = this.length,
  9509. self = this;
  9510. if ( typeof selector !== "string" ) {
  9511. return this.pushStack( jQuery( selector ).filter( function() {
  9512. for ( i = 0; i < len; i++ ) {
  9513. if ( jQuery.contains( self[ i ], this ) ) {
  9514. return true;
  9515. }
  9516. }
  9517. } ) );
  9518. }
  9519. ret = this.pushStack( [] );
  9520. for ( i = 0; i < len; i++ ) {
  9521. jQuery.find( selector, self[ i ], ret );
  9522. }
  9523. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9524. },
  9525. filter: function( selector ) {
  9526. return this.pushStack( winnow( this, selector || [], false ) );
  9527. },
  9528. not: function( selector ) {
  9529. return this.pushStack( winnow( this, selector || [], true ) );
  9530. },
  9531. is: function( selector ) {
  9532. return !!winnow(
  9533. this,
  9534. // If this is a positional/relative selector, check membership in the returned set
  9535. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9536. typeof selector === "string" && rneedsContext.test( selector ) ?
  9537. jQuery( selector ) :
  9538. selector || [],
  9539. false
  9540. ).length;
  9541. }
  9542. } );
  9543. // Initialize a jQuery object
  9544. // A central reference to the root jQuery(document)
  9545. var rootjQuery,
  9546. // A simple way to check for HTML strings
  9547. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9548. // Strict HTML recognition (#11290: must start with <)
  9549. // Shortcut simple #id case for speed
  9550. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9551. init = jQuery.fn.init = function( selector, context, root ) {
  9552. var match, elem;
  9553. // HANDLE: $(""), $(null), $(undefined), $(false)
  9554. if ( !selector ) {
  9555. return this;
  9556. }
  9557. // Method init() accepts an alternate rootjQuery
  9558. // so migrate can support jQuery.sub (gh-2101)
  9559. root = root || rootjQuery;
  9560. // Handle HTML strings
  9561. if ( typeof selector === "string" ) {
  9562. if ( selector[ 0 ] === "<" &&
  9563. selector[ selector.length - 1 ] === ">" &&
  9564. selector.length >= 3 ) {
  9565. // Assume that strings that start and end with <> are HTML and skip the regex check
  9566. match = [ null, selector, null ];
  9567. } else {
  9568. match = rquickExpr.exec( selector );
  9569. }
  9570. // Match html or make sure no context is specified for #id
  9571. if ( match && ( match[ 1 ] || !context ) ) {
  9572. // HANDLE: $(html) -> $(array)
  9573. if ( match[ 1 ] ) {
  9574. context = context instanceof jQuery ? context[ 0 ] : context;
  9575. // Option to run scripts is true for back-compat
  9576. // Intentionally let the error be thrown if parseHTML is not present
  9577. jQuery.merge( this, jQuery.parseHTML(
  9578. match[ 1 ],
  9579. context && context.nodeType ? context.ownerDocument || context : document,
  9580. true
  9581. ) );
  9582. // HANDLE: $(html, props)
  9583. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9584. for ( match in context ) {
  9585. // Properties of context are called as methods if possible
  9586. if ( isFunction( this[ match ] ) ) {
  9587. this[ match ]( context[ match ] );
  9588. // ...and otherwise set as attributes
  9589. } else {
  9590. this.attr( match, context[ match ] );
  9591. }
  9592. }
  9593. }
  9594. return this;
  9595. // HANDLE: $(#id)
  9596. } else {
  9597. elem = document.getElementById( match[ 2 ] );
  9598. if ( elem ) {
  9599. // Inject the element directly into the jQuery object
  9600. this[ 0 ] = elem;
  9601. this.length = 1;
  9602. }
  9603. return this;
  9604. }
  9605. // HANDLE: $(expr, $(...))
  9606. } else if ( !context || context.jquery ) {
  9607. return ( context || root ).find( selector );
  9608. // HANDLE: $(expr, context)
  9609. // (which is just equivalent to: $(context).find(expr)
  9610. } else {
  9611. return this.constructor( context ).find( selector );
  9612. }
  9613. // HANDLE: $(DOMElement)
  9614. } else if ( selector.nodeType ) {
  9615. this[ 0 ] = selector;
  9616. this.length = 1;
  9617. return this;
  9618. // HANDLE: $(function)
  9619. // Shortcut for document ready
  9620. } else if ( isFunction( selector ) ) {
  9621. return root.ready !== undefined ?
  9622. root.ready( selector ) :
  9623. // Execute immediately if ready is not present
  9624. selector( jQuery );
  9625. }
  9626. return jQuery.makeArray( selector, this );
  9627. };
  9628. // Give the init function the jQuery prototype for later instantiation
  9629. init.prototype = jQuery.fn;
  9630. // Initialize central reference
  9631. rootjQuery = jQuery( document );
  9632. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9633. // Methods guaranteed to produce a unique set when starting from a unique set
  9634. guaranteedUnique = {
  9635. children: true,
  9636. contents: true,
  9637. next: true,
  9638. prev: true
  9639. };
  9640. jQuery.fn.extend( {
  9641. has: function( target ) {
  9642. var targets = jQuery( target, this ),
  9643. l = targets.length;
  9644. return this.filter( function() {
  9645. var i = 0;
  9646. for ( ; i < l; i++ ) {
  9647. if ( jQuery.contains( this, targets[ i ] ) ) {
  9648. return true;
  9649. }
  9650. }
  9651. } );
  9652. },
  9653. closest: function( selectors, context ) {
  9654. var cur,
  9655. i = 0,
  9656. l = this.length,
  9657. matched = [],
  9658. targets = typeof selectors !== "string" && jQuery( selectors );
  9659. // Positional selectors never match, since there's no _selection_ context
  9660. if ( !rneedsContext.test( selectors ) ) {
  9661. for ( ; i < l; i++ ) {
  9662. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9663. // Always skip document fragments
  9664. if ( cur.nodeType < 11 && ( targets ?
  9665. targets.index( cur ) > -1 :
  9666. // Don't pass non-elements to Sizzle
  9667. cur.nodeType === 1 &&
  9668. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9669. matched.push( cur );
  9670. break;
  9671. }
  9672. }
  9673. }
  9674. }
  9675. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9676. },
  9677. // Determine the position of an element within the set
  9678. index: function( elem ) {
  9679. // No argument, return index in parent
  9680. if ( !elem ) {
  9681. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9682. }
  9683. // Index in selector
  9684. if ( typeof elem === "string" ) {
  9685. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9686. }
  9687. // Locate the position of the desired element
  9688. return indexOf.call( this,
  9689. // If it receives a jQuery object, the first element is used
  9690. elem.jquery ? elem[ 0 ] : elem
  9691. );
  9692. },
  9693. add: function( selector, context ) {
  9694. return this.pushStack(
  9695. jQuery.uniqueSort(
  9696. jQuery.merge( this.get(), jQuery( selector, context ) )
  9697. )
  9698. );
  9699. },
  9700. addBack: function( selector ) {
  9701. return this.add( selector == null ?
  9702. this.prevObject : this.prevObject.filter( selector )
  9703. );
  9704. }
  9705. } );
  9706. function sibling( cur, dir ) {
  9707. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9708. return cur;
  9709. }
  9710. jQuery.each( {
  9711. parent: function( elem ) {
  9712. var parent = elem.parentNode;
  9713. return parent && parent.nodeType !== 11 ? parent : null;
  9714. },
  9715. parents: function( elem ) {
  9716. return dir( elem, "parentNode" );
  9717. },
  9718. parentsUntil: function( elem, i, until ) {
  9719. return dir( elem, "parentNode", until );
  9720. },
  9721. next: function( elem ) {
  9722. return sibling( elem, "nextSibling" );
  9723. },
  9724. prev: function( elem ) {
  9725. return sibling( elem, "previousSibling" );
  9726. },
  9727. nextAll: function( elem ) {
  9728. return dir( elem, "nextSibling" );
  9729. },
  9730. prevAll: function( elem ) {
  9731. return dir( elem, "previousSibling" );
  9732. },
  9733. nextUntil: function( elem, i, until ) {
  9734. return dir( elem, "nextSibling", until );
  9735. },
  9736. prevUntil: function( elem, i, until ) {
  9737. return dir( elem, "previousSibling", until );
  9738. },
  9739. siblings: function( elem ) {
  9740. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9741. },
  9742. children: function( elem ) {
  9743. return siblings( elem.firstChild );
  9744. },
  9745. contents: function( elem ) {
  9746. if ( typeof elem.contentDocument !== "undefined" ) {
  9747. return elem.contentDocument;
  9748. }
  9749. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9750. // Treat the template element as a regular one in browsers that
  9751. // don't support it.
  9752. if ( nodeName( elem, "template" ) ) {
  9753. elem = elem.content || elem;
  9754. }
  9755. return jQuery.merge( [], elem.childNodes );
  9756. }
  9757. }, function( name, fn ) {
  9758. jQuery.fn[ name ] = function( until, selector ) {
  9759. var matched = jQuery.map( this, fn, until );
  9760. if ( name.slice( -5 ) !== "Until" ) {
  9761. selector = until;
  9762. }
  9763. if ( selector && typeof selector === "string" ) {
  9764. matched = jQuery.filter( selector, matched );
  9765. }
  9766. if ( this.length > 1 ) {
  9767. // Remove duplicates
  9768. if ( !guaranteedUnique[ name ] ) {
  9769. jQuery.uniqueSort( matched );
  9770. }
  9771. // Reverse order for parents* and prev-derivatives
  9772. if ( rparentsprev.test( name ) ) {
  9773. matched.reverse();
  9774. }
  9775. }
  9776. return this.pushStack( matched );
  9777. };
  9778. } );
  9779. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9780. // Convert String-formatted options into Object-formatted ones
  9781. function createOptions( options ) {
  9782. var object = {};
  9783. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9784. object[ flag ] = true;
  9785. } );
  9786. return object;
  9787. }
  9788. /*
  9789. * Create a callback list using the following parameters:
  9790. *
  9791. * options: an optional list of space-separated options that will change how
  9792. * the callback list behaves or a more traditional option object
  9793. *
  9794. * By default a callback list will act like an event callback list and can be
  9795. * "fired" multiple times.
  9796. *
  9797. * Possible options:
  9798. *
  9799. * once: will ensure the callback list can only be fired once (like a Deferred)
  9800. *
  9801. * memory: will keep track of previous values and will call any callback added
  9802. * after the list has been fired right away with the latest "memorized"
  9803. * values (like a Deferred)
  9804. *
  9805. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9806. *
  9807. * stopOnFalse: interrupt callings when a callback returns false
  9808. *
  9809. */
  9810. jQuery.Callbacks = function( options ) {
  9811. // Convert options from String-formatted to Object-formatted if needed
  9812. // (we check in cache first)
  9813. options = typeof options === "string" ?
  9814. createOptions( options ) :
  9815. jQuery.extend( {}, options );
  9816. var // Flag to know if list is currently firing
  9817. firing,
  9818. // Last fire value for non-forgettable lists
  9819. memory,
  9820. // Flag to know if list was already fired
  9821. fired,
  9822. // Flag to prevent firing
  9823. locked,
  9824. // Actual callback list
  9825. list = [],
  9826. // Queue of execution data for repeatable lists
  9827. queue = [],
  9828. // Index of currently firing callback (modified by add/remove as needed)
  9829. firingIndex = -1,
  9830. // Fire callbacks
  9831. fire = function() {
  9832. // Enforce single-firing
  9833. locked = locked || options.once;
  9834. // Execute callbacks for all pending executions,
  9835. // respecting firingIndex overrides and runtime changes
  9836. fired = firing = true;
  9837. for ( ; queue.length; firingIndex = -1 ) {
  9838. memory = queue.shift();
  9839. while ( ++firingIndex < list.length ) {
  9840. // Run callback and check for early termination
  9841. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9842. options.stopOnFalse ) {
  9843. // Jump to end and forget the data so .add doesn't re-fire
  9844. firingIndex = list.length;
  9845. memory = false;
  9846. }
  9847. }
  9848. }
  9849. // Forget the data if we're done with it
  9850. if ( !options.memory ) {
  9851. memory = false;
  9852. }
  9853. firing = false;
  9854. // Clean up if we're done firing for good
  9855. if ( locked ) {
  9856. // Keep an empty list if we have data for future add calls
  9857. if ( memory ) {
  9858. list = [];
  9859. // Otherwise, this object is spent
  9860. } else {
  9861. list = "";
  9862. }
  9863. }
  9864. },
  9865. // Actual Callbacks object
  9866. self = {
  9867. // Add a callback or a collection of callbacks to the list
  9868. add: function() {
  9869. if ( list ) {
  9870. // If we have memory from a past run, we should fire after adding
  9871. if ( memory && !firing ) {
  9872. firingIndex = list.length - 1;
  9873. queue.push( memory );
  9874. }
  9875. ( function add( args ) {
  9876. jQuery.each( args, function( _, arg ) {
  9877. if ( isFunction( arg ) ) {
  9878. if ( !options.unique || !self.has( arg ) ) {
  9879. list.push( arg );
  9880. }
  9881. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9882. // Inspect recursively
  9883. add( arg );
  9884. }
  9885. } );
  9886. } )( arguments );
  9887. if ( memory && !firing ) {
  9888. fire();
  9889. }
  9890. }
  9891. return this;
  9892. },
  9893. // Remove a callback from the list
  9894. remove: function() {
  9895. jQuery.each( arguments, function( _, arg ) {
  9896. var index;
  9897. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9898. list.splice( index, 1 );
  9899. // Handle firing indexes
  9900. if ( index <= firingIndex ) {
  9901. firingIndex--;
  9902. }
  9903. }
  9904. } );
  9905. return this;
  9906. },
  9907. // Check if a given callback is in the list.
  9908. // If no argument is given, return whether or not list has callbacks attached.
  9909. has: function( fn ) {
  9910. return fn ?
  9911. jQuery.inArray( fn, list ) > -1 :
  9912. list.length > 0;
  9913. },
  9914. // Remove all callbacks from the list
  9915. empty: function() {
  9916. if ( list ) {
  9917. list = [];
  9918. }
  9919. return this;
  9920. },
  9921. // Disable .fire and .add
  9922. // Abort any current/pending executions
  9923. // Clear all callbacks and values
  9924. disable: function() {
  9925. locked = queue = [];
  9926. list = memory = "";
  9927. return this;
  9928. },
  9929. disabled: function() {
  9930. return !list;
  9931. },
  9932. // Disable .fire
  9933. // Also disable .add unless we have memory (since it would have no effect)
  9934. // Abort any pending executions
  9935. lock: function() {
  9936. locked = queue = [];
  9937. if ( !memory && !firing ) {
  9938. list = memory = "";
  9939. }
  9940. return this;
  9941. },
  9942. locked: function() {
  9943. return !!locked;
  9944. },
  9945. // Call all callbacks with the given context and arguments
  9946. fireWith: function( context, args ) {
  9947. if ( !locked ) {
  9948. args = args || [];
  9949. args = [ context, args.slice ? args.slice() : args ];
  9950. queue.push( args );
  9951. if ( !firing ) {
  9952. fire();
  9953. }
  9954. }
  9955. return this;
  9956. },
  9957. // Call all the callbacks with the given arguments
  9958. fire: function() {
  9959. self.fireWith( this, arguments );
  9960. return this;
  9961. },
  9962. // To know if the callbacks have already been called at least once
  9963. fired: function() {
  9964. return !!fired;
  9965. }
  9966. };
  9967. return self;
  9968. };
  9969. function Identity( v ) {
  9970. return v;
  9971. }
  9972. function Thrower( ex ) {
  9973. throw ex;
  9974. }
  9975. function adoptValue( value, resolve, reject, noValue ) {
  9976. var method;
  9977. try {
  9978. // Check for promise aspect first to privilege synchronous behavior
  9979. if ( value && isFunction( ( method = value.promise ) ) ) {
  9980. method.call( value ).done( resolve ).fail( reject );
  9981. // Other thenables
  9982. } else if ( value && isFunction( ( method = value.then ) ) ) {
  9983. method.call( value, resolve, reject );
  9984. // Other non-thenables
  9985. } else {
  9986. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  9987. // * false: [ value ].slice( 0 ) => resolve( value )
  9988. // * true: [ value ].slice( 1 ) => resolve()
  9989. resolve.apply( undefined, [ value ].slice( noValue ) );
  9990. }
  9991. // For Promises/A+, convert exceptions into rejections
  9992. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  9993. // Deferred#then to conditionally suppress rejection.
  9994. } catch ( value ) {
  9995. // Support: Android 4.0 only
  9996. // Strict mode functions invoked without .call/.apply get global-object context
  9997. reject.apply( undefined, [ value ] );
  9998. }
  9999. }
  10000. jQuery.extend( {
  10001. Deferred: function( func ) {
  10002. var tuples = [
  10003. // action, add listener, callbacks,
  10004. // ... .then handlers, argument index, [final state]
  10005. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10006. jQuery.Callbacks( "memory" ), 2 ],
  10007. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10008. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10009. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10010. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10011. ],
  10012. state = "pending",
  10013. promise = {
  10014. state: function() {
  10015. return state;
  10016. },
  10017. always: function() {
  10018. deferred.done( arguments ).fail( arguments );
  10019. return this;
  10020. },
  10021. "catch": function( fn ) {
  10022. return promise.then( null, fn );
  10023. },
  10024. // Keep pipe for back-compat
  10025. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10026. var fns = arguments;
  10027. return jQuery.Deferred( function( newDefer ) {
  10028. jQuery.each( tuples, function( i, tuple ) {
  10029. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10030. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10031. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10032. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10033. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10034. deferred[ tuple[ 1 ] ]( function() {
  10035. var returned = fn && fn.apply( this, arguments );
  10036. if ( returned && isFunction( returned.promise ) ) {
  10037. returned.promise()
  10038. .progress( newDefer.notify )
  10039. .done( newDefer.resolve )
  10040. .fail( newDefer.reject );
  10041. } else {
  10042. newDefer[ tuple[ 0 ] + "With" ](
  10043. this,
  10044. fn ? [ returned ] : arguments
  10045. );
  10046. }
  10047. } );
  10048. } );
  10049. fns = null;
  10050. } ).promise();
  10051. },
  10052. then: function( onFulfilled, onRejected, onProgress ) {
  10053. var maxDepth = 0;
  10054. function resolve( depth, deferred, handler, special ) {
  10055. return function() {
  10056. var that = this,
  10057. args = arguments,
  10058. mightThrow = function() {
  10059. var returned, then;
  10060. // Support: Promises/A+ section 2.3.3.3.3
  10061. // https://promisesaplus.com/#point-59
  10062. // Ignore double-resolution attempts
  10063. if ( depth < maxDepth ) {
  10064. return;
  10065. }
  10066. returned = handler.apply( that, args );
  10067. // Support: Promises/A+ section 2.3.1
  10068. // https://promisesaplus.com/#point-48
  10069. if ( returned === deferred.promise() ) {
  10070. throw new TypeError( "Thenable self-resolution" );
  10071. }
  10072. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10073. // https://promisesaplus.com/#point-54
  10074. // https://promisesaplus.com/#point-75
  10075. // Retrieve `then` only once
  10076. then = returned &&
  10077. // Support: Promises/A+ section 2.3.4
  10078. // https://promisesaplus.com/#point-64
  10079. // Only check objects and functions for thenability
  10080. ( typeof returned === "object" ||
  10081. typeof returned === "function" ) &&
  10082. returned.then;
  10083. // Handle a returned thenable
  10084. if ( isFunction( then ) ) {
  10085. // Special processors (notify) just wait for resolution
  10086. if ( special ) {
  10087. then.call(
  10088. returned,
  10089. resolve( maxDepth, deferred, Identity, special ),
  10090. resolve( maxDepth, deferred, Thrower, special )
  10091. );
  10092. // Normal processors (resolve) also hook into progress
  10093. } else {
  10094. // ...and disregard older resolution values
  10095. maxDepth++;
  10096. then.call(
  10097. returned,
  10098. resolve( maxDepth, deferred, Identity, special ),
  10099. resolve( maxDepth, deferred, Thrower, special ),
  10100. resolve( maxDepth, deferred, Identity,
  10101. deferred.notifyWith )
  10102. );
  10103. }
  10104. // Handle all other returned values
  10105. } else {
  10106. // Only substitute handlers pass on context
  10107. // and multiple values (non-spec behavior)
  10108. if ( handler !== Identity ) {
  10109. that = undefined;
  10110. args = [ returned ];
  10111. }
  10112. // Process the value(s)
  10113. // Default process is resolve
  10114. ( special || deferred.resolveWith )( that, args );
  10115. }
  10116. },
  10117. // Only normal processors (resolve) catch and reject exceptions
  10118. process = special ?
  10119. mightThrow :
  10120. function() {
  10121. try {
  10122. mightThrow();
  10123. } catch ( e ) {
  10124. if ( jQuery.Deferred.exceptionHook ) {
  10125. jQuery.Deferred.exceptionHook( e,
  10126. process.stackTrace );
  10127. }
  10128. // Support: Promises/A+ section 2.3.3.3.4.1
  10129. // https://promisesaplus.com/#point-61
  10130. // Ignore post-resolution exceptions
  10131. if ( depth + 1 >= maxDepth ) {
  10132. // Only substitute handlers pass on context
  10133. // and multiple values (non-spec behavior)
  10134. if ( handler !== Thrower ) {
  10135. that = undefined;
  10136. args = [ e ];
  10137. }
  10138. deferred.rejectWith( that, args );
  10139. }
  10140. }
  10141. };
  10142. // Support: Promises/A+ section 2.3.3.3.1
  10143. // https://promisesaplus.com/#point-57
  10144. // Re-resolve promises immediately to dodge false rejection from
  10145. // subsequent errors
  10146. if ( depth ) {
  10147. process();
  10148. } else {
  10149. // Call an optional hook to record the stack, in case of exception
  10150. // since it's otherwise lost when execution goes async
  10151. if ( jQuery.Deferred.getStackHook ) {
  10152. process.stackTrace = jQuery.Deferred.getStackHook();
  10153. }
  10154. window.setTimeout( process );
  10155. }
  10156. };
  10157. }
  10158. return jQuery.Deferred( function( newDefer ) {
  10159. // progress_handlers.add( ... )
  10160. tuples[ 0 ][ 3 ].add(
  10161. resolve(
  10162. 0,
  10163. newDefer,
  10164. isFunction( onProgress ) ?
  10165. onProgress :
  10166. Identity,
  10167. newDefer.notifyWith
  10168. )
  10169. );
  10170. // fulfilled_handlers.add( ... )
  10171. tuples[ 1 ][ 3 ].add(
  10172. resolve(
  10173. 0,
  10174. newDefer,
  10175. isFunction( onFulfilled ) ?
  10176. onFulfilled :
  10177. Identity
  10178. )
  10179. );
  10180. // rejected_handlers.add( ... )
  10181. tuples[ 2 ][ 3 ].add(
  10182. resolve(
  10183. 0,
  10184. newDefer,
  10185. isFunction( onRejected ) ?
  10186. onRejected :
  10187. Thrower
  10188. )
  10189. );
  10190. } ).promise();
  10191. },
  10192. // Get a promise for this deferred
  10193. // If obj is provided, the promise aspect is added to the object
  10194. promise: function( obj ) {
  10195. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10196. }
  10197. },
  10198. deferred = {};
  10199. // Add list-specific methods
  10200. jQuery.each( tuples, function( i, tuple ) {
  10201. var list = tuple[ 2 ],
  10202. stateString = tuple[ 5 ];
  10203. // promise.progress = list.add
  10204. // promise.done = list.add
  10205. // promise.fail = list.add
  10206. promise[ tuple[ 1 ] ] = list.add;
  10207. // Handle state
  10208. if ( stateString ) {
  10209. list.add(
  10210. function() {
  10211. // state = "resolved" (i.e., fulfilled)
  10212. // state = "rejected"
  10213. state = stateString;
  10214. },
  10215. // rejected_callbacks.disable
  10216. // fulfilled_callbacks.disable
  10217. tuples[ 3 - i ][ 2 ].disable,
  10218. // rejected_handlers.disable
  10219. // fulfilled_handlers.disable
  10220. tuples[ 3 - i ][ 3 ].disable,
  10221. // progress_callbacks.lock
  10222. tuples[ 0 ][ 2 ].lock,
  10223. // progress_handlers.lock
  10224. tuples[ 0 ][ 3 ].lock
  10225. );
  10226. }
  10227. // progress_handlers.fire
  10228. // fulfilled_handlers.fire
  10229. // rejected_handlers.fire
  10230. list.add( tuple[ 3 ].fire );
  10231. // deferred.notify = function() { deferred.notifyWith(...) }
  10232. // deferred.resolve = function() { deferred.resolveWith(...) }
  10233. // deferred.reject = function() { deferred.rejectWith(...) }
  10234. deferred[ tuple[ 0 ] ] = function() {
  10235. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10236. return this;
  10237. };
  10238. // deferred.notifyWith = list.fireWith
  10239. // deferred.resolveWith = list.fireWith
  10240. // deferred.rejectWith = list.fireWith
  10241. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10242. } );
  10243. // Make the deferred a promise
  10244. promise.promise( deferred );
  10245. // Call given func if any
  10246. if ( func ) {
  10247. func.call( deferred, deferred );
  10248. }
  10249. // All done!
  10250. return deferred;
  10251. },
  10252. // Deferred helper
  10253. when: function( singleValue ) {
  10254. var
  10255. // count of uncompleted subordinates
  10256. remaining = arguments.length,
  10257. // count of unprocessed arguments
  10258. i = remaining,
  10259. // subordinate fulfillment data
  10260. resolveContexts = Array( i ),
  10261. resolveValues = slice.call( arguments ),
  10262. // the master Deferred
  10263. master = jQuery.Deferred(),
  10264. // subordinate callback factory
  10265. updateFunc = function( i ) {
  10266. return function( value ) {
  10267. resolveContexts[ i ] = this;
  10268. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10269. if ( !( --remaining ) ) {
  10270. master.resolveWith( resolveContexts, resolveValues );
  10271. }
  10272. };
  10273. };
  10274. // Single- and empty arguments are adopted like Promise.resolve
  10275. if ( remaining <= 1 ) {
  10276. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10277. !remaining );
  10278. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10279. if ( master.state() === "pending" ||
  10280. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10281. return master.then();
  10282. }
  10283. }
  10284. // Multiple arguments are aggregated like Promise.all array elements
  10285. while ( i-- ) {
  10286. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10287. }
  10288. return master.promise();
  10289. }
  10290. } );
  10291. // These usually indicate a programmer mistake during development,
  10292. // warn about them ASAP rather than swallowing them by default.
  10293. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10294. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10295. // Support: IE 8 - 9 only
  10296. // Console exists when dev tools are open, which can happen at any time
  10297. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10298. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10299. }
  10300. };
  10301. jQuery.readyException = function( error ) {
  10302. window.setTimeout( function() {
  10303. throw error;
  10304. } );
  10305. };
  10306. // The deferred used on DOM ready
  10307. var readyList = jQuery.Deferred();
  10308. jQuery.fn.ready = function( fn ) {
  10309. readyList
  10310. .then( fn )
  10311. // Wrap jQuery.readyException in a function so that the lookup
  10312. // happens at the time of error handling instead of callback
  10313. // registration.
  10314. .catch( function( error ) {
  10315. jQuery.readyException( error );
  10316. } );
  10317. return this;
  10318. };
  10319. jQuery.extend( {
  10320. // Is the DOM ready to be used? Set to true once it occurs.
  10321. isReady: false,
  10322. // A counter to track how many items to wait for before
  10323. // the ready event fires. See #6781
  10324. readyWait: 1,
  10325. // Handle when the DOM is ready
  10326. ready: function( wait ) {
  10327. // Abort if there are pending holds or we're already ready
  10328. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10329. return;
  10330. }
  10331. // Remember that the DOM is ready
  10332. jQuery.isReady = true;
  10333. // If a normal DOM Ready event fired, decrement, and wait if need be
  10334. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10335. return;
  10336. }
  10337. // If there are functions bound, to execute
  10338. readyList.resolveWith( document, [ jQuery ] );
  10339. }
  10340. } );
  10341. jQuery.ready.then = readyList.then;
  10342. // The ready event handler and self cleanup method
  10343. function completed() {
  10344. document.removeEventListener( "DOMContentLoaded", completed );
  10345. window.removeEventListener( "load", completed );
  10346. jQuery.ready();
  10347. }
  10348. // Catch cases where $(document).ready() is called
  10349. // after the browser event has already occurred.
  10350. // Support: IE <=9 - 10 only
  10351. // Older IE sometimes signals "interactive" too soon
  10352. if ( document.readyState === "complete" ||
  10353. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10354. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10355. window.setTimeout( jQuery.ready );
  10356. } else {
  10357. // Use the handy event callback
  10358. document.addEventListener( "DOMContentLoaded", completed );
  10359. // A fallback to window.onload, that will always work
  10360. window.addEventListener( "load", completed );
  10361. }
  10362. // Multifunctional method to get and set values of a collection
  10363. // The value/s can optionally be executed if it's a function
  10364. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10365. var i = 0,
  10366. len = elems.length,
  10367. bulk = key == null;
  10368. // Sets many values
  10369. if ( toType( key ) === "object" ) {
  10370. chainable = true;
  10371. for ( i in key ) {
  10372. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10373. }
  10374. // Sets one value
  10375. } else if ( value !== undefined ) {
  10376. chainable = true;
  10377. if ( !isFunction( value ) ) {
  10378. raw = true;
  10379. }
  10380. if ( bulk ) {
  10381. // Bulk operations run against the entire set
  10382. if ( raw ) {
  10383. fn.call( elems, value );
  10384. fn = null;
  10385. // ...except when executing function values
  10386. } else {
  10387. bulk = fn;
  10388. fn = function( elem, key, value ) {
  10389. return bulk.call( jQuery( elem ), value );
  10390. };
  10391. }
  10392. }
  10393. if ( fn ) {
  10394. for ( ; i < len; i++ ) {
  10395. fn(
  10396. elems[ i ], key, raw ?
  10397. value :
  10398. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10399. );
  10400. }
  10401. }
  10402. }
  10403. if ( chainable ) {
  10404. return elems;
  10405. }
  10406. // Gets
  10407. if ( bulk ) {
  10408. return fn.call( elems );
  10409. }
  10410. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10411. };
  10412. // Matches dashed string for camelizing
  10413. var rmsPrefix = /^-ms-/,
  10414. rdashAlpha = /-([a-z])/g;
  10415. // Used by camelCase as callback to replace()
  10416. function fcamelCase( all, letter ) {
  10417. return letter.toUpperCase();
  10418. }
  10419. // Convert dashed to camelCase; used by the css and data modules
  10420. // Support: IE <=9 - 11, Edge 12 - 15
  10421. // Microsoft forgot to hump their vendor prefix (#9572)
  10422. function camelCase( string ) {
  10423. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10424. }
  10425. var acceptData = function( owner ) {
  10426. // Accepts only:
  10427. // - Node
  10428. // - Node.ELEMENT_NODE
  10429. // - Node.DOCUMENT_NODE
  10430. // - Object
  10431. // - Any
  10432. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10433. };
  10434. function Data() {
  10435. this.expando = jQuery.expando + Data.uid++;
  10436. }
  10437. Data.uid = 1;
  10438. Data.prototype = {
  10439. cache: function( owner ) {
  10440. // Check if the owner object already has a cache
  10441. var value = owner[ this.expando ];
  10442. // If not, create one
  10443. if ( !value ) {
  10444. value = {};
  10445. // We can accept data for non-element nodes in modern browsers,
  10446. // but we should not, see #8335.
  10447. // Always return an empty object.
  10448. if ( acceptData( owner ) ) {
  10449. // If it is a node unlikely to be stringify-ed or looped over
  10450. // use plain assignment
  10451. if ( owner.nodeType ) {
  10452. owner[ this.expando ] = value;
  10453. // Otherwise secure it in a non-enumerable property
  10454. // configurable must be true to allow the property to be
  10455. // deleted when data is removed
  10456. } else {
  10457. Object.defineProperty( owner, this.expando, {
  10458. value: value,
  10459. configurable: true
  10460. } );
  10461. }
  10462. }
  10463. }
  10464. return value;
  10465. },
  10466. set: function( owner, data, value ) {
  10467. var prop,
  10468. cache = this.cache( owner );
  10469. // Handle: [ owner, key, value ] args
  10470. // Always use camelCase key (gh-2257)
  10471. if ( typeof data === "string" ) {
  10472. cache[ camelCase( data ) ] = value;
  10473. // Handle: [ owner, { properties } ] args
  10474. } else {
  10475. // Copy the properties one-by-one to the cache object
  10476. for ( prop in data ) {
  10477. cache[ camelCase( prop ) ] = data[ prop ];
  10478. }
  10479. }
  10480. return cache;
  10481. },
  10482. get: function( owner, key ) {
  10483. return key === undefined ?
  10484. this.cache( owner ) :
  10485. // Always use camelCase key (gh-2257)
  10486. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10487. },
  10488. access: function( owner, key, value ) {
  10489. // In cases where either:
  10490. //
  10491. // 1. No key was specified
  10492. // 2. A string key was specified, but no value provided
  10493. //
  10494. // Take the "read" path and allow the get method to determine
  10495. // which value to return, respectively either:
  10496. //
  10497. // 1. The entire cache object
  10498. // 2. The data stored at the key
  10499. //
  10500. if ( key === undefined ||
  10501. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10502. return this.get( owner, key );
  10503. }
  10504. // When the key is not a string, or both a key and value
  10505. // are specified, set or extend (existing objects) with either:
  10506. //
  10507. // 1. An object of properties
  10508. // 2. A key and value
  10509. //
  10510. this.set( owner, key, value );
  10511. // Since the "set" path can have two possible entry points
  10512. // return the expected data based on which path was taken[*]
  10513. return value !== undefined ? value : key;
  10514. },
  10515. remove: function( owner, key ) {
  10516. var i,
  10517. cache = owner[ this.expando ];
  10518. if ( cache === undefined ) {
  10519. return;
  10520. }
  10521. if ( key !== undefined ) {
  10522. // Support array or space separated string of keys
  10523. if ( Array.isArray( key ) ) {
  10524. // If key is an array of keys...
  10525. // We always set camelCase keys, so remove that.
  10526. key = key.map( camelCase );
  10527. } else {
  10528. key = camelCase( key );
  10529. // If a key with the spaces exists, use it.
  10530. // Otherwise, create an array by matching non-whitespace
  10531. key = key in cache ?
  10532. [ key ] :
  10533. ( key.match( rnothtmlwhite ) || [] );
  10534. }
  10535. i = key.length;
  10536. while ( i-- ) {
  10537. delete cache[ key[ i ] ];
  10538. }
  10539. }
  10540. // Remove the expando if there's no more data
  10541. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10542. // Support: Chrome <=35 - 45
  10543. // Webkit & Blink performance suffers when deleting properties
  10544. // from DOM nodes, so set to undefined instead
  10545. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10546. if ( owner.nodeType ) {
  10547. owner[ this.expando ] = undefined;
  10548. } else {
  10549. delete owner[ this.expando ];
  10550. }
  10551. }
  10552. },
  10553. hasData: function( owner ) {
  10554. var cache = owner[ this.expando ];
  10555. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10556. }
  10557. };
  10558. var dataPriv = new Data();
  10559. var dataUser = new Data();
  10560. // Implementation Summary
  10561. //
  10562. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10563. // 2. Improve the module's maintainability by reducing the storage
  10564. // paths to a single mechanism.
  10565. // 3. Use the same single mechanism to support "private" and "user" data.
  10566. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10567. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10568. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10569. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10570. rmultiDash = /[A-Z]/g;
  10571. function getData( data ) {
  10572. if ( data === "true" ) {
  10573. return true;
  10574. }
  10575. if ( data === "false" ) {
  10576. return false;
  10577. }
  10578. if ( data === "null" ) {
  10579. return null;
  10580. }
  10581. // Only convert to a number if it doesn't change the string
  10582. if ( data === +data + "" ) {
  10583. return +data;
  10584. }
  10585. if ( rbrace.test( data ) ) {
  10586. return JSON.parse( data );
  10587. }
  10588. return data;
  10589. }
  10590. function dataAttr( elem, key, data ) {
  10591. var name;
  10592. // If nothing was found internally, try to fetch any
  10593. // data from the HTML5 data-* attribute
  10594. if ( data === undefined && elem.nodeType === 1 ) {
  10595. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10596. data = elem.getAttribute( name );
  10597. if ( typeof data === "string" ) {
  10598. try {
  10599. data = getData( data );
  10600. } catch ( e ) {}
  10601. // Make sure we set the data so it isn't changed later
  10602. dataUser.set( elem, key, data );
  10603. } else {
  10604. data = undefined;
  10605. }
  10606. }
  10607. return data;
  10608. }
  10609. jQuery.extend( {
  10610. hasData: function( elem ) {
  10611. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10612. },
  10613. data: function( elem, name, data ) {
  10614. return dataUser.access( elem, name, data );
  10615. },
  10616. removeData: function( elem, name ) {
  10617. dataUser.remove( elem, name );
  10618. },
  10619. // TODO: Now that all calls to _data and _removeData have been replaced
  10620. // with direct calls to dataPriv methods, these can be deprecated.
  10621. _data: function( elem, name, data ) {
  10622. return dataPriv.access( elem, name, data );
  10623. },
  10624. _removeData: function( elem, name ) {
  10625. dataPriv.remove( elem, name );
  10626. }
  10627. } );
  10628. jQuery.fn.extend( {
  10629. data: function( key, value ) {
  10630. var i, name, data,
  10631. elem = this[ 0 ],
  10632. attrs = elem && elem.attributes;
  10633. // Gets all values
  10634. if ( key === undefined ) {
  10635. if ( this.length ) {
  10636. data = dataUser.get( elem );
  10637. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10638. i = attrs.length;
  10639. while ( i-- ) {
  10640. // Support: IE 11 only
  10641. // The attrs elements can be null (#14894)
  10642. if ( attrs[ i ] ) {
  10643. name = attrs[ i ].name;
  10644. if ( name.indexOf( "data-" ) === 0 ) {
  10645. name = camelCase( name.slice( 5 ) );
  10646. dataAttr( elem, name, data[ name ] );
  10647. }
  10648. }
  10649. }
  10650. dataPriv.set( elem, "hasDataAttrs", true );
  10651. }
  10652. }
  10653. return data;
  10654. }
  10655. // Sets multiple values
  10656. if ( typeof key === "object" ) {
  10657. return this.each( function() {
  10658. dataUser.set( this, key );
  10659. } );
  10660. }
  10661. return access( this, function( value ) {
  10662. var data;
  10663. // The calling jQuery object (element matches) is not empty
  10664. // (and therefore has an element appears at this[ 0 ]) and the
  10665. // `value` parameter was not undefined. An empty jQuery object
  10666. // will result in `undefined` for elem = this[ 0 ] which will
  10667. // throw an exception if an attempt to read a data cache is made.
  10668. if ( elem && value === undefined ) {
  10669. // Attempt to get data from the cache
  10670. // The key will always be camelCased in Data
  10671. data = dataUser.get( elem, key );
  10672. if ( data !== undefined ) {
  10673. return data;
  10674. }
  10675. // Attempt to "discover" the data in
  10676. // HTML5 custom data-* attrs
  10677. data = dataAttr( elem, key );
  10678. if ( data !== undefined ) {
  10679. return data;
  10680. }
  10681. // We tried really hard, but the data doesn't exist.
  10682. return;
  10683. }
  10684. // Set the data...
  10685. this.each( function() {
  10686. // We always store the camelCased key
  10687. dataUser.set( this, key, value );
  10688. } );
  10689. }, null, value, arguments.length > 1, null, true );
  10690. },
  10691. removeData: function( key ) {
  10692. return this.each( function() {
  10693. dataUser.remove( this, key );
  10694. } );
  10695. }
  10696. } );
  10697. jQuery.extend( {
  10698. queue: function( elem, type, data ) {
  10699. var queue;
  10700. if ( elem ) {
  10701. type = ( type || "fx" ) + "queue";
  10702. queue = dataPriv.get( elem, type );
  10703. // Speed up dequeue by getting out quickly if this is just a lookup
  10704. if ( data ) {
  10705. if ( !queue || Array.isArray( data ) ) {
  10706. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10707. } else {
  10708. queue.push( data );
  10709. }
  10710. }
  10711. return queue || [];
  10712. }
  10713. },
  10714. dequeue: function( elem, type ) {
  10715. type = type || "fx";
  10716. var queue = jQuery.queue( elem, type ),
  10717. startLength = queue.length,
  10718. fn = queue.shift(),
  10719. hooks = jQuery._queueHooks( elem, type ),
  10720. next = function() {
  10721. jQuery.dequeue( elem, type );
  10722. };
  10723. // If the fx queue is dequeued, always remove the progress sentinel
  10724. if ( fn === "inprogress" ) {
  10725. fn = queue.shift();
  10726. startLength--;
  10727. }
  10728. if ( fn ) {
  10729. // Add a progress sentinel to prevent the fx queue from being
  10730. // automatically dequeued
  10731. if ( type === "fx" ) {
  10732. queue.unshift( "inprogress" );
  10733. }
  10734. // Clear up the last queue stop function
  10735. delete hooks.stop;
  10736. fn.call( elem, next, hooks );
  10737. }
  10738. if ( !startLength && hooks ) {
  10739. hooks.empty.fire();
  10740. }
  10741. },
  10742. // Not public - generate a queueHooks object, or return the current one
  10743. _queueHooks: function( elem, type ) {
  10744. var key = type + "queueHooks";
  10745. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10746. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10747. dataPriv.remove( elem, [ type + "queue", key ] );
  10748. } )
  10749. } );
  10750. }
  10751. } );
  10752. jQuery.fn.extend( {
  10753. queue: function( type, data ) {
  10754. var setter = 2;
  10755. if ( typeof type !== "string" ) {
  10756. data = type;
  10757. type = "fx";
  10758. setter--;
  10759. }
  10760. if ( arguments.length < setter ) {
  10761. return jQuery.queue( this[ 0 ], type );
  10762. }
  10763. return data === undefined ?
  10764. this :
  10765. this.each( function() {
  10766. var queue = jQuery.queue( this, type, data );
  10767. // Ensure a hooks for this queue
  10768. jQuery._queueHooks( this, type );
  10769. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10770. jQuery.dequeue( this, type );
  10771. }
  10772. } );
  10773. },
  10774. dequeue: function( type ) {
  10775. return this.each( function() {
  10776. jQuery.dequeue( this, type );
  10777. } );
  10778. },
  10779. clearQueue: function( type ) {
  10780. return this.queue( type || "fx", [] );
  10781. },
  10782. // Get a promise resolved when queues of a certain type
  10783. // are emptied (fx is the type by default)
  10784. promise: function( type, obj ) {
  10785. var tmp,
  10786. count = 1,
  10787. defer = jQuery.Deferred(),
  10788. elements = this,
  10789. i = this.length,
  10790. resolve = function() {
  10791. if ( !( --count ) ) {
  10792. defer.resolveWith( elements, [ elements ] );
  10793. }
  10794. };
  10795. if ( typeof type !== "string" ) {
  10796. obj = type;
  10797. type = undefined;
  10798. }
  10799. type = type || "fx";
  10800. while ( i-- ) {
  10801. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10802. if ( tmp && tmp.empty ) {
  10803. count++;
  10804. tmp.empty.add( resolve );
  10805. }
  10806. }
  10807. resolve();
  10808. return defer.promise( obj );
  10809. }
  10810. } );
  10811. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10812. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10813. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10814. var documentElement = document.documentElement;
  10815. var isAttached = function( elem ) {
  10816. return jQuery.contains( elem.ownerDocument, elem );
  10817. },
  10818. composed = { composed: true };
  10819. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10820. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10821. // Support: iOS 10.0-10.2 only
  10822. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10823. // leading to errors. We need to check for `getRootNode`.
  10824. if ( documentElement.getRootNode ) {
  10825. isAttached = function( elem ) {
  10826. return jQuery.contains( elem.ownerDocument, elem ) ||
  10827. elem.getRootNode( composed ) === elem.ownerDocument;
  10828. };
  10829. }
  10830. var isHiddenWithinTree = function( elem, el ) {
  10831. // isHiddenWithinTree might be called from jQuery#filter function;
  10832. // in that case, element will be second argument
  10833. elem = el || elem;
  10834. // Inline style trumps all
  10835. return elem.style.display === "none" ||
  10836. elem.style.display === "" &&
  10837. // Otherwise, check computed style
  10838. // Support: Firefox <=43 - 45
  10839. // Disconnected elements can have computed display: none, so first confirm that elem is
  10840. // in the document.
  10841. isAttached( elem ) &&
  10842. jQuery.css( elem, "display" ) === "none";
  10843. };
  10844. var swap = function( elem, options, callback, args ) {
  10845. var ret, name,
  10846. old = {};
  10847. // Remember the old values, and insert the new ones
  10848. for ( name in options ) {
  10849. old[ name ] = elem.style[ name ];
  10850. elem.style[ name ] = options[ name ];
  10851. }
  10852. ret = callback.apply( elem, args || [] );
  10853. // Revert the old values
  10854. for ( name in options ) {
  10855. elem.style[ name ] = old[ name ];
  10856. }
  10857. return ret;
  10858. };
  10859. function adjustCSS( elem, prop, valueParts, tween ) {
  10860. var adjusted, scale,
  10861. maxIterations = 20,
  10862. currentValue = tween ?
  10863. function() {
  10864. return tween.cur();
  10865. } :
  10866. function() {
  10867. return jQuery.css( elem, prop, "" );
  10868. },
  10869. initial = currentValue(),
  10870. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10871. // Starting value computation is required for potential unit mismatches
  10872. initialInUnit = elem.nodeType &&
  10873. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10874. rcssNum.exec( jQuery.css( elem, prop ) );
  10875. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10876. // Support: Firefox <=54
  10877. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10878. initial = initial / 2;
  10879. // Trust units reported by jQuery.css
  10880. unit = unit || initialInUnit[ 3 ];
  10881. // Iteratively approximate from a nonzero starting point
  10882. initialInUnit = +initial || 1;
  10883. while ( maxIterations-- ) {
  10884. // Evaluate and update our best guess (doubling guesses that zero out).
  10885. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10886. jQuery.style( elem, prop, initialInUnit + unit );
  10887. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10888. maxIterations = 0;
  10889. }
  10890. initialInUnit = initialInUnit / scale;
  10891. }
  10892. initialInUnit = initialInUnit * 2;
  10893. jQuery.style( elem, prop, initialInUnit + unit );
  10894. // Make sure we update the tween properties later on
  10895. valueParts = valueParts || [];
  10896. }
  10897. if ( valueParts ) {
  10898. initialInUnit = +initialInUnit || +initial || 0;
  10899. // Apply relative offset (+=/-=) if specified
  10900. adjusted = valueParts[ 1 ] ?
  10901. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10902. +valueParts[ 2 ];
  10903. if ( tween ) {
  10904. tween.unit = unit;
  10905. tween.start = initialInUnit;
  10906. tween.end = adjusted;
  10907. }
  10908. }
  10909. return adjusted;
  10910. }
  10911. var defaultDisplayMap = {};
  10912. function getDefaultDisplay( elem ) {
  10913. var temp,
  10914. doc = elem.ownerDocument,
  10915. nodeName = elem.nodeName,
  10916. display = defaultDisplayMap[ nodeName ];
  10917. if ( display ) {
  10918. return display;
  10919. }
  10920. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10921. display = jQuery.css( temp, "display" );
  10922. temp.parentNode.removeChild( temp );
  10923. if ( display === "none" ) {
  10924. display = "block";
  10925. }
  10926. defaultDisplayMap[ nodeName ] = display;
  10927. return display;
  10928. }
  10929. function showHide( elements, show ) {
  10930. var display, elem,
  10931. values = [],
  10932. index = 0,
  10933. length = elements.length;
  10934. // Determine new display value for elements that need to change
  10935. for ( ; index < length; index++ ) {
  10936. elem = elements[ index ];
  10937. if ( !elem.style ) {
  10938. continue;
  10939. }
  10940. display = elem.style.display;
  10941. if ( show ) {
  10942. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10943. // check is required in this first loop unless we have a nonempty display value (either
  10944. // inline or about-to-be-restored)
  10945. if ( display === "none" ) {
  10946. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10947. if ( !values[ index ] ) {
  10948. elem.style.display = "";
  10949. }
  10950. }
  10951. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10952. values[ index ] = getDefaultDisplay( elem );
  10953. }
  10954. } else {
  10955. if ( display !== "none" ) {
  10956. values[ index ] = "none";
  10957. // Remember what we're overwriting
  10958. dataPriv.set( elem, "display", display );
  10959. }
  10960. }
  10961. }
  10962. // Set the display of the elements in a second loop to avoid constant reflow
  10963. for ( index = 0; index < length; index++ ) {
  10964. if ( values[ index ] != null ) {
  10965. elements[ index ].style.display = values[ index ];
  10966. }
  10967. }
  10968. return elements;
  10969. }
  10970. jQuery.fn.extend( {
  10971. show: function() {
  10972. return showHide( this, true );
  10973. },
  10974. hide: function() {
  10975. return showHide( this );
  10976. },
  10977. toggle: function( state ) {
  10978. if ( typeof state === "boolean" ) {
  10979. return state ? this.show() : this.hide();
  10980. }
  10981. return this.each( function() {
  10982. if ( isHiddenWithinTree( this ) ) {
  10983. jQuery( this ).show();
  10984. } else {
  10985. jQuery( this ).hide();
  10986. }
  10987. } );
  10988. }
  10989. } );
  10990. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  10991. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  10992. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  10993. // We have to close these tags to support XHTML (#13200)
  10994. var wrapMap = {
  10995. // Support: IE <=9 only
  10996. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  10997. // XHTML parsers do not magically insert elements in the
  10998. // same way that tag soup parsers do. So we cannot shorten
  10999. // this by omitting <tbody> or other required elements.
  11000. thead: [ 1, "<table>", "</table>" ],
  11001. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11002. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11003. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11004. _default: [ 0, "", "" ]
  11005. };
  11006. // Support: IE <=9 only
  11007. wrapMap.optgroup = wrapMap.option;
  11008. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11009. wrapMap.th = wrapMap.td;
  11010. function getAll( context, tag ) {
  11011. // Support: IE <=9 - 11 only
  11012. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11013. var ret;
  11014. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11015. ret = context.getElementsByTagName( tag || "*" );
  11016. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11017. ret = context.querySelectorAll( tag || "*" );
  11018. } else {
  11019. ret = [];
  11020. }
  11021. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11022. return jQuery.merge( [ context ], ret );
  11023. }
  11024. return ret;
  11025. }
  11026. // Mark scripts as having already been evaluated
  11027. function setGlobalEval( elems, refElements ) {
  11028. var i = 0,
  11029. l = elems.length;
  11030. for ( ; i < l; i++ ) {
  11031. dataPriv.set(
  11032. elems[ i ],
  11033. "globalEval",
  11034. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11035. );
  11036. }
  11037. }
  11038. var rhtml = /<|&#?\w+;/;
  11039. function buildFragment( elems, context, scripts, selection, ignored ) {
  11040. var elem, tmp, tag, wrap, attached, j,
  11041. fragment = context.createDocumentFragment(),
  11042. nodes = [],
  11043. i = 0,
  11044. l = elems.length;
  11045. for ( ; i < l; i++ ) {
  11046. elem = elems[ i ];
  11047. if ( elem || elem === 0 ) {
  11048. // Add nodes directly
  11049. if ( toType( elem ) === "object" ) {
  11050. // Support: Android <=4.0 only, PhantomJS 1 only
  11051. // push.apply(_, arraylike) throws on ancient WebKit
  11052. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11053. // Convert non-html into a text node
  11054. } else if ( !rhtml.test( elem ) ) {
  11055. nodes.push( context.createTextNode( elem ) );
  11056. // Convert html into DOM nodes
  11057. } else {
  11058. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11059. // Deserialize a standard representation
  11060. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11061. wrap = wrapMap[ tag ] || wrapMap._default;
  11062. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11063. // Descend through wrappers to the right content
  11064. j = wrap[ 0 ];
  11065. while ( j-- ) {
  11066. tmp = tmp.lastChild;
  11067. }
  11068. // Support: Android <=4.0 only, PhantomJS 1 only
  11069. // push.apply(_, arraylike) throws on ancient WebKit
  11070. jQuery.merge( nodes, tmp.childNodes );
  11071. // Remember the top-level container
  11072. tmp = fragment.firstChild;
  11073. // Ensure the created nodes are orphaned (#12392)
  11074. tmp.textContent = "";
  11075. }
  11076. }
  11077. }
  11078. // Remove wrapper from fragment
  11079. fragment.textContent = "";
  11080. i = 0;
  11081. while ( ( elem = nodes[ i++ ] ) ) {
  11082. // Skip elements already in the context collection (trac-4087)
  11083. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11084. if ( ignored ) {
  11085. ignored.push( elem );
  11086. }
  11087. continue;
  11088. }
  11089. attached = isAttached( elem );
  11090. // Append to fragment
  11091. tmp = getAll( fragment.appendChild( elem ), "script" );
  11092. // Preserve script evaluation history
  11093. if ( attached ) {
  11094. setGlobalEval( tmp );
  11095. }
  11096. // Capture executables
  11097. if ( scripts ) {
  11098. j = 0;
  11099. while ( ( elem = tmp[ j++ ] ) ) {
  11100. if ( rscriptType.test( elem.type || "" ) ) {
  11101. scripts.push( elem );
  11102. }
  11103. }
  11104. }
  11105. }
  11106. return fragment;
  11107. }
  11108. ( function() {
  11109. var fragment = document.createDocumentFragment(),
  11110. div = fragment.appendChild( document.createElement( "div" ) ),
  11111. input = document.createElement( "input" );
  11112. // Support: Android 4.0 - 4.3 only
  11113. // Check state lost if the name is set (#11217)
  11114. // Support: Windows Web Apps (WWA)
  11115. // `name` and `type` must use .setAttribute for WWA (#14901)
  11116. input.setAttribute( "type", "radio" );
  11117. input.setAttribute( "checked", "checked" );
  11118. input.setAttribute( "name", "t" );
  11119. div.appendChild( input );
  11120. // Support: Android <=4.1 only
  11121. // Older WebKit doesn't clone checked state correctly in fragments
  11122. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11123. // Support: IE <=11 only
  11124. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11125. div.innerHTML = "<textarea>x</textarea>";
  11126. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11127. } )();
  11128. var
  11129. rkeyEvent = /^key/,
  11130. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11131. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11132. function returnTrue() {
  11133. return true;
  11134. }
  11135. function returnFalse() {
  11136. return false;
  11137. }
  11138. // Support: IE <=9 - 11+
  11139. // focus() and blur() are asynchronous, except when they are no-op.
  11140. // So expect focus to be synchronous when the element is already active,
  11141. // and blur to be synchronous when the element is not already active.
  11142. // (focus and blur are always synchronous in other supported browsers,
  11143. // this just defines when we can count on it).
  11144. function expectSync( elem, type ) {
  11145. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11146. }
  11147. // Support: IE <=9 only
  11148. // Accessing document.activeElement can throw unexpectedly
  11149. // https://bugs.jquery.com/ticket/13393
  11150. function safeActiveElement() {
  11151. try {
  11152. return document.activeElement;
  11153. } catch ( err ) { }
  11154. }
  11155. function on( elem, types, selector, data, fn, one ) {
  11156. var origFn, type;
  11157. // Types can be a map of types/handlers
  11158. if ( typeof types === "object" ) {
  11159. // ( types-Object, selector, data )
  11160. if ( typeof selector !== "string" ) {
  11161. // ( types-Object, data )
  11162. data = data || selector;
  11163. selector = undefined;
  11164. }
  11165. for ( type in types ) {
  11166. on( elem, type, selector, data, types[ type ], one );
  11167. }
  11168. return elem;
  11169. }
  11170. if ( data == null && fn == null ) {
  11171. // ( types, fn )
  11172. fn = selector;
  11173. data = selector = undefined;
  11174. } else if ( fn == null ) {
  11175. if ( typeof selector === "string" ) {
  11176. // ( types, selector, fn )
  11177. fn = data;
  11178. data = undefined;
  11179. } else {
  11180. // ( types, data, fn )
  11181. fn = data;
  11182. data = selector;
  11183. selector = undefined;
  11184. }
  11185. }
  11186. if ( fn === false ) {
  11187. fn = returnFalse;
  11188. } else if ( !fn ) {
  11189. return elem;
  11190. }
  11191. if ( one === 1 ) {
  11192. origFn = fn;
  11193. fn = function( event ) {
  11194. // Can use an empty set, since event contains the info
  11195. jQuery().off( event );
  11196. return origFn.apply( this, arguments );
  11197. };
  11198. // Use same guid so caller can remove using origFn
  11199. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11200. }
  11201. return elem.each( function() {
  11202. jQuery.event.add( this, types, fn, data, selector );
  11203. } );
  11204. }
  11205. /*
  11206. * Helper functions for managing events -- not part of the public interface.
  11207. * Props to Dean Edwards' addEvent library for many of the ideas.
  11208. */
  11209. jQuery.event = {
  11210. global: {},
  11211. add: function( elem, types, handler, data, selector ) {
  11212. var handleObjIn, eventHandle, tmp,
  11213. events, t, handleObj,
  11214. special, handlers, type, namespaces, origType,
  11215. elemData = dataPriv.get( elem );
  11216. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11217. if ( !elemData ) {
  11218. return;
  11219. }
  11220. // Caller can pass in an object of custom data in lieu of the handler
  11221. if ( handler.handler ) {
  11222. handleObjIn = handler;
  11223. handler = handleObjIn.handler;
  11224. selector = handleObjIn.selector;
  11225. }
  11226. // Ensure that invalid selectors throw exceptions at attach time
  11227. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11228. if ( selector ) {
  11229. jQuery.find.matchesSelector( documentElement, selector );
  11230. }
  11231. // Make sure that the handler has a unique ID, used to find/remove it later
  11232. if ( !handler.guid ) {
  11233. handler.guid = jQuery.guid++;
  11234. }
  11235. // Init the element's event structure and main handler, if this is the first
  11236. if ( !( events = elemData.events ) ) {
  11237. events = elemData.events = {};
  11238. }
  11239. if ( !( eventHandle = elemData.handle ) ) {
  11240. eventHandle = elemData.handle = function( e ) {
  11241. // Discard the second event of a jQuery.event.trigger() and
  11242. // when an event is called after a page has unloaded
  11243. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11244. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11245. };
  11246. }
  11247. // Handle multiple events separated by a space
  11248. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11249. t = types.length;
  11250. while ( t-- ) {
  11251. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11252. type = origType = tmp[ 1 ];
  11253. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11254. // There *must* be a type, no attaching namespace-only handlers
  11255. if ( !type ) {
  11256. continue;
  11257. }
  11258. // If event changes its type, use the special event handlers for the changed type
  11259. special = jQuery.event.special[ type ] || {};
  11260. // If selector defined, determine special event api type, otherwise given type
  11261. type = ( selector ? special.delegateType : special.bindType ) || type;
  11262. // Update special based on newly reset type
  11263. special = jQuery.event.special[ type ] || {};
  11264. // handleObj is passed to all event handlers
  11265. handleObj = jQuery.extend( {
  11266. type: type,
  11267. origType: origType,
  11268. data: data,
  11269. handler: handler,
  11270. guid: handler.guid,
  11271. selector: selector,
  11272. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11273. namespace: namespaces.join( "." )
  11274. }, handleObjIn );
  11275. // Init the event handler queue if we're the first
  11276. if ( !( handlers = events[ type ] ) ) {
  11277. handlers = events[ type ] = [];
  11278. handlers.delegateCount = 0;
  11279. // Only use addEventListener if the special events handler returns false
  11280. if ( !special.setup ||
  11281. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11282. if ( elem.addEventListener ) {
  11283. elem.addEventListener( type, eventHandle );
  11284. }
  11285. }
  11286. }
  11287. if ( special.add ) {
  11288. special.add.call( elem, handleObj );
  11289. if ( !handleObj.handler.guid ) {
  11290. handleObj.handler.guid = handler.guid;
  11291. }
  11292. }
  11293. // Add to the element's handler list, delegates in front
  11294. if ( selector ) {
  11295. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11296. } else {
  11297. handlers.push( handleObj );
  11298. }
  11299. // Keep track of which events have ever been used, for event optimization
  11300. jQuery.event.global[ type ] = true;
  11301. }
  11302. },
  11303. // Detach an event or set of events from an element
  11304. remove: function( elem, types, handler, selector, mappedTypes ) {
  11305. var j, origCount, tmp,
  11306. events, t, handleObj,
  11307. special, handlers, type, namespaces, origType,
  11308. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11309. if ( !elemData || !( events = elemData.events ) ) {
  11310. return;
  11311. }
  11312. // Once for each type.namespace in types; type may be omitted
  11313. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11314. t = types.length;
  11315. while ( t-- ) {
  11316. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11317. type = origType = tmp[ 1 ];
  11318. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11319. // Unbind all events (on this namespace, if provided) for the element
  11320. if ( !type ) {
  11321. for ( type in events ) {
  11322. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11323. }
  11324. continue;
  11325. }
  11326. special = jQuery.event.special[ type ] || {};
  11327. type = ( selector ? special.delegateType : special.bindType ) || type;
  11328. handlers = events[ type ] || [];
  11329. tmp = tmp[ 2 ] &&
  11330. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11331. // Remove matching events
  11332. origCount = j = handlers.length;
  11333. while ( j-- ) {
  11334. handleObj = handlers[ j ];
  11335. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11336. ( !handler || handler.guid === handleObj.guid ) &&
  11337. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11338. ( !selector || selector === handleObj.selector ||
  11339. selector === "**" && handleObj.selector ) ) {
  11340. handlers.splice( j, 1 );
  11341. if ( handleObj.selector ) {
  11342. handlers.delegateCount--;
  11343. }
  11344. if ( special.remove ) {
  11345. special.remove.call( elem, handleObj );
  11346. }
  11347. }
  11348. }
  11349. // Remove generic event handler if we removed something and no more handlers exist
  11350. // (avoids potential for endless recursion during removal of special event handlers)
  11351. if ( origCount && !handlers.length ) {
  11352. if ( !special.teardown ||
  11353. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11354. jQuery.removeEvent( elem, type, elemData.handle );
  11355. }
  11356. delete events[ type ];
  11357. }
  11358. }
  11359. // Remove data and the expando if it's no longer used
  11360. if ( jQuery.isEmptyObject( events ) ) {
  11361. dataPriv.remove( elem, "handle events" );
  11362. }
  11363. },
  11364. dispatch: function( nativeEvent ) {
  11365. // Make a writable jQuery.Event from the native event object
  11366. var event = jQuery.event.fix( nativeEvent );
  11367. var i, j, ret, matched, handleObj, handlerQueue,
  11368. args = new Array( arguments.length ),
  11369. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11370. special = jQuery.event.special[ event.type ] || {};
  11371. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11372. args[ 0 ] = event;
  11373. for ( i = 1; i < arguments.length; i++ ) {
  11374. args[ i ] = arguments[ i ];
  11375. }
  11376. event.delegateTarget = this;
  11377. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11378. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11379. return;
  11380. }
  11381. // Determine handlers
  11382. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11383. // Run delegates first; they may want to stop propagation beneath us
  11384. i = 0;
  11385. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11386. event.currentTarget = matched.elem;
  11387. j = 0;
  11388. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11389. !event.isImmediatePropagationStopped() ) {
  11390. // If the event is namespaced, then each handler is only invoked if it is
  11391. // specially universal or its namespaces are a superset of the event's.
  11392. if ( !event.rnamespace || handleObj.namespace === false ||
  11393. event.rnamespace.test( handleObj.namespace ) ) {
  11394. event.handleObj = handleObj;
  11395. event.data = handleObj.data;
  11396. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11397. handleObj.handler ).apply( matched.elem, args );
  11398. if ( ret !== undefined ) {
  11399. if ( ( event.result = ret ) === false ) {
  11400. event.preventDefault();
  11401. event.stopPropagation();
  11402. }
  11403. }
  11404. }
  11405. }
  11406. }
  11407. // Call the postDispatch hook for the mapped type
  11408. if ( special.postDispatch ) {
  11409. special.postDispatch.call( this, event );
  11410. }
  11411. return event.result;
  11412. },
  11413. handlers: function( event, handlers ) {
  11414. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11415. handlerQueue = [],
  11416. delegateCount = handlers.delegateCount,
  11417. cur = event.target;
  11418. // Find delegate handlers
  11419. if ( delegateCount &&
  11420. // Support: IE <=9
  11421. // Black-hole SVG <use> instance trees (trac-13180)
  11422. cur.nodeType &&
  11423. // Support: Firefox <=42
  11424. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11425. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11426. // Support: IE 11 only
  11427. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11428. !( event.type === "click" && event.button >= 1 ) ) {
  11429. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11430. // Don't check non-elements (#13208)
  11431. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11432. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11433. matchedHandlers = [];
  11434. matchedSelectors = {};
  11435. for ( i = 0; i < delegateCount; i++ ) {
  11436. handleObj = handlers[ i ];
  11437. // Don't conflict with Object.prototype properties (#13203)
  11438. sel = handleObj.selector + " ";
  11439. if ( matchedSelectors[ sel ] === undefined ) {
  11440. matchedSelectors[ sel ] = handleObj.needsContext ?
  11441. jQuery( sel, this ).index( cur ) > -1 :
  11442. jQuery.find( sel, this, null, [ cur ] ).length;
  11443. }
  11444. if ( matchedSelectors[ sel ] ) {
  11445. matchedHandlers.push( handleObj );
  11446. }
  11447. }
  11448. if ( matchedHandlers.length ) {
  11449. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11450. }
  11451. }
  11452. }
  11453. }
  11454. // Add the remaining (directly-bound) handlers
  11455. cur = this;
  11456. if ( delegateCount < handlers.length ) {
  11457. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11458. }
  11459. return handlerQueue;
  11460. },
  11461. addProp: function( name, hook ) {
  11462. Object.defineProperty( jQuery.Event.prototype, name, {
  11463. enumerable: true,
  11464. configurable: true,
  11465. get: isFunction( hook ) ?
  11466. function() {
  11467. if ( this.originalEvent ) {
  11468. return hook( this.originalEvent );
  11469. }
  11470. } :
  11471. function() {
  11472. if ( this.originalEvent ) {
  11473. return this.originalEvent[ name ];
  11474. }
  11475. },
  11476. set: function( value ) {
  11477. Object.defineProperty( this, name, {
  11478. enumerable: true,
  11479. configurable: true,
  11480. writable: true,
  11481. value: value
  11482. } );
  11483. }
  11484. } );
  11485. },
  11486. fix: function( originalEvent ) {
  11487. return originalEvent[ jQuery.expando ] ?
  11488. originalEvent :
  11489. new jQuery.Event( originalEvent );
  11490. },
  11491. special: {
  11492. load: {
  11493. // Prevent triggered image.load events from bubbling to window.load
  11494. noBubble: true
  11495. },
  11496. click: {
  11497. // Utilize native event to ensure correct state for checkable inputs
  11498. setup: function( data ) {
  11499. // For mutual compressibility with _default, replace `this` access with a local var.
  11500. // `|| data` is dead code meant only to preserve the variable through minification.
  11501. var el = this || data;
  11502. // Claim the first handler
  11503. if ( rcheckableType.test( el.type ) &&
  11504. el.click && nodeName( el, "input" ) ) {
  11505. // dataPriv.set( el, "click", ... )
  11506. leverageNative( el, "click", returnTrue );
  11507. }
  11508. // Return false to allow normal processing in the caller
  11509. return false;
  11510. },
  11511. trigger: function( data ) {
  11512. // For mutual compressibility with _default, replace `this` access with a local var.
  11513. // `|| data` is dead code meant only to preserve the variable through minification.
  11514. var el = this || data;
  11515. // Force setup before triggering a click
  11516. if ( rcheckableType.test( el.type ) &&
  11517. el.click && nodeName( el, "input" ) ) {
  11518. leverageNative( el, "click" );
  11519. }
  11520. // Return non-false to allow normal event-path propagation
  11521. return true;
  11522. },
  11523. // For cross-browser consistency, suppress native .click() on links
  11524. // Also prevent it if we're currently inside a leveraged native-event stack
  11525. _default: function( event ) {
  11526. var target = event.target;
  11527. return rcheckableType.test( target.type ) &&
  11528. target.click && nodeName( target, "input" ) &&
  11529. dataPriv.get( target, "click" ) ||
  11530. nodeName( target, "a" );
  11531. }
  11532. },
  11533. beforeunload: {
  11534. postDispatch: function( event ) {
  11535. // Support: Firefox 20+
  11536. // Firefox doesn't alert if the returnValue field is not set.
  11537. if ( event.result !== undefined && event.originalEvent ) {
  11538. event.originalEvent.returnValue = event.result;
  11539. }
  11540. }
  11541. }
  11542. }
  11543. };
  11544. // Ensure the presence of an event listener that handles manually-triggered
  11545. // synthetic events by interrupting progress until reinvoked in response to
  11546. // *native* events that it fires directly, ensuring that state changes have
  11547. // already occurred before other listeners are invoked.
  11548. function leverageNative( el, type, expectSync ) {
  11549. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11550. if ( !expectSync ) {
  11551. if ( dataPriv.get( el, type ) === undefined ) {
  11552. jQuery.event.add( el, type, returnTrue );
  11553. }
  11554. return;
  11555. }
  11556. // Register the controller as a special universal handler for all event namespaces
  11557. dataPriv.set( el, type, false );
  11558. jQuery.event.add( el, type, {
  11559. namespace: false,
  11560. handler: function( event ) {
  11561. var notAsync, result,
  11562. saved = dataPriv.get( this, type );
  11563. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11564. // Interrupt processing of the outer synthetic .trigger()ed event
  11565. // Saved data should be false in such cases, but might be a leftover capture object
  11566. // from an async native handler (gh-4350)
  11567. if ( !saved.length ) {
  11568. // Store arguments for use when handling the inner native event
  11569. // There will always be at least one argument (an event object), so this array
  11570. // will not be confused with a leftover capture object.
  11571. saved = slice.call( arguments );
  11572. dataPriv.set( this, type, saved );
  11573. // Trigger the native event and capture its result
  11574. // Support: IE <=9 - 11+
  11575. // focus() and blur() are asynchronous
  11576. notAsync = expectSync( this, type );
  11577. this[ type ]();
  11578. result = dataPriv.get( this, type );
  11579. if ( saved !== result || notAsync ) {
  11580. dataPriv.set( this, type, false );
  11581. } else {
  11582. result = {};
  11583. }
  11584. if ( saved !== result ) {
  11585. // Cancel the outer synthetic event
  11586. event.stopImmediatePropagation();
  11587. event.preventDefault();
  11588. return result.value;
  11589. }
  11590. // If this is an inner synthetic event for an event with a bubbling surrogate
  11591. // (focus or blur), assume that the surrogate already propagated from triggering the
  11592. // native event and prevent that from happening again here.
  11593. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11594. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11595. // less bad than duplication.
  11596. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11597. event.stopPropagation();
  11598. }
  11599. // If this is a native event triggered above, everything is now in order
  11600. // Fire an inner synthetic event with the original arguments
  11601. } else if ( saved.length ) {
  11602. // ...and capture the result
  11603. dataPriv.set( this, type, {
  11604. value: jQuery.event.trigger(
  11605. // Support: IE <=9 - 11+
  11606. // Extend with the prototype to reset the above stopImmediatePropagation()
  11607. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11608. saved.slice( 1 ),
  11609. this
  11610. )
  11611. } );
  11612. // Abort handling of the native event
  11613. event.stopImmediatePropagation();
  11614. }
  11615. }
  11616. } );
  11617. }
  11618. jQuery.removeEvent = function( elem, type, handle ) {
  11619. // This "if" is needed for plain objects
  11620. if ( elem.removeEventListener ) {
  11621. elem.removeEventListener( type, handle );
  11622. }
  11623. };
  11624. jQuery.Event = function( src, props ) {
  11625. // Allow instantiation without the 'new' keyword
  11626. if ( !( this instanceof jQuery.Event ) ) {
  11627. return new jQuery.Event( src, props );
  11628. }
  11629. // Event object
  11630. if ( src && src.type ) {
  11631. this.originalEvent = src;
  11632. this.type = src.type;
  11633. // Events bubbling up the document may have been marked as prevented
  11634. // by a handler lower down the tree; reflect the correct value.
  11635. this.isDefaultPrevented = src.defaultPrevented ||
  11636. src.defaultPrevented === undefined &&
  11637. // Support: Android <=2.3 only
  11638. src.returnValue === false ?
  11639. returnTrue :
  11640. returnFalse;
  11641. // Create target properties
  11642. // Support: Safari <=6 - 7 only
  11643. // Target should not be a text node (#504, #13143)
  11644. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11645. src.target.parentNode :
  11646. src.target;
  11647. this.currentTarget = src.currentTarget;
  11648. this.relatedTarget = src.relatedTarget;
  11649. // Event type
  11650. } else {
  11651. this.type = src;
  11652. }
  11653. // Put explicitly provided properties onto the event object
  11654. if ( props ) {
  11655. jQuery.extend( this, props );
  11656. }
  11657. // Create a timestamp if incoming event doesn't have one
  11658. this.timeStamp = src && src.timeStamp || Date.now();
  11659. // Mark it as fixed
  11660. this[ jQuery.expando ] = true;
  11661. };
  11662. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11663. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11664. jQuery.Event.prototype = {
  11665. constructor: jQuery.Event,
  11666. isDefaultPrevented: returnFalse,
  11667. isPropagationStopped: returnFalse,
  11668. isImmediatePropagationStopped: returnFalse,
  11669. isSimulated: false,
  11670. preventDefault: function() {
  11671. var e = this.originalEvent;
  11672. this.isDefaultPrevented = returnTrue;
  11673. if ( e && !this.isSimulated ) {
  11674. e.preventDefault();
  11675. }
  11676. },
  11677. stopPropagation: function() {
  11678. var e = this.originalEvent;
  11679. this.isPropagationStopped = returnTrue;
  11680. if ( e && !this.isSimulated ) {
  11681. e.stopPropagation();
  11682. }
  11683. },
  11684. stopImmediatePropagation: function() {
  11685. var e = this.originalEvent;
  11686. this.isImmediatePropagationStopped = returnTrue;
  11687. if ( e && !this.isSimulated ) {
  11688. e.stopImmediatePropagation();
  11689. }
  11690. this.stopPropagation();
  11691. }
  11692. };
  11693. // Includes all common event props including KeyEvent and MouseEvent specific props
  11694. jQuery.each( {
  11695. altKey: true,
  11696. bubbles: true,
  11697. cancelable: true,
  11698. changedTouches: true,
  11699. ctrlKey: true,
  11700. detail: true,
  11701. eventPhase: true,
  11702. metaKey: true,
  11703. pageX: true,
  11704. pageY: true,
  11705. shiftKey: true,
  11706. view: true,
  11707. "char": true,
  11708. code: true,
  11709. charCode: true,
  11710. key: true,
  11711. keyCode: true,
  11712. button: true,
  11713. buttons: true,
  11714. clientX: true,
  11715. clientY: true,
  11716. offsetX: true,
  11717. offsetY: true,
  11718. pointerId: true,
  11719. pointerType: true,
  11720. screenX: true,
  11721. screenY: true,
  11722. targetTouches: true,
  11723. toElement: true,
  11724. touches: true,
  11725. which: function( event ) {
  11726. var button = event.button;
  11727. // Add which for key events
  11728. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11729. return event.charCode != null ? event.charCode : event.keyCode;
  11730. }
  11731. // Add which for click: 1 === left; 2 === middle; 3 === right
  11732. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11733. if ( button & 1 ) {
  11734. return 1;
  11735. }
  11736. if ( button & 2 ) {
  11737. return 3;
  11738. }
  11739. if ( button & 4 ) {
  11740. return 2;
  11741. }
  11742. return 0;
  11743. }
  11744. return event.which;
  11745. }
  11746. }, jQuery.event.addProp );
  11747. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11748. jQuery.event.special[ type ] = {
  11749. // Utilize native event if possible so blur/focus sequence is correct
  11750. setup: function() {
  11751. // Claim the first handler
  11752. // dataPriv.set( this, "focus", ... )
  11753. // dataPriv.set( this, "blur", ... )
  11754. leverageNative( this, type, expectSync );
  11755. // Return false to allow normal processing in the caller
  11756. return false;
  11757. },
  11758. trigger: function() {
  11759. // Force setup before trigger
  11760. leverageNative( this, type );
  11761. // Return non-false to allow normal event-path propagation
  11762. return true;
  11763. },
  11764. delegateType: delegateType
  11765. };
  11766. } );
  11767. // Create mouseenter/leave events using mouseover/out and event-time checks
  11768. // so that event delegation works in jQuery.
  11769. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11770. //
  11771. // Support: Safari 7 only
  11772. // Safari sends mouseenter too often; see:
  11773. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11774. // for the description of the bug (it existed in older Chrome versions as well).
  11775. jQuery.each( {
  11776. mouseenter: "mouseover",
  11777. mouseleave: "mouseout",
  11778. pointerenter: "pointerover",
  11779. pointerleave: "pointerout"
  11780. }, function( orig, fix ) {
  11781. jQuery.event.special[ orig ] = {
  11782. delegateType: fix,
  11783. bindType: fix,
  11784. handle: function( event ) {
  11785. var ret,
  11786. target = this,
  11787. related = event.relatedTarget,
  11788. handleObj = event.handleObj;
  11789. // For mouseenter/leave call the handler if related is outside the target.
  11790. // NB: No relatedTarget if the mouse left/entered the browser window
  11791. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11792. event.type = handleObj.origType;
  11793. ret = handleObj.handler.apply( this, arguments );
  11794. event.type = fix;
  11795. }
  11796. return ret;
  11797. }
  11798. };
  11799. } );
  11800. jQuery.fn.extend( {
  11801. on: function( types, selector, data, fn ) {
  11802. return on( this, types, selector, data, fn );
  11803. },
  11804. one: function( types, selector, data, fn ) {
  11805. return on( this, types, selector, data, fn, 1 );
  11806. },
  11807. off: function( types, selector, fn ) {
  11808. var handleObj, type;
  11809. if ( types && types.preventDefault && types.handleObj ) {
  11810. // ( event ) dispatched jQuery.Event
  11811. handleObj = types.handleObj;
  11812. jQuery( types.delegateTarget ).off(
  11813. handleObj.namespace ?
  11814. handleObj.origType + "." + handleObj.namespace :
  11815. handleObj.origType,
  11816. handleObj.selector,
  11817. handleObj.handler
  11818. );
  11819. return this;
  11820. }
  11821. if ( typeof types === "object" ) {
  11822. // ( types-object [, selector] )
  11823. for ( type in types ) {
  11824. this.off( type, selector, types[ type ] );
  11825. }
  11826. return this;
  11827. }
  11828. if ( selector === false || typeof selector === "function" ) {
  11829. // ( types [, fn] )
  11830. fn = selector;
  11831. selector = undefined;
  11832. }
  11833. if ( fn === false ) {
  11834. fn = returnFalse;
  11835. }
  11836. return this.each( function() {
  11837. jQuery.event.remove( this, types, fn, selector );
  11838. } );
  11839. }
  11840. } );
  11841. var
  11842. /* eslint-disable max-len */
  11843. // See https://github.com/eslint/eslint/issues/3229
  11844. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11845. /* eslint-enable */
  11846. // Support: IE <=10 - 11, Edge 12 - 13 only
  11847. // In IE/Edge using regex groups here causes severe slowdowns.
  11848. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11849. rnoInnerhtml = /<script|<style|<link/i,
  11850. // checked="checked" or checked
  11851. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11852. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11853. // Prefer a tbody over its parent table for containing new rows
  11854. function manipulationTarget( elem, content ) {
  11855. if ( nodeName( elem, "table" ) &&
  11856. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11857. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11858. }
  11859. return elem;
  11860. }
  11861. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11862. function disableScript( elem ) {
  11863. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11864. return elem;
  11865. }
  11866. function restoreScript( elem ) {
  11867. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11868. elem.type = elem.type.slice( 5 );
  11869. } else {
  11870. elem.removeAttribute( "type" );
  11871. }
  11872. return elem;
  11873. }
  11874. function cloneCopyEvent( src, dest ) {
  11875. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11876. if ( dest.nodeType !== 1 ) {
  11877. return;
  11878. }
  11879. // 1. Copy private data: events, handlers, etc.
  11880. if ( dataPriv.hasData( src ) ) {
  11881. pdataOld = dataPriv.access( src );
  11882. pdataCur = dataPriv.set( dest, pdataOld );
  11883. events = pdataOld.events;
  11884. if ( events ) {
  11885. delete pdataCur.handle;
  11886. pdataCur.events = {};
  11887. for ( type in events ) {
  11888. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11889. jQuery.event.add( dest, type, events[ type ][ i ] );
  11890. }
  11891. }
  11892. }
  11893. }
  11894. // 2. Copy user data
  11895. if ( dataUser.hasData( src ) ) {
  11896. udataOld = dataUser.access( src );
  11897. udataCur = jQuery.extend( {}, udataOld );
  11898. dataUser.set( dest, udataCur );
  11899. }
  11900. }
  11901. // Fix IE bugs, see support tests
  11902. function fixInput( src, dest ) {
  11903. var nodeName = dest.nodeName.toLowerCase();
  11904. // Fails to persist the checked state of a cloned checkbox or radio button.
  11905. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11906. dest.checked = src.checked;
  11907. // Fails to return the selected option to the default selected state when cloning options
  11908. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11909. dest.defaultValue = src.defaultValue;
  11910. }
  11911. }
  11912. function domManip( collection, args, callback, ignored ) {
  11913. // Flatten any nested arrays
  11914. args = concat.apply( [], args );
  11915. var fragment, first, scripts, hasScripts, node, doc,
  11916. i = 0,
  11917. l = collection.length,
  11918. iNoClone = l - 1,
  11919. value = args[ 0 ],
  11920. valueIsFunction = isFunction( value );
  11921. // We can't cloneNode fragments that contain checked, in WebKit
  11922. if ( valueIsFunction ||
  11923. ( l > 1 && typeof value === "string" &&
  11924. !support.checkClone && rchecked.test( value ) ) ) {
  11925. return collection.each( function( index ) {
  11926. var self = collection.eq( index );
  11927. if ( valueIsFunction ) {
  11928. args[ 0 ] = value.call( this, index, self.html() );
  11929. }
  11930. domManip( self, args, callback, ignored );
  11931. } );
  11932. }
  11933. if ( l ) {
  11934. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11935. first = fragment.firstChild;
  11936. if ( fragment.childNodes.length === 1 ) {
  11937. fragment = first;
  11938. }
  11939. // Require either new content or an interest in ignored elements to invoke the callback
  11940. if ( first || ignored ) {
  11941. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11942. hasScripts = scripts.length;
  11943. // Use the original fragment for the last item
  11944. // instead of the first because it can end up
  11945. // being emptied incorrectly in certain situations (#8070).
  11946. for ( ; i < l; i++ ) {
  11947. node = fragment;
  11948. if ( i !== iNoClone ) {
  11949. node = jQuery.clone( node, true, true );
  11950. // Keep references to cloned scripts for later restoration
  11951. if ( hasScripts ) {
  11952. // Support: Android <=4.0 only, PhantomJS 1 only
  11953. // push.apply(_, arraylike) throws on ancient WebKit
  11954. jQuery.merge( scripts, getAll( node, "script" ) );
  11955. }
  11956. }
  11957. callback.call( collection[ i ], node, i );
  11958. }
  11959. if ( hasScripts ) {
  11960. doc = scripts[ scripts.length - 1 ].ownerDocument;
  11961. // Reenable scripts
  11962. jQuery.map( scripts, restoreScript );
  11963. // Evaluate executable scripts on first document insertion
  11964. for ( i = 0; i < hasScripts; i++ ) {
  11965. node = scripts[ i ];
  11966. if ( rscriptType.test( node.type || "" ) &&
  11967. !dataPriv.access( node, "globalEval" ) &&
  11968. jQuery.contains( doc, node ) ) {
  11969. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  11970. // Optional AJAX dependency, but won't run scripts if not present
  11971. if ( jQuery._evalUrl && !node.noModule ) {
  11972. jQuery._evalUrl( node.src, {
  11973. nonce: node.nonce || node.getAttribute( "nonce" )
  11974. } );
  11975. }
  11976. } else {
  11977. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  11978. }
  11979. }
  11980. }
  11981. }
  11982. }
  11983. }
  11984. return collection;
  11985. }
  11986. function remove( elem, selector, keepData ) {
  11987. var node,
  11988. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  11989. i = 0;
  11990. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  11991. if ( !keepData && node.nodeType === 1 ) {
  11992. jQuery.cleanData( getAll( node ) );
  11993. }
  11994. if ( node.parentNode ) {
  11995. if ( keepData && isAttached( node ) ) {
  11996. setGlobalEval( getAll( node, "script" ) );
  11997. }
  11998. node.parentNode.removeChild( node );
  11999. }
  12000. }
  12001. return elem;
  12002. }
  12003. jQuery.extend( {
  12004. htmlPrefilter: function( html ) {
  12005. return html.replace( rxhtmlTag, "<$1></$2>" );
  12006. },
  12007. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12008. var i, l, srcElements, destElements,
  12009. clone = elem.cloneNode( true ),
  12010. inPage = isAttached( elem );
  12011. // Fix IE cloning issues
  12012. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12013. !jQuery.isXMLDoc( elem ) ) {
  12014. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12015. destElements = getAll( clone );
  12016. srcElements = getAll( elem );
  12017. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12018. fixInput( srcElements[ i ], destElements[ i ] );
  12019. }
  12020. }
  12021. // Copy the events from the original to the clone
  12022. if ( dataAndEvents ) {
  12023. if ( deepDataAndEvents ) {
  12024. srcElements = srcElements || getAll( elem );
  12025. destElements = destElements || getAll( clone );
  12026. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12027. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12028. }
  12029. } else {
  12030. cloneCopyEvent( elem, clone );
  12031. }
  12032. }
  12033. // Preserve script evaluation history
  12034. destElements = getAll( clone, "script" );
  12035. if ( destElements.length > 0 ) {
  12036. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12037. }
  12038. // Return the cloned set
  12039. return clone;
  12040. },
  12041. cleanData: function( elems ) {
  12042. var data, elem, type,
  12043. special = jQuery.event.special,
  12044. i = 0;
  12045. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12046. if ( acceptData( elem ) ) {
  12047. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12048. if ( data.events ) {
  12049. for ( type in data.events ) {
  12050. if ( special[ type ] ) {
  12051. jQuery.event.remove( elem, type );
  12052. // This is a shortcut to avoid jQuery.event.remove's overhead
  12053. } else {
  12054. jQuery.removeEvent( elem, type, data.handle );
  12055. }
  12056. }
  12057. }
  12058. // Support: Chrome <=35 - 45+
  12059. // Assign undefined instead of using delete, see Data#remove
  12060. elem[ dataPriv.expando ] = undefined;
  12061. }
  12062. if ( elem[ dataUser.expando ] ) {
  12063. // Support: Chrome <=35 - 45+
  12064. // Assign undefined instead of using delete, see Data#remove
  12065. elem[ dataUser.expando ] = undefined;
  12066. }
  12067. }
  12068. }
  12069. }
  12070. } );
  12071. jQuery.fn.extend( {
  12072. detach: function( selector ) {
  12073. return remove( this, selector, true );
  12074. },
  12075. remove: function( selector ) {
  12076. return remove( this, selector );
  12077. },
  12078. text: function( value ) {
  12079. return access( this, function( value ) {
  12080. return value === undefined ?
  12081. jQuery.text( this ) :
  12082. this.empty().each( function() {
  12083. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12084. this.textContent = value;
  12085. }
  12086. } );
  12087. }, null, value, arguments.length );
  12088. },
  12089. append: function() {
  12090. return domManip( this, arguments, function( elem ) {
  12091. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12092. var target = manipulationTarget( this, elem );
  12093. target.appendChild( elem );
  12094. }
  12095. } );
  12096. },
  12097. prepend: function() {
  12098. return domManip( this, arguments, function( elem ) {
  12099. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12100. var target = manipulationTarget( this, elem );
  12101. target.insertBefore( elem, target.firstChild );
  12102. }
  12103. } );
  12104. },
  12105. before: function() {
  12106. return domManip( this, arguments, function( elem ) {
  12107. if ( this.parentNode ) {
  12108. this.parentNode.insertBefore( elem, this );
  12109. }
  12110. } );
  12111. },
  12112. after: function() {
  12113. return domManip( this, arguments, function( elem ) {
  12114. if ( this.parentNode ) {
  12115. this.parentNode.insertBefore( elem, this.nextSibling );
  12116. }
  12117. } );
  12118. },
  12119. empty: function() {
  12120. var elem,
  12121. i = 0;
  12122. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12123. if ( elem.nodeType === 1 ) {
  12124. // Prevent memory leaks
  12125. jQuery.cleanData( getAll( elem, false ) );
  12126. // Remove any remaining nodes
  12127. elem.textContent = "";
  12128. }
  12129. }
  12130. return this;
  12131. },
  12132. clone: function( dataAndEvents, deepDataAndEvents ) {
  12133. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12134. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12135. return this.map( function() {
  12136. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12137. } );
  12138. },
  12139. html: function( value ) {
  12140. return access( this, function( value ) {
  12141. var elem = this[ 0 ] || {},
  12142. i = 0,
  12143. l = this.length;
  12144. if ( value === undefined && elem.nodeType === 1 ) {
  12145. return elem.innerHTML;
  12146. }
  12147. // See if we can take a shortcut and just use innerHTML
  12148. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12149. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12150. value = jQuery.htmlPrefilter( value );
  12151. try {
  12152. for ( ; i < l; i++ ) {
  12153. elem = this[ i ] || {};
  12154. // Remove element nodes and prevent memory leaks
  12155. if ( elem.nodeType === 1 ) {
  12156. jQuery.cleanData( getAll( elem, false ) );
  12157. elem.innerHTML = value;
  12158. }
  12159. }
  12160. elem = 0;
  12161. // If using innerHTML throws an exception, use the fallback method
  12162. } catch ( e ) {}
  12163. }
  12164. if ( elem ) {
  12165. this.empty().append( value );
  12166. }
  12167. }, null, value, arguments.length );
  12168. },
  12169. replaceWith: function() {
  12170. var ignored = [];
  12171. // Make the changes, replacing each non-ignored context element with the new content
  12172. return domManip( this, arguments, function( elem ) {
  12173. var parent = this.parentNode;
  12174. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12175. jQuery.cleanData( getAll( this ) );
  12176. if ( parent ) {
  12177. parent.replaceChild( elem, this );
  12178. }
  12179. }
  12180. // Force callback invocation
  12181. }, ignored );
  12182. }
  12183. } );
  12184. jQuery.each( {
  12185. appendTo: "append",
  12186. prependTo: "prepend",
  12187. insertBefore: "before",
  12188. insertAfter: "after",
  12189. replaceAll: "replaceWith"
  12190. }, function( name, original ) {
  12191. jQuery.fn[ name ] = function( selector ) {
  12192. var elems,
  12193. ret = [],
  12194. insert = jQuery( selector ),
  12195. last = insert.length - 1,
  12196. i = 0;
  12197. for ( ; i <= last; i++ ) {
  12198. elems = i === last ? this : this.clone( true );
  12199. jQuery( insert[ i ] )[ original ]( elems );
  12200. // Support: Android <=4.0 only, PhantomJS 1 only
  12201. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12202. push.apply( ret, elems.get() );
  12203. }
  12204. return this.pushStack( ret );
  12205. };
  12206. } );
  12207. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12208. var getStyles = function( elem ) {
  12209. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12210. // IE throws on elements created in popups
  12211. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12212. var view = elem.ownerDocument.defaultView;
  12213. if ( !view || !view.opener ) {
  12214. view = window;
  12215. }
  12216. return view.getComputedStyle( elem );
  12217. };
  12218. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12219. ( function() {
  12220. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12221. // so they're executed at the same time to save the second computation.
  12222. function computeStyleTests() {
  12223. // This is a singleton, we need to execute it only once
  12224. if ( !div ) {
  12225. return;
  12226. }
  12227. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12228. "margin-top:1px;padding:0;border:0";
  12229. div.style.cssText =
  12230. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12231. "margin:auto;border:1px;padding:1px;" +
  12232. "width:60%;top:1%";
  12233. documentElement.appendChild( container ).appendChild( div );
  12234. var divStyle = window.getComputedStyle( div );
  12235. pixelPositionVal = divStyle.top !== "1%";
  12236. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12237. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12238. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12239. // Some styles come back with percentage values, even though they shouldn't
  12240. div.style.right = "60%";
  12241. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12242. // Support: IE 9 - 11 only
  12243. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12244. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12245. // Support: IE 9 only
  12246. // Detect overflow:scroll screwiness (gh-3699)
  12247. // Support: Chrome <=64
  12248. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12249. div.style.position = "absolute";
  12250. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12251. documentElement.removeChild( container );
  12252. // Nullify the div so it wouldn't be stored in the memory and
  12253. // it will also be a sign that checks already performed
  12254. div = null;
  12255. }
  12256. function roundPixelMeasures( measure ) {
  12257. return Math.round( parseFloat( measure ) );
  12258. }
  12259. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12260. reliableMarginLeftVal,
  12261. container = document.createElement( "div" ),
  12262. div = document.createElement( "div" );
  12263. // Finish early in limited (non-browser) environments
  12264. if ( !div.style ) {
  12265. return;
  12266. }
  12267. // Support: IE <=9 - 11 only
  12268. // Style of cloned element affects source element cloned (#8908)
  12269. div.style.backgroundClip = "content-box";
  12270. div.cloneNode( true ).style.backgroundClip = "";
  12271. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12272. jQuery.extend( support, {
  12273. boxSizingReliable: function() {
  12274. computeStyleTests();
  12275. return boxSizingReliableVal;
  12276. },
  12277. pixelBoxStyles: function() {
  12278. computeStyleTests();
  12279. return pixelBoxStylesVal;
  12280. },
  12281. pixelPosition: function() {
  12282. computeStyleTests();
  12283. return pixelPositionVal;
  12284. },
  12285. reliableMarginLeft: function() {
  12286. computeStyleTests();
  12287. return reliableMarginLeftVal;
  12288. },
  12289. scrollboxSize: function() {
  12290. computeStyleTests();
  12291. return scrollboxSizeVal;
  12292. }
  12293. } );
  12294. } )();
  12295. function curCSS( elem, name, computed ) {
  12296. var width, minWidth, maxWidth, ret,
  12297. // Support: Firefox 51+
  12298. // Retrieving style before computed somehow
  12299. // fixes an issue with getting wrong values
  12300. // on detached elements
  12301. style = elem.style;
  12302. computed = computed || getStyles( elem );
  12303. // getPropertyValue is needed for:
  12304. // .css('filter') (IE 9 only, #12537)
  12305. // .css('--customProperty) (#3144)
  12306. if ( computed ) {
  12307. ret = computed.getPropertyValue( name ) || computed[ name ];
  12308. if ( ret === "" && !isAttached( elem ) ) {
  12309. ret = jQuery.style( elem, name );
  12310. }
  12311. // A tribute to the "awesome hack by Dean Edwards"
  12312. // Android Browser returns percentage for some values,
  12313. // but width seems to be reliably pixels.
  12314. // This is against the CSSOM draft spec:
  12315. // https://drafts.csswg.org/cssom/#resolved-values
  12316. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12317. // Remember the original values
  12318. width = style.width;
  12319. minWidth = style.minWidth;
  12320. maxWidth = style.maxWidth;
  12321. // Put in the new values to get a computed value out
  12322. style.minWidth = style.maxWidth = style.width = ret;
  12323. ret = computed.width;
  12324. // Revert the changed values
  12325. style.width = width;
  12326. style.minWidth = minWidth;
  12327. style.maxWidth = maxWidth;
  12328. }
  12329. }
  12330. return ret !== undefined ?
  12331. // Support: IE <=9 - 11 only
  12332. // IE returns zIndex value as an integer.
  12333. ret + "" :
  12334. ret;
  12335. }
  12336. function addGetHookIf( conditionFn, hookFn ) {
  12337. // Define the hook, we'll check on the first run if it's really needed.
  12338. return {
  12339. get: function() {
  12340. if ( conditionFn() ) {
  12341. // Hook not needed (or it's not possible to use it due
  12342. // to missing dependency), remove it.
  12343. delete this.get;
  12344. return;
  12345. }
  12346. // Hook needed; redefine it so that the support test is not executed again.
  12347. return ( this.get = hookFn ).apply( this, arguments );
  12348. }
  12349. };
  12350. }
  12351. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12352. emptyStyle = document.createElement( "div" ).style,
  12353. vendorProps = {};
  12354. // Return a vendor-prefixed property or undefined
  12355. function vendorPropName( name ) {
  12356. // Check for vendor prefixed names
  12357. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12358. i = cssPrefixes.length;
  12359. while ( i-- ) {
  12360. name = cssPrefixes[ i ] + capName;
  12361. if ( name in emptyStyle ) {
  12362. return name;
  12363. }
  12364. }
  12365. }
  12366. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12367. function finalPropName( name ) {
  12368. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12369. if ( final ) {
  12370. return final;
  12371. }
  12372. if ( name in emptyStyle ) {
  12373. return name;
  12374. }
  12375. return vendorProps[ name ] = vendorPropName( name ) || name;
  12376. }
  12377. var
  12378. // Swappable if display is none or starts with table
  12379. // except "table", "table-cell", or "table-caption"
  12380. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12381. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12382. rcustomProp = /^--/,
  12383. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12384. cssNormalTransform = {
  12385. letterSpacing: "0",
  12386. fontWeight: "400"
  12387. };
  12388. function setPositiveNumber( elem, value, subtract ) {
  12389. // Any relative (+/-) values have already been
  12390. // normalized at this point
  12391. var matches = rcssNum.exec( value );
  12392. return matches ?
  12393. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12394. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12395. value;
  12396. }
  12397. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12398. var i = dimension === "width" ? 1 : 0,
  12399. extra = 0,
  12400. delta = 0;
  12401. // Adjustment may not be necessary
  12402. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12403. return 0;
  12404. }
  12405. for ( ; i < 4; i += 2 ) {
  12406. // Both box models exclude margin
  12407. if ( box === "margin" ) {
  12408. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12409. }
  12410. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12411. if ( !isBorderBox ) {
  12412. // Add padding
  12413. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12414. // For "border" or "margin", add border
  12415. if ( box !== "padding" ) {
  12416. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12417. // But still keep track of it otherwise
  12418. } else {
  12419. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12420. }
  12421. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12422. // "padding" or "margin"
  12423. } else {
  12424. // For "content", subtract padding
  12425. if ( box === "content" ) {
  12426. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12427. }
  12428. // For "content" or "padding", subtract border
  12429. if ( box !== "margin" ) {
  12430. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12431. }
  12432. }
  12433. }
  12434. // Account for positive content-box scroll gutter when requested by providing computedVal
  12435. if ( !isBorderBox && computedVal >= 0 ) {
  12436. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12437. // Assuming integer scroll gutter, subtract the rest and round down
  12438. delta += Math.max( 0, Math.ceil(
  12439. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12440. computedVal -
  12441. delta -
  12442. extra -
  12443. 0.5
  12444. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12445. // Use an explicit zero to avoid NaN (gh-3964)
  12446. ) ) || 0;
  12447. }
  12448. return delta;
  12449. }
  12450. function getWidthOrHeight( elem, dimension, extra ) {
  12451. // Start with computed style
  12452. var styles = getStyles( elem ),
  12453. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12454. // Fake content-box until we know it's needed to know the true value.
  12455. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12456. isBorderBox = boxSizingNeeded &&
  12457. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12458. valueIsBorderBox = isBorderBox,
  12459. val = curCSS( elem, dimension, styles ),
  12460. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12461. // Support: Firefox <=54
  12462. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12463. if ( rnumnonpx.test( val ) ) {
  12464. if ( !extra ) {
  12465. return val;
  12466. }
  12467. val = "auto";
  12468. }
  12469. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12470. // This happens for inline elements with no explicit setting (gh-3571)
  12471. // Support: Android <=4.1 - 4.3 only
  12472. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12473. // Support: IE 9-11 only
  12474. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12475. // We use getClientRects() to check for hidden/disconnected.
  12476. // In those cases, the computed value can be trusted to be border-box
  12477. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12478. val === "auto" ||
  12479. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12480. elem.getClientRects().length ) {
  12481. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12482. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12483. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12484. // retrieved value as a content box dimension.
  12485. valueIsBorderBox = offsetProp in elem;
  12486. if ( valueIsBorderBox ) {
  12487. val = elem[ offsetProp ];
  12488. }
  12489. }
  12490. // Normalize "" and auto
  12491. val = parseFloat( val ) || 0;
  12492. // Adjust for the element's box model
  12493. return ( val +
  12494. boxModelAdjustment(
  12495. elem,
  12496. dimension,
  12497. extra || ( isBorderBox ? "border" : "content" ),
  12498. valueIsBorderBox,
  12499. styles,
  12500. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12501. val
  12502. )
  12503. ) + "px";
  12504. }
  12505. jQuery.extend( {
  12506. // Add in style property hooks for overriding the default
  12507. // behavior of getting and setting a style property
  12508. cssHooks: {
  12509. opacity: {
  12510. get: function( elem, computed ) {
  12511. if ( computed ) {
  12512. // We should always get a number back from opacity
  12513. var ret = curCSS( elem, "opacity" );
  12514. return ret === "" ? "1" : ret;
  12515. }
  12516. }
  12517. }
  12518. },
  12519. // Don't automatically add "px" to these possibly-unitless properties
  12520. cssNumber: {
  12521. "animationIterationCount": true,
  12522. "columnCount": true,
  12523. "fillOpacity": true,
  12524. "flexGrow": true,
  12525. "flexShrink": true,
  12526. "fontWeight": true,
  12527. "gridArea": true,
  12528. "gridColumn": true,
  12529. "gridColumnEnd": true,
  12530. "gridColumnStart": true,
  12531. "gridRow": true,
  12532. "gridRowEnd": true,
  12533. "gridRowStart": true,
  12534. "lineHeight": true,
  12535. "opacity": true,
  12536. "order": true,
  12537. "orphans": true,
  12538. "widows": true,
  12539. "zIndex": true,
  12540. "zoom": true
  12541. },
  12542. // Add in properties whose names you wish to fix before
  12543. // setting or getting the value
  12544. cssProps: {},
  12545. // Get and set the style property on a DOM Node
  12546. style: function( elem, name, value, extra ) {
  12547. // Don't set styles on text and comment nodes
  12548. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12549. return;
  12550. }
  12551. // Make sure that we're working with the right name
  12552. var ret, type, hooks,
  12553. origName = camelCase( name ),
  12554. isCustomProp = rcustomProp.test( name ),
  12555. style = elem.style;
  12556. // Make sure that we're working with the right name. We don't
  12557. // want to query the value if it is a CSS custom property
  12558. // since they are user-defined.
  12559. if ( !isCustomProp ) {
  12560. name = finalPropName( origName );
  12561. }
  12562. // Gets hook for the prefixed version, then unprefixed version
  12563. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12564. // Check if we're setting a value
  12565. if ( value !== undefined ) {
  12566. type = typeof value;
  12567. // Convert "+=" or "-=" to relative numbers (#7345)
  12568. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12569. value = adjustCSS( elem, name, ret );
  12570. // Fixes bug #9237
  12571. type = "number";
  12572. }
  12573. // Make sure that null and NaN values aren't set (#7116)
  12574. if ( value == null || value !== value ) {
  12575. return;
  12576. }
  12577. // If a number was passed in, add the unit (except for certain CSS properties)
  12578. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12579. // "px" to a few hardcoded values.
  12580. if ( type === "number" && !isCustomProp ) {
  12581. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12582. }
  12583. // background-* props affect original clone's values
  12584. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12585. style[ name ] = "inherit";
  12586. }
  12587. // If a hook was provided, use that value, otherwise just set the specified value
  12588. if ( !hooks || !( "set" in hooks ) ||
  12589. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12590. if ( isCustomProp ) {
  12591. style.setProperty( name, value );
  12592. } else {
  12593. style[ name ] = value;
  12594. }
  12595. }
  12596. } else {
  12597. // If a hook was provided get the non-computed value from there
  12598. if ( hooks && "get" in hooks &&
  12599. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12600. return ret;
  12601. }
  12602. // Otherwise just get the value from the style object
  12603. return style[ name ];
  12604. }
  12605. },
  12606. css: function( elem, name, extra, styles ) {
  12607. var val, num, hooks,
  12608. origName = camelCase( name ),
  12609. isCustomProp = rcustomProp.test( name );
  12610. // Make sure that we're working with the right name. We don't
  12611. // want to modify the value if it is a CSS custom property
  12612. // since they are user-defined.
  12613. if ( !isCustomProp ) {
  12614. name = finalPropName( origName );
  12615. }
  12616. // Try prefixed name followed by the unprefixed name
  12617. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12618. // If a hook was provided get the computed value from there
  12619. if ( hooks && "get" in hooks ) {
  12620. val = hooks.get( elem, true, extra );
  12621. }
  12622. // Otherwise, if a way to get the computed value exists, use that
  12623. if ( val === undefined ) {
  12624. val = curCSS( elem, name, styles );
  12625. }
  12626. // Convert "normal" to computed value
  12627. if ( val === "normal" && name in cssNormalTransform ) {
  12628. val = cssNormalTransform[ name ];
  12629. }
  12630. // Make numeric if forced or a qualifier was provided and val looks numeric
  12631. if ( extra === "" || extra ) {
  12632. num = parseFloat( val );
  12633. return extra === true || isFinite( num ) ? num || 0 : val;
  12634. }
  12635. return val;
  12636. }
  12637. } );
  12638. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12639. jQuery.cssHooks[ dimension ] = {
  12640. get: function( elem, computed, extra ) {
  12641. if ( computed ) {
  12642. // Certain elements can have dimension info if we invisibly show them
  12643. // but it must have a current display style that would benefit
  12644. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12645. // Support: Safari 8+
  12646. // Table columns in Safari have non-zero offsetWidth & zero
  12647. // getBoundingClientRect().width unless display is changed.
  12648. // Support: IE <=11 only
  12649. // Running getBoundingClientRect on a disconnected node
  12650. // in IE throws an error.
  12651. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12652. swap( elem, cssShow, function() {
  12653. return getWidthOrHeight( elem, dimension, extra );
  12654. } ) :
  12655. getWidthOrHeight( elem, dimension, extra );
  12656. }
  12657. },
  12658. set: function( elem, value, extra ) {
  12659. var matches,
  12660. styles = getStyles( elem ),
  12661. // Only read styles.position if the test has a chance to fail
  12662. // to avoid forcing a reflow.
  12663. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12664. styles.position === "absolute",
  12665. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12666. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12667. isBorderBox = boxSizingNeeded &&
  12668. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12669. subtract = extra ?
  12670. boxModelAdjustment(
  12671. elem,
  12672. dimension,
  12673. extra,
  12674. isBorderBox,
  12675. styles
  12676. ) :
  12677. 0;
  12678. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12679. // faking a content-box to get border and padding (gh-3699)
  12680. if ( isBorderBox && scrollboxSizeBuggy ) {
  12681. subtract -= Math.ceil(
  12682. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12683. parseFloat( styles[ dimension ] ) -
  12684. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12685. 0.5
  12686. );
  12687. }
  12688. // Convert to pixels if value adjustment is needed
  12689. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12690. ( matches[ 3 ] || "px" ) !== "px" ) {
  12691. elem.style[ dimension ] = value;
  12692. value = jQuery.css( elem, dimension );
  12693. }
  12694. return setPositiveNumber( elem, value, subtract );
  12695. }
  12696. };
  12697. } );
  12698. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12699. function( elem, computed ) {
  12700. if ( computed ) {
  12701. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12702. elem.getBoundingClientRect().left -
  12703. swap( elem, { marginLeft: 0 }, function() {
  12704. return elem.getBoundingClientRect().left;
  12705. } )
  12706. ) + "px";
  12707. }
  12708. }
  12709. );
  12710. // These hooks are used by animate to expand properties
  12711. jQuery.each( {
  12712. margin: "",
  12713. padding: "",
  12714. border: "Width"
  12715. }, function( prefix, suffix ) {
  12716. jQuery.cssHooks[ prefix + suffix ] = {
  12717. expand: function( value ) {
  12718. var i = 0,
  12719. expanded = {},
  12720. // Assumes a single number if not a string
  12721. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12722. for ( ; i < 4; i++ ) {
  12723. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12724. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12725. }
  12726. return expanded;
  12727. }
  12728. };
  12729. if ( prefix !== "margin" ) {
  12730. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12731. }
  12732. } );
  12733. jQuery.fn.extend( {
  12734. css: function( name, value ) {
  12735. return access( this, function( elem, name, value ) {
  12736. var styles, len,
  12737. map = {},
  12738. i = 0;
  12739. if ( Array.isArray( name ) ) {
  12740. styles = getStyles( elem );
  12741. len = name.length;
  12742. for ( ; i < len; i++ ) {
  12743. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12744. }
  12745. return map;
  12746. }
  12747. return value !== undefined ?
  12748. jQuery.style( elem, name, value ) :
  12749. jQuery.css( elem, name );
  12750. }, name, value, arguments.length > 1 );
  12751. }
  12752. } );
  12753. function Tween( elem, options, prop, end, easing ) {
  12754. return new Tween.prototype.init( elem, options, prop, end, easing );
  12755. }
  12756. jQuery.Tween = Tween;
  12757. Tween.prototype = {
  12758. constructor: Tween,
  12759. init: function( elem, options, prop, end, easing, unit ) {
  12760. this.elem = elem;
  12761. this.prop = prop;
  12762. this.easing = easing || jQuery.easing._default;
  12763. this.options = options;
  12764. this.start = this.now = this.cur();
  12765. this.end = end;
  12766. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12767. },
  12768. cur: function() {
  12769. var hooks = Tween.propHooks[ this.prop ];
  12770. return hooks && hooks.get ?
  12771. hooks.get( this ) :
  12772. Tween.propHooks._default.get( this );
  12773. },
  12774. run: function( percent ) {
  12775. var eased,
  12776. hooks = Tween.propHooks[ this.prop ];
  12777. if ( this.options.duration ) {
  12778. this.pos = eased = jQuery.easing[ this.easing ](
  12779. percent, this.options.duration * percent, 0, 1, this.options.duration
  12780. );
  12781. } else {
  12782. this.pos = eased = percent;
  12783. }
  12784. this.now = ( this.end - this.start ) * eased + this.start;
  12785. if ( this.options.step ) {
  12786. this.options.step.call( this.elem, this.now, this );
  12787. }
  12788. if ( hooks && hooks.set ) {
  12789. hooks.set( this );
  12790. } else {
  12791. Tween.propHooks._default.set( this );
  12792. }
  12793. return this;
  12794. }
  12795. };
  12796. Tween.prototype.init.prototype = Tween.prototype;
  12797. Tween.propHooks = {
  12798. _default: {
  12799. get: function( tween ) {
  12800. var result;
  12801. // Use a property on the element directly when it is not a DOM element,
  12802. // or when there is no matching style property that exists.
  12803. if ( tween.elem.nodeType !== 1 ||
  12804. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12805. return tween.elem[ tween.prop ];
  12806. }
  12807. // Passing an empty string as a 3rd parameter to .css will automatically
  12808. // attempt a parseFloat and fallback to a string if the parse fails.
  12809. // Simple values such as "10px" are parsed to Float;
  12810. // complex values such as "rotate(1rad)" are returned as-is.
  12811. result = jQuery.css( tween.elem, tween.prop, "" );
  12812. // Empty strings, null, undefined and "auto" are converted to 0.
  12813. return !result || result === "auto" ? 0 : result;
  12814. },
  12815. set: function( tween ) {
  12816. // Use step hook for back compat.
  12817. // Use cssHook if its there.
  12818. // Use .style if available and use plain properties where available.
  12819. if ( jQuery.fx.step[ tween.prop ] ) {
  12820. jQuery.fx.step[ tween.prop ]( tween );
  12821. } else if ( tween.elem.nodeType === 1 && (
  12822. jQuery.cssHooks[ tween.prop ] ||
  12823. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12824. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12825. } else {
  12826. tween.elem[ tween.prop ] = tween.now;
  12827. }
  12828. }
  12829. }
  12830. };
  12831. // Support: IE <=9 only
  12832. // Panic based approach to setting things on disconnected nodes
  12833. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12834. set: function( tween ) {
  12835. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12836. tween.elem[ tween.prop ] = tween.now;
  12837. }
  12838. }
  12839. };
  12840. jQuery.easing = {
  12841. linear: function( p ) {
  12842. return p;
  12843. },
  12844. swing: function( p ) {
  12845. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12846. },
  12847. _default: "swing"
  12848. };
  12849. jQuery.fx = Tween.prototype.init;
  12850. // Back compat <1.8 extension point
  12851. jQuery.fx.step = {};
  12852. var
  12853. fxNow, inProgress,
  12854. rfxtypes = /^(?:toggle|show|hide)$/,
  12855. rrun = /queueHooks$/;
  12856. function schedule() {
  12857. if ( inProgress ) {
  12858. if ( document.hidden === false && window.requestAnimationFrame ) {
  12859. window.requestAnimationFrame( schedule );
  12860. } else {
  12861. window.setTimeout( schedule, jQuery.fx.interval );
  12862. }
  12863. jQuery.fx.tick();
  12864. }
  12865. }
  12866. // Animations created synchronously will run synchronously
  12867. function createFxNow() {
  12868. window.setTimeout( function() {
  12869. fxNow = undefined;
  12870. } );
  12871. return ( fxNow = Date.now() );
  12872. }
  12873. // Generate parameters to create a standard animation
  12874. function genFx( type, includeWidth ) {
  12875. var which,
  12876. i = 0,
  12877. attrs = { height: type };
  12878. // If we include width, step value is 1 to do all cssExpand values,
  12879. // otherwise step value is 2 to skip over Left and Right
  12880. includeWidth = includeWidth ? 1 : 0;
  12881. for ( ; i < 4; i += 2 - includeWidth ) {
  12882. which = cssExpand[ i ];
  12883. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12884. }
  12885. if ( includeWidth ) {
  12886. attrs.opacity = attrs.width = type;
  12887. }
  12888. return attrs;
  12889. }
  12890. function createTween( value, prop, animation ) {
  12891. var tween,
  12892. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12893. index = 0,
  12894. length = collection.length;
  12895. for ( ; index < length; index++ ) {
  12896. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12897. // We're done with this property
  12898. return tween;
  12899. }
  12900. }
  12901. }
  12902. function defaultPrefilter( elem, props, opts ) {
  12903. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12904. isBox = "width" in props || "height" in props,
  12905. anim = this,
  12906. orig = {},
  12907. style = elem.style,
  12908. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12909. dataShow = dataPriv.get( elem, "fxshow" );
  12910. // Queue-skipping animations hijack the fx hooks
  12911. if ( !opts.queue ) {
  12912. hooks = jQuery._queueHooks( elem, "fx" );
  12913. if ( hooks.unqueued == null ) {
  12914. hooks.unqueued = 0;
  12915. oldfire = hooks.empty.fire;
  12916. hooks.empty.fire = function() {
  12917. if ( !hooks.unqueued ) {
  12918. oldfire();
  12919. }
  12920. };
  12921. }
  12922. hooks.unqueued++;
  12923. anim.always( function() {
  12924. // Ensure the complete handler is called before this completes
  12925. anim.always( function() {
  12926. hooks.unqueued--;
  12927. if ( !jQuery.queue( elem, "fx" ).length ) {
  12928. hooks.empty.fire();
  12929. }
  12930. } );
  12931. } );
  12932. }
  12933. // Detect show/hide animations
  12934. for ( prop in props ) {
  12935. value = props[ prop ];
  12936. if ( rfxtypes.test( value ) ) {
  12937. delete props[ prop ];
  12938. toggle = toggle || value === "toggle";
  12939. if ( value === ( hidden ? "hide" : "show" ) ) {
  12940. // Pretend to be hidden if this is a "show" and
  12941. // there is still data from a stopped show/hide
  12942. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12943. hidden = true;
  12944. // Ignore all other no-op show/hide data
  12945. } else {
  12946. continue;
  12947. }
  12948. }
  12949. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12950. }
  12951. }
  12952. // Bail out if this is a no-op like .hide().hide()
  12953. propTween = !jQuery.isEmptyObject( props );
  12954. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12955. return;
  12956. }
  12957. // Restrict "overflow" and "display" styles during box animations
  12958. if ( isBox && elem.nodeType === 1 ) {
  12959. // Support: IE <=9 - 11, Edge 12 - 15
  12960. // Record all 3 overflow attributes because IE does not infer the shorthand
  12961. // from identically-valued overflowX and overflowY and Edge just mirrors
  12962. // the overflowX value there.
  12963. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  12964. // Identify a display type, preferring old show/hide data over the CSS cascade
  12965. restoreDisplay = dataShow && dataShow.display;
  12966. if ( restoreDisplay == null ) {
  12967. restoreDisplay = dataPriv.get( elem, "display" );
  12968. }
  12969. display = jQuery.css( elem, "display" );
  12970. if ( display === "none" ) {
  12971. if ( restoreDisplay ) {
  12972. display = restoreDisplay;
  12973. } else {
  12974. // Get nonempty value(s) by temporarily forcing visibility
  12975. showHide( [ elem ], true );
  12976. restoreDisplay = elem.style.display || restoreDisplay;
  12977. display = jQuery.css( elem, "display" );
  12978. showHide( [ elem ] );
  12979. }
  12980. }
  12981. // Animate inline elements as inline-block
  12982. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  12983. if ( jQuery.css( elem, "float" ) === "none" ) {
  12984. // Restore the original display value at the end of pure show/hide animations
  12985. if ( !propTween ) {
  12986. anim.done( function() {
  12987. style.display = restoreDisplay;
  12988. } );
  12989. if ( restoreDisplay == null ) {
  12990. display = style.display;
  12991. restoreDisplay = display === "none" ? "" : display;
  12992. }
  12993. }
  12994. style.display = "inline-block";
  12995. }
  12996. }
  12997. }
  12998. if ( opts.overflow ) {
  12999. style.overflow = "hidden";
  13000. anim.always( function() {
  13001. style.overflow = opts.overflow[ 0 ];
  13002. style.overflowX = opts.overflow[ 1 ];
  13003. style.overflowY = opts.overflow[ 2 ];
  13004. } );
  13005. }
  13006. // Implement show/hide animations
  13007. propTween = false;
  13008. for ( prop in orig ) {
  13009. // General show/hide setup for this element animation
  13010. if ( !propTween ) {
  13011. if ( dataShow ) {
  13012. if ( "hidden" in dataShow ) {
  13013. hidden = dataShow.hidden;
  13014. }
  13015. } else {
  13016. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13017. }
  13018. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13019. if ( toggle ) {
  13020. dataShow.hidden = !hidden;
  13021. }
  13022. // Show elements before animating them
  13023. if ( hidden ) {
  13024. showHide( [ elem ], true );
  13025. }
  13026. /* eslint-disable no-loop-func */
  13027. anim.done( function() {
  13028. /* eslint-enable no-loop-func */
  13029. // The final step of a "hide" animation is actually hiding the element
  13030. if ( !hidden ) {
  13031. showHide( [ elem ] );
  13032. }
  13033. dataPriv.remove( elem, "fxshow" );
  13034. for ( prop in orig ) {
  13035. jQuery.style( elem, prop, orig[ prop ] );
  13036. }
  13037. } );
  13038. }
  13039. // Per-property setup
  13040. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13041. if ( !( prop in dataShow ) ) {
  13042. dataShow[ prop ] = propTween.start;
  13043. if ( hidden ) {
  13044. propTween.end = propTween.start;
  13045. propTween.start = 0;
  13046. }
  13047. }
  13048. }
  13049. }
  13050. function propFilter( props, specialEasing ) {
  13051. var index, name, easing, value, hooks;
  13052. // camelCase, specialEasing and expand cssHook pass
  13053. for ( index in props ) {
  13054. name = camelCase( index );
  13055. easing = specialEasing[ name ];
  13056. value = props[ index ];
  13057. if ( Array.isArray( value ) ) {
  13058. easing = value[ 1 ];
  13059. value = props[ index ] = value[ 0 ];
  13060. }
  13061. if ( index !== name ) {
  13062. props[ name ] = value;
  13063. delete props[ index ];
  13064. }
  13065. hooks = jQuery.cssHooks[ name ];
  13066. if ( hooks && "expand" in hooks ) {
  13067. value = hooks.expand( value );
  13068. delete props[ name ];
  13069. // Not quite $.extend, this won't overwrite existing keys.
  13070. // Reusing 'index' because we have the correct "name"
  13071. for ( index in value ) {
  13072. if ( !( index in props ) ) {
  13073. props[ index ] = value[ index ];
  13074. specialEasing[ index ] = easing;
  13075. }
  13076. }
  13077. } else {
  13078. specialEasing[ name ] = easing;
  13079. }
  13080. }
  13081. }
  13082. function Animation( elem, properties, options ) {
  13083. var result,
  13084. stopped,
  13085. index = 0,
  13086. length = Animation.prefilters.length,
  13087. deferred = jQuery.Deferred().always( function() {
  13088. // Don't match elem in the :animated selector
  13089. delete tick.elem;
  13090. } ),
  13091. tick = function() {
  13092. if ( stopped ) {
  13093. return false;
  13094. }
  13095. var currentTime = fxNow || createFxNow(),
  13096. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13097. // Support: Android 2.3 only
  13098. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13099. temp = remaining / animation.duration || 0,
  13100. percent = 1 - temp,
  13101. index = 0,
  13102. length = animation.tweens.length;
  13103. for ( ; index < length; index++ ) {
  13104. animation.tweens[ index ].run( percent );
  13105. }
  13106. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13107. // If there's more to do, yield
  13108. if ( percent < 1 && length ) {
  13109. return remaining;
  13110. }
  13111. // If this was an empty animation, synthesize a final progress notification
  13112. if ( !length ) {
  13113. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13114. }
  13115. // Resolve the animation and report its conclusion
  13116. deferred.resolveWith( elem, [ animation ] );
  13117. return false;
  13118. },
  13119. animation = deferred.promise( {
  13120. elem: elem,
  13121. props: jQuery.extend( {}, properties ),
  13122. opts: jQuery.extend( true, {
  13123. specialEasing: {},
  13124. easing: jQuery.easing._default
  13125. }, options ),
  13126. originalProperties: properties,
  13127. originalOptions: options,
  13128. startTime: fxNow || createFxNow(),
  13129. duration: options.duration,
  13130. tweens: [],
  13131. createTween: function( prop, end ) {
  13132. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13133. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13134. animation.tweens.push( tween );
  13135. return tween;
  13136. },
  13137. stop: function( gotoEnd ) {
  13138. var index = 0,
  13139. // If we are going to the end, we want to run all the tweens
  13140. // otherwise we skip this part
  13141. length = gotoEnd ? animation.tweens.length : 0;
  13142. if ( stopped ) {
  13143. return this;
  13144. }
  13145. stopped = true;
  13146. for ( ; index < length; index++ ) {
  13147. animation.tweens[ index ].run( 1 );
  13148. }
  13149. // Resolve when we played the last frame; otherwise, reject
  13150. if ( gotoEnd ) {
  13151. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13152. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13153. } else {
  13154. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13155. }
  13156. return this;
  13157. }
  13158. } ),
  13159. props = animation.props;
  13160. propFilter( props, animation.opts.specialEasing );
  13161. for ( ; index < length; index++ ) {
  13162. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13163. if ( result ) {
  13164. if ( isFunction( result.stop ) ) {
  13165. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13166. result.stop.bind( result );
  13167. }
  13168. return result;
  13169. }
  13170. }
  13171. jQuery.map( props, createTween, animation );
  13172. if ( isFunction( animation.opts.start ) ) {
  13173. animation.opts.start.call( elem, animation );
  13174. }
  13175. // Attach callbacks from options
  13176. animation
  13177. .progress( animation.opts.progress )
  13178. .done( animation.opts.done, animation.opts.complete )
  13179. .fail( animation.opts.fail )
  13180. .always( animation.opts.always );
  13181. jQuery.fx.timer(
  13182. jQuery.extend( tick, {
  13183. elem: elem,
  13184. anim: animation,
  13185. queue: animation.opts.queue
  13186. } )
  13187. );
  13188. return animation;
  13189. }
  13190. jQuery.Animation = jQuery.extend( Animation, {
  13191. tweeners: {
  13192. "*": [ function( prop, value ) {
  13193. var tween = this.createTween( prop, value );
  13194. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13195. return tween;
  13196. } ]
  13197. },
  13198. tweener: function( props, callback ) {
  13199. if ( isFunction( props ) ) {
  13200. callback = props;
  13201. props = [ "*" ];
  13202. } else {
  13203. props = props.match( rnothtmlwhite );
  13204. }
  13205. var prop,
  13206. index = 0,
  13207. length = props.length;
  13208. for ( ; index < length; index++ ) {
  13209. prop = props[ index ];
  13210. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13211. Animation.tweeners[ prop ].unshift( callback );
  13212. }
  13213. },
  13214. prefilters: [ defaultPrefilter ],
  13215. prefilter: function( callback, prepend ) {
  13216. if ( prepend ) {
  13217. Animation.prefilters.unshift( callback );
  13218. } else {
  13219. Animation.prefilters.push( callback );
  13220. }
  13221. }
  13222. } );
  13223. jQuery.speed = function( speed, easing, fn ) {
  13224. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13225. complete: fn || !fn && easing ||
  13226. isFunction( speed ) && speed,
  13227. duration: speed,
  13228. easing: fn && easing || easing && !isFunction( easing ) && easing
  13229. };
  13230. // Go to the end state if fx are off
  13231. if ( jQuery.fx.off ) {
  13232. opt.duration = 0;
  13233. } else {
  13234. if ( typeof opt.duration !== "number" ) {
  13235. if ( opt.duration in jQuery.fx.speeds ) {
  13236. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13237. } else {
  13238. opt.duration = jQuery.fx.speeds._default;
  13239. }
  13240. }
  13241. }
  13242. // Normalize opt.queue - true/undefined/null -> "fx"
  13243. if ( opt.queue == null || opt.queue === true ) {
  13244. opt.queue = "fx";
  13245. }
  13246. // Queueing
  13247. opt.old = opt.complete;
  13248. opt.complete = function() {
  13249. if ( isFunction( opt.old ) ) {
  13250. opt.old.call( this );
  13251. }
  13252. if ( opt.queue ) {
  13253. jQuery.dequeue( this, opt.queue );
  13254. }
  13255. };
  13256. return opt;
  13257. };
  13258. jQuery.fn.extend( {
  13259. fadeTo: function( speed, to, easing, callback ) {
  13260. // Show any hidden elements after setting opacity to 0
  13261. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13262. // Animate to the value specified
  13263. .end().animate( { opacity: to }, speed, easing, callback );
  13264. },
  13265. animate: function( prop, speed, easing, callback ) {
  13266. var empty = jQuery.isEmptyObject( prop ),
  13267. optall = jQuery.speed( speed, easing, callback ),
  13268. doAnimation = function() {
  13269. // Operate on a copy of prop so per-property easing won't be lost
  13270. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13271. // Empty animations, or finishing resolves immediately
  13272. if ( empty || dataPriv.get( this, "finish" ) ) {
  13273. anim.stop( true );
  13274. }
  13275. };
  13276. doAnimation.finish = doAnimation;
  13277. return empty || optall.queue === false ?
  13278. this.each( doAnimation ) :
  13279. this.queue( optall.queue, doAnimation );
  13280. },
  13281. stop: function( type, clearQueue, gotoEnd ) {
  13282. var stopQueue = function( hooks ) {
  13283. var stop = hooks.stop;
  13284. delete hooks.stop;
  13285. stop( gotoEnd );
  13286. };
  13287. if ( typeof type !== "string" ) {
  13288. gotoEnd = clearQueue;
  13289. clearQueue = type;
  13290. type = undefined;
  13291. }
  13292. if ( clearQueue && type !== false ) {
  13293. this.queue( type || "fx", [] );
  13294. }
  13295. return this.each( function() {
  13296. var dequeue = true,
  13297. index = type != null && type + "queueHooks",
  13298. timers = jQuery.timers,
  13299. data = dataPriv.get( this );
  13300. if ( index ) {
  13301. if ( data[ index ] && data[ index ].stop ) {
  13302. stopQueue( data[ index ] );
  13303. }
  13304. } else {
  13305. for ( index in data ) {
  13306. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13307. stopQueue( data[ index ] );
  13308. }
  13309. }
  13310. }
  13311. for ( index = timers.length; index--; ) {
  13312. if ( timers[ index ].elem === this &&
  13313. ( type == null || timers[ index ].queue === type ) ) {
  13314. timers[ index ].anim.stop( gotoEnd );
  13315. dequeue = false;
  13316. timers.splice( index, 1 );
  13317. }
  13318. }
  13319. // Start the next in the queue if the last step wasn't forced.
  13320. // Timers currently will call their complete callbacks, which
  13321. // will dequeue but only if they were gotoEnd.
  13322. if ( dequeue || !gotoEnd ) {
  13323. jQuery.dequeue( this, type );
  13324. }
  13325. } );
  13326. },
  13327. finish: function( type ) {
  13328. if ( type !== false ) {
  13329. type = type || "fx";
  13330. }
  13331. return this.each( function() {
  13332. var index,
  13333. data = dataPriv.get( this ),
  13334. queue = data[ type + "queue" ],
  13335. hooks = data[ type + "queueHooks" ],
  13336. timers = jQuery.timers,
  13337. length = queue ? queue.length : 0;
  13338. // Enable finishing flag on private data
  13339. data.finish = true;
  13340. // Empty the queue first
  13341. jQuery.queue( this, type, [] );
  13342. if ( hooks && hooks.stop ) {
  13343. hooks.stop.call( this, true );
  13344. }
  13345. // Look for any active animations, and finish them
  13346. for ( index = timers.length; index--; ) {
  13347. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13348. timers[ index ].anim.stop( true );
  13349. timers.splice( index, 1 );
  13350. }
  13351. }
  13352. // Look for any animations in the old queue and finish them
  13353. for ( index = 0; index < length; index++ ) {
  13354. if ( queue[ index ] && queue[ index ].finish ) {
  13355. queue[ index ].finish.call( this );
  13356. }
  13357. }
  13358. // Turn off finishing flag
  13359. delete data.finish;
  13360. } );
  13361. }
  13362. } );
  13363. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13364. var cssFn = jQuery.fn[ name ];
  13365. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13366. return speed == null || typeof speed === "boolean" ?
  13367. cssFn.apply( this, arguments ) :
  13368. this.animate( genFx( name, true ), speed, easing, callback );
  13369. };
  13370. } );
  13371. // Generate shortcuts for custom animations
  13372. jQuery.each( {
  13373. slideDown: genFx( "show" ),
  13374. slideUp: genFx( "hide" ),
  13375. slideToggle: genFx( "toggle" ),
  13376. fadeIn: { opacity: "show" },
  13377. fadeOut: { opacity: "hide" },
  13378. fadeToggle: { opacity: "toggle" }
  13379. }, function( name, props ) {
  13380. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13381. return this.animate( props, speed, easing, callback );
  13382. };
  13383. } );
  13384. jQuery.timers = [];
  13385. jQuery.fx.tick = function() {
  13386. var timer,
  13387. i = 0,
  13388. timers = jQuery.timers;
  13389. fxNow = Date.now();
  13390. for ( ; i < timers.length; i++ ) {
  13391. timer = timers[ i ];
  13392. // Run the timer and safely remove it when done (allowing for external removal)
  13393. if ( !timer() && timers[ i ] === timer ) {
  13394. timers.splice( i--, 1 );
  13395. }
  13396. }
  13397. if ( !timers.length ) {
  13398. jQuery.fx.stop();
  13399. }
  13400. fxNow = undefined;
  13401. };
  13402. jQuery.fx.timer = function( timer ) {
  13403. jQuery.timers.push( timer );
  13404. jQuery.fx.start();
  13405. };
  13406. jQuery.fx.interval = 13;
  13407. jQuery.fx.start = function() {
  13408. if ( inProgress ) {
  13409. return;
  13410. }
  13411. inProgress = true;
  13412. schedule();
  13413. };
  13414. jQuery.fx.stop = function() {
  13415. inProgress = null;
  13416. };
  13417. jQuery.fx.speeds = {
  13418. slow: 600,
  13419. fast: 200,
  13420. // Default speed
  13421. _default: 400
  13422. };
  13423. // Based off of the plugin by Clint Helfers, with permission.
  13424. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13425. jQuery.fn.delay = function( time, type ) {
  13426. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13427. type = type || "fx";
  13428. return this.queue( type, function( next, hooks ) {
  13429. var timeout = window.setTimeout( next, time );
  13430. hooks.stop = function() {
  13431. window.clearTimeout( timeout );
  13432. };
  13433. } );
  13434. };
  13435. ( function() {
  13436. var input = document.createElement( "input" ),
  13437. select = document.createElement( "select" ),
  13438. opt = select.appendChild( document.createElement( "option" ) );
  13439. input.type = "checkbox";
  13440. // Support: Android <=4.3 only
  13441. // Default value for a checkbox should be "on"
  13442. support.checkOn = input.value !== "";
  13443. // Support: IE <=11 only
  13444. // Must access selectedIndex to make default options select
  13445. support.optSelected = opt.selected;
  13446. // Support: IE <=11 only
  13447. // An input loses its value after becoming a radio
  13448. input = document.createElement( "input" );
  13449. input.value = "t";
  13450. input.type = "radio";
  13451. support.radioValue = input.value === "t";
  13452. } )();
  13453. var boolHook,
  13454. attrHandle = jQuery.expr.attrHandle;
  13455. jQuery.fn.extend( {
  13456. attr: function( name, value ) {
  13457. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13458. },
  13459. removeAttr: function( name ) {
  13460. return this.each( function() {
  13461. jQuery.removeAttr( this, name );
  13462. } );
  13463. }
  13464. } );
  13465. jQuery.extend( {
  13466. attr: function( elem, name, value ) {
  13467. var ret, hooks,
  13468. nType = elem.nodeType;
  13469. // Don't get/set attributes on text, comment and attribute nodes
  13470. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13471. return;
  13472. }
  13473. // Fallback to prop when attributes are not supported
  13474. if ( typeof elem.getAttribute === "undefined" ) {
  13475. return jQuery.prop( elem, name, value );
  13476. }
  13477. // Attribute hooks are determined by the lowercase version
  13478. // Grab necessary hook if one is defined
  13479. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13480. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13481. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13482. }
  13483. if ( value !== undefined ) {
  13484. if ( value === null ) {
  13485. jQuery.removeAttr( elem, name );
  13486. return;
  13487. }
  13488. if ( hooks && "set" in hooks &&
  13489. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13490. return ret;
  13491. }
  13492. elem.setAttribute( name, value + "" );
  13493. return value;
  13494. }
  13495. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13496. return ret;
  13497. }
  13498. ret = jQuery.find.attr( elem, name );
  13499. // Non-existent attributes return null, we normalize to undefined
  13500. return ret == null ? undefined : ret;
  13501. },
  13502. attrHooks: {
  13503. type: {
  13504. set: function( elem, value ) {
  13505. if ( !support.radioValue && value === "radio" &&
  13506. nodeName( elem, "input" ) ) {
  13507. var val = elem.value;
  13508. elem.setAttribute( "type", value );
  13509. if ( val ) {
  13510. elem.value = val;
  13511. }
  13512. return value;
  13513. }
  13514. }
  13515. }
  13516. },
  13517. removeAttr: function( elem, value ) {
  13518. var name,
  13519. i = 0,
  13520. // Attribute names can contain non-HTML whitespace characters
  13521. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13522. attrNames = value && value.match( rnothtmlwhite );
  13523. if ( attrNames && elem.nodeType === 1 ) {
  13524. while ( ( name = attrNames[ i++ ] ) ) {
  13525. elem.removeAttribute( name );
  13526. }
  13527. }
  13528. }
  13529. } );
  13530. // Hooks for boolean attributes
  13531. boolHook = {
  13532. set: function( elem, value, name ) {
  13533. if ( value === false ) {
  13534. // Remove boolean attributes when set to false
  13535. jQuery.removeAttr( elem, name );
  13536. } else {
  13537. elem.setAttribute( name, name );
  13538. }
  13539. return name;
  13540. }
  13541. };
  13542. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13543. var getter = attrHandle[ name ] || jQuery.find.attr;
  13544. attrHandle[ name ] = function( elem, name, isXML ) {
  13545. var ret, handle,
  13546. lowercaseName = name.toLowerCase();
  13547. if ( !isXML ) {
  13548. // Avoid an infinite loop by temporarily removing this function from the getter
  13549. handle = attrHandle[ lowercaseName ];
  13550. attrHandle[ lowercaseName ] = ret;
  13551. ret = getter( elem, name, isXML ) != null ?
  13552. lowercaseName :
  13553. null;
  13554. attrHandle[ lowercaseName ] = handle;
  13555. }
  13556. return ret;
  13557. };
  13558. } );
  13559. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13560. rclickable = /^(?:a|area)$/i;
  13561. jQuery.fn.extend( {
  13562. prop: function( name, value ) {
  13563. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13564. },
  13565. removeProp: function( name ) {
  13566. return this.each( function() {
  13567. delete this[ jQuery.propFix[ name ] || name ];
  13568. } );
  13569. }
  13570. } );
  13571. jQuery.extend( {
  13572. prop: function( elem, name, value ) {
  13573. var ret, hooks,
  13574. nType = elem.nodeType;
  13575. // Don't get/set properties on text, comment and attribute nodes
  13576. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13577. return;
  13578. }
  13579. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13580. // Fix name and attach hooks
  13581. name = jQuery.propFix[ name ] || name;
  13582. hooks = jQuery.propHooks[ name ];
  13583. }
  13584. if ( value !== undefined ) {
  13585. if ( hooks && "set" in hooks &&
  13586. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13587. return ret;
  13588. }
  13589. return ( elem[ name ] = value );
  13590. }
  13591. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13592. return ret;
  13593. }
  13594. return elem[ name ];
  13595. },
  13596. propHooks: {
  13597. tabIndex: {
  13598. get: function( elem ) {
  13599. // Support: IE <=9 - 11 only
  13600. // elem.tabIndex doesn't always return the
  13601. // correct value when it hasn't been explicitly set
  13602. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13603. // Use proper attribute retrieval(#12072)
  13604. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13605. if ( tabindex ) {
  13606. return parseInt( tabindex, 10 );
  13607. }
  13608. if (
  13609. rfocusable.test( elem.nodeName ) ||
  13610. rclickable.test( elem.nodeName ) &&
  13611. elem.href
  13612. ) {
  13613. return 0;
  13614. }
  13615. return -1;
  13616. }
  13617. }
  13618. },
  13619. propFix: {
  13620. "for": "htmlFor",
  13621. "class": "className"
  13622. }
  13623. } );
  13624. // Support: IE <=11 only
  13625. // Accessing the selectedIndex property
  13626. // forces the browser to respect setting selected
  13627. // on the option
  13628. // The getter ensures a default option is selected
  13629. // when in an optgroup
  13630. // eslint rule "no-unused-expressions" is disabled for this code
  13631. // since it considers such accessions noop
  13632. if ( !support.optSelected ) {
  13633. jQuery.propHooks.selected = {
  13634. get: function( elem ) {
  13635. /* eslint no-unused-expressions: "off" */
  13636. var parent = elem.parentNode;
  13637. if ( parent && parent.parentNode ) {
  13638. parent.parentNode.selectedIndex;
  13639. }
  13640. return null;
  13641. },
  13642. set: function( elem ) {
  13643. /* eslint no-unused-expressions: "off" */
  13644. var parent = elem.parentNode;
  13645. if ( parent ) {
  13646. parent.selectedIndex;
  13647. if ( parent.parentNode ) {
  13648. parent.parentNode.selectedIndex;
  13649. }
  13650. }
  13651. }
  13652. };
  13653. }
  13654. jQuery.each( [
  13655. "tabIndex",
  13656. "readOnly",
  13657. "maxLength",
  13658. "cellSpacing",
  13659. "cellPadding",
  13660. "rowSpan",
  13661. "colSpan",
  13662. "useMap",
  13663. "frameBorder",
  13664. "contentEditable"
  13665. ], function() {
  13666. jQuery.propFix[ this.toLowerCase() ] = this;
  13667. } );
  13668. // Strip and collapse whitespace according to HTML spec
  13669. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13670. function stripAndCollapse( value ) {
  13671. var tokens = value.match( rnothtmlwhite ) || [];
  13672. return tokens.join( " " );
  13673. }
  13674. function getClass( elem ) {
  13675. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13676. }
  13677. function classesToArray( value ) {
  13678. if ( Array.isArray( value ) ) {
  13679. return value;
  13680. }
  13681. if ( typeof value === "string" ) {
  13682. return value.match( rnothtmlwhite ) || [];
  13683. }
  13684. return [];
  13685. }
  13686. jQuery.fn.extend( {
  13687. addClass: function( value ) {
  13688. var classes, elem, cur, curValue, clazz, j, finalValue,
  13689. i = 0;
  13690. if ( isFunction( value ) ) {
  13691. return this.each( function( j ) {
  13692. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13693. } );
  13694. }
  13695. classes = classesToArray( value );
  13696. if ( classes.length ) {
  13697. while ( ( elem = this[ i++ ] ) ) {
  13698. curValue = getClass( elem );
  13699. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13700. if ( cur ) {
  13701. j = 0;
  13702. while ( ( clazz = classes[ j++ ] ) ) {
  13703. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13704. cur += clazz + " ";
  13705. }
  13706. }
  13707. // Only assign if different to avoid unneeded rendering.
  13708. finalValue = stripAndCollapse( cur );
  13709. if ( curValue !== finalValue ) {
  13710. elem.setAttribute( "class", finalValue );
  13711. }
  13712. }
  13713. }
  13714. }
  13715. return this;
  13716. },
  13717. removeClass: function( value ) {
  13718. var classes, elem, cur, curValue, clazz, j, finalValue,
  13719. i = 0;
  13720. if ( isFunction( value ) ) {
  13721. return this.each( function( j ) {
  13722. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13723. } );
  13724. }
  13725. if ( !arguments.length ) {
  13726. return this.attr( "class", "" );
  13727. }
  13728. classes = classesToArray( value );
  13729. if ( classes.length ) {
  13730. while ( ( elem = this[ i++ ] ) ) {
  13731. curValue = getClass( elem );
  13732. // This expression is here for better compressibility (see addClass)
  13733. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13734. if ( cur ) {
  13735. j = 0;
  13736. while ( ( clazz = classes[ j++ ] ) ) {
  13737. // Remove *all* instances
  13738. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13739. cur = cur.replace( " " + clazz + " ", " " );
  13740. }
  13741. }
  13742. // Only assign if different to avoid unneeded rendering.
  13743. finalValue = stripAndCollapse( cur );
  13744. if ( curValue !== finalValue ) {
  13745. elem.setAttribute( "class", finalValue );
  13746. }
  13747. }
  13748. }
  13749. }
  13750. return this;
  13751. },
  13752. toggleClass: function( value, stateVal ) {
  13753. var type = typeof value,
  13754. isValidValue = type === "string" || Array.isArray( value );
  13755. if ( typeof stateVal === "boolean" && isValidValue ) {
  13756. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13757. }
  13758. if ( isFunction( value ) ) {
  13759. return this.each( function( i ) {
  13760. jQuery( this ).toggleClass(
  13761. value.call( this, i, getClass( this ), stateVal ),
  13762. stateVal
  13763. );
  13764. } );
  13765. }
  13766. return this.each( function() {
  13767. var className, i, self, classNames;
  13768. if ( isValidValue ) {
  13769. // Toggle individual class names
  13770. i = 0;
  13771. self = jQuery( this );
  13772. classNames = classesToArray( value );
  13773. while ( ( className = classNames[ i++ ] ) ) {
  13774. // Check each className given, space separated list
  13775. if ( self.hasClass( className ) ) {
  13776. self.removeClass( className );
  13777. } else {
  13778. self.addClass( className );
  13779. }
  13780. }
  13781. // Toggle whole class name
  13782. } else if ( value === undefined || type === "boolean" ) {
  13783. className = getClass( this );
  13784. if ( className ) {
  13785. // Store className if set
  13786. dataPriv.set( this, "__className__", className );
  13787. }
  13788. // If the element has a class name or if we're passed `false`,
  13789. // then remove the whole classname (if there was one, the above saved it).
  13790. // Otherwise bring back whatever was previously saved (if anything),
  13791. // falling back to the empty string if nothing was stored.
  13792. if ( this.setAttribute ) {
  13793. this.setAttribute( "class",
  13794. className || value === false ?
  13795. "" :
  13796. dataPriv.get( this, "__className__" ) || ""
  13797. );
  13798. }
  13799. }
  13800. } );
  13801. },
  13802. hasClass: function( selector ) {
  13803. var className, elem,
  13804. i = 0;
  13805. className = " " + selector + " ";
  13806. while ( ( elem = this[ i++ ] ) ) {
  13807. if ( elem.nodeType === 1 &&
  13808. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13809. return true;
  13810. }
  13811. }
  13812. return false;
  13813. }
  13814. } );
  13815. var rreturn = /\r/g;
  13816. jQuery.fn.extend( {
  13817. val: function( value ) {
  13818. var hooks, ret, valueIsFunction,
  13819. elem = this[ 0 ];
  13820. if ( !arguments.length ) {
  13821. if ( elem ) {
  13822. hooks = jQuery.valHooks[ elem.type ] ||
  13823. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13824. if ( hooks &&
  13825. "get" in hooks &&
  13826. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13827. ) {
  13828. return ret;
  13829. }
  13830. ret = elem.value;
  13831. // Handle most common string cases
  13832. if ( typeof ret === "string" ) {
  13833. return ret.replace( rreturn, "" );
  13834. }
  13835. // Handle cases where value is null/undef or number
  13836. return ret == null ? "" : ret;
  13837. }
  13838. return;
  13839. }
  13840. valueIsFunction = isFunction( value );
  13841. return this.each( function( i ) {
  13842. var val;
  13843. if ( this.nodeType !== 1 ) {
  13844. return;
  13845. }
  13846. if ( valueIsFunction ) {
  13847. val = value.call( this, i, jQuery( this ).val() );
  13848. } else {
  13849. val = value;
  13850. }
  13851. // Treat null/undefined as ""; convert numbers to string
  13852. if ( val == null ) {
  13853. val = "";
  13854. } else if ( typeof val === "number" ) {
  13855. val += "";
  13856. } else if ( Array.isArray( val ) ) {
  13857. val = jQuery.map( val, function( value ) {
  13858. return value == null ? "" : value + "";
  13859. } );
  13860. }
  13861. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13862. // If set returns undefined, fall back to normal setting
  13863. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13864. this.value = val;
  13865. }
  13866. } );
  13867. }
  13868. } );
  13869. jQuery.extend( {
  13870. valHooks: {
  13871. option: {
  13872. get: function( elem ) {
  13873. var val = jQuery.find.attr( elem, "value" );
  13874. return val != null ?
  13875. val :
  13876. // Support: IE <=10 - 11 only
  13877. // option.text throws exceptions (#14686, #14858)
  13878. // Strip and collapse whitespace
  13879. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13880. stripAndCollapse( jQuery.text( elem ) );
  13881. }
  13882. },
  13883. select: {
  13884. get: function( elem ) {
  13885. var value, option, i,
  13886. options = elem.options,
  13887. index = elem.selectedIndex,
  13888. one = elem.type === "select-one",
  13889. values = one ? null : [],
  13890. max = one ? index + 1 : options.length;
  13891. if ( index < 0 ) {
  13892. i = max;
  13893. } else {
  13894. i = one ? index : 0;
  13895. }
  13896. // Loop through all the selected options
  13897. for ( ; i < max; i++ ) {
  13898. option = options[ i ];
  13899. // Support: IE <=9 only
  13900. // IE8-9 doesn't update selected after form reset (#2551)
  13901. if ( ( option.selected || i === index ) &&
  13902. // Don't return options that are disabled or in a disabled optgroup
  13903. !option.disabled &&
  13904. ( !option.parentNode.disabled ||
  13905. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13906. // Get the specific value for the option
  13907. value = jQuery( option ).val();
  13908. // We don't need an array for one selects
  13909. if ( one ) {
  13910. return value;
  13911. }
  13912. // Multi-Selects return an array
  13913. values.push( value );
  13914. }
  13915. }
  13916. return values;
  13917. },
  13918. set: function( elem, value ) {
  13919. var optionSet, option,
  13920. options = elem.options,
  13921. values = jQuery.makeArray( value ),
  13922. i = options.length;
  13923. while ( i-- ) {
  13924. option = options[ i ];
  13925. /* eslint-disable no-cond-assign */
  13926. if ( option.selected =
  13927. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13928. ) {
  13929. optionSet = true;
  13930. }
  13931. /* eslint-enable no-cond-assign */
  13932. }
  13933. // Force browsers to behave consistently when non-matching value is set
  13934. if ( !optionSet ) {
  13935. elem.selectedIndex = -1;
  13936. }
  13937. return values;
  13938. }
  13939. }
  13940. }
  13941. } );
  13942. // Radios and checkboxes getter/setter
  13943. jQuery.each( [ "radio", "checkbox" ], function() {
  13944. jQuery.valHooks[ this ] = {
  13945. set: function( elem, value ) {
  13946. if ( Array.isArray( value ) ) {
  13947. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13948. }
  13949. }
  13950. };
  13951. if ( !support.checkOn ) {
  13952. jQuery.valHooks[ this ].get = function( elem ) {
  13953. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13954. };
  13955. }
  13956. } );
  13957. // Return jQuery for attributes-only inclusion
  13958. support.focusin = "onfocusin" in window;
  13959. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  13960. stopPropagationCallback = function( e ) {
  13961. e.stopPropagation();
  13962. };
  13963. jQuery.extend( jQuery.event, {
  13964. trigger: function( event, data, elem, onlyHandlers ) {
  13965. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  13966. eventPath = [ elem || document ],
  13967. type = hasOwn.call( event, "type" ) ? event.type : event,
  13968. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  13969. cur = lastElement = tmp = elem = elem || document;
  13970. // Don't do events on text and comment nodes
  13971. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  13972. return;
  13973. }
  13974. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  13975. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  13976. return;
  13977. }
  13978. if ( type.indexOf( "." ) > -1 ) {
  13979. // Namespaced trigger; create a regexp to match event type in handle()
  13980. namespaces = type.split( "." );
  13981. type = namespaces.shift();
  13982. namespaces.sort();
  13983. }
  13984. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  13985. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  13986. event = event[ jQuery.expando ] ?
  13987. event :
  13988. new jQuery.Event( type, typeof event === "object" && event );
  13989. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  13990. event.isTrigger = onlyHandlers ? 2 : 3;
  13991. event.namespace = namespaces.join( "." );
  13992. event.rnamespace = event.namespace ?
  13993. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  13994. null;
  13995. // Clean up the event in case it is being reused
  13996. event.result = undefined;
  13997. if ( !event.target ) {
  13998. event.target = elem;
  13999. }
  14000. // Clone any incoming data and prepend the event, creating the handler arg list
  14001. data = data == null ?
  14002. [ event ] :
  14003. jQuery.makeArray( data, [ event ] );
  14004. // Allow special events to draw outside the lines
  14005. special = jQuery.event.special[ type ] || {};
  14006. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14007. return;
  14008. }
  14009. // Determine event propagation path in advance, per W3C events spec (#9951)
  14010. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14011. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14012. bubbleType = special.delegateType || type;
  14013. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14014. cur = cur.parentNode;
  14015. }
  14016. for ( ; cur; cur = cur.parentNode ) {
  14017. eventPath.push( cur );
  14018. tmp = cur;
  14019. }
  14020. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14021. if ( tmp === ( elem.ownerDocument || document ) ) {
  14022. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14023. }
  14024. }
  14025. // Fire handlers on the event path
  14026. i = 0;
  14027. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14028. lastElement = cur;
  14029. event.type = i > 1 ?
  14030. bubbleType :
  14031. special.bindType || type;
  14032. // jQuery handler
  14033. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14034. dataPriv.get( cur, "handle" );
  14035. if ( handle ) {
  14036. handle.apply( cur, data );
  14037. }
  14038. // Native handler
  14039. handle = ontype && cur[ ontype ];
  14040. if ( handle && handle.apply && acceptData( cur ) ) {
  14041. event.result = handle.apply( cur, data );
  14042. if ( event.result === false ) {
  14043. event.preventDefault();
  14044. }
  14045. }
  14046. }
  14047. event.type = type;
  14048. // If nobody prevented the default action, do it now
  14049. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14050. if ( ( !special._default ||
  14051. special._default.apply( eventPath.pop(), data ) === false ) &&
  14052. acceptData( elem ) ) {
  14053. // Call a native DOM method on the target with the same name as the event.
  14054. // Don't do default actions on window, that's where global variables be (#6170)
  14055. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14056. // Don't re-trigger an onFOO event when we call its FOO() method
  14057. tmp = elem[ ontype ];
  14058. if ( tmp ) {
  14059. elem[ ontype ] = null;
  14060. }
  14061. // Prevent re-triggering of the same event, since we already bubbled it above
  14062. jQuery.event.triggered = type;
  14063. if ( event.isPropagationStopped() ) {
  14064. lastElement.addEventListener( type, stopPropagationCallback );
  14065. }
  14066. elem[ type ]();
  14067. if ( event.isPropagationStopped() ) {
  14068. lastElement.removeEventListener( type, stopPropagationCallback );
  14069. }
  14070. jQuery.event.triggered = undefined;
  14071. if ( tmp ) {
  14072. elem[ ontype ] = tmp;
  14073. }
  14074. }
  14075. }
  14076. }
  14077. return event.result;
  14078. },
  14079. // Piggyback on a donor event to simulate a different one
  14080. // Used only for `focus(in | out)` events
  14081. simulate: function( type, elem, event ) {
  14082. var e = jQuery.extend(
  14083. new jQuery.Event(),
  14084. event,
  14085. {
  14086. type: type,
  14087. isSimulated: true
  14088. }
  14089. );
  14090. jQuery.event.trigger( e, null, elem );
  14091. }
  14092. } );
  14093. jQuery.fn.extend( {
  14094. trigger: function( type, data ) {
  14095. return this.each( function() {
  14096. jQuery.event.trigger( type, data, this );
  14097. } );
  14098. },
  14099. triggerHandler: function( type, data ) {
  14100. var elem = this[ 0 ];
  14101. if ( elem ) {
  14102. return jQuery.event.trigger( type, data, elem, true );
  14103. }
  14104. }
  14105. } );
  14106. // Support: Firefox <=44
  14107. // Firefox doesn't have focus(in | out) events
  14108. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14109. //
  14110. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14111. // focus(in | out) events fire after focus & blur events,
  14112. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14113. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14114. if ( !support.focusin ) {
  14115. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14116. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14117. var handler = function( event ) {
  14118. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14119. };
  14120. jQuery.event.special[ fix ] = {
  14121. setup: function() {
  14122. var doc = this.ownerDocument || this,
  14123. attaches = dataPriv.access( doc, fix );
  14124. if ( !attaches ) {
  14125. doc.addEventListener( orig, handler, true );
  14126. }
  14127. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14128. },
  14129. teardown: function() {
  14130. var doc = this.ownerDocument || this,
  14131. attaches = dataPriv.access( doc, fix ) - 1;
  14132. if ( !attaches ) {
  14133. doc.removeEventListener( orig, handler, true );
  14134. dataPriv.remove( doc, fix );
  14135. } else {
  14136. dataPriv.access( doc, fix, attaches );
  14137. }
  14138. }
  14139. };
  14140. } );
  14141. }
  14142. var location = window.location;
  14143. var nonce = Date.now();
  14144. var rquery = ( /\?/ );
  14145. // Cross-browser xml parsing
  14146. jQuery.parseXML = function( data ) {
  14147. var xml;
  14148. if ( !data || typeof data !== "string" ) {
  14149. return null;
  14150. }
  14151. // Support: IE 9 - 11 only
  14152. // IE throws on parseFromString with invalid input.
  14153. try {
  14154. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14155. } catch ( e ) {
  14156. xml = undefined;
  14157. }
  14158. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14159. jQuery.error( "Invalid XML: " + data );
  14160. }
  14161. return xml;
  14162. };
  14163. var
  14164. rbracket = /\[\]$/,
  14165. rCRLF = /\r?\n/g,
  14166. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14167. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14168. function buildParams( prefix, obj, traditional, add ) {
  14169. var name;
  14170. if ( Array.isArray( obj ) ) {
  14171. // Serialize array item.
  14172. jQuery.each( obj, function( i, v ) {
  14173. if ( traditional || rbracket.test( prefix ) ) {
  14174. // Treat each array item as a scalar.
  14175. add( prefix, v );
  14176. } else {
  14177. // Item is non-scalar (array or object), encode its numeric index.
  14178. buildParams(
  14179. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14180. v,
  14181. traditional,
  14182. add
  14183. );
  14184. }
  14185. } );
  14186. } else if ( !traditional && toType( obj ) === "object" ) {
  14187. // Serialize object item.
  14188. for ( name in obj ) {
  14189. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14190. }
  14191. } else {
  14192. // Serialize scalar item.
  14193. add( prefix, obj );
  14194. }
  14195. }
  14196. // Serialize an array of form elements or a set of
  14197. // key/values into a query string
  14198. jQuery.param = function( a, traditional ) {
  14199. var prefix,
  14200. s = [],
  14201. add = function( key, valueOrFunction ) {
  14202. // If value is a function, invoke it and use its return value
  14203. var value = isFunction( valueOrFunction ) ?
  14204. valueOrFunction() :
  14205. valueOrFunction;
  14206. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14207. encodeURIComponent( value == null ? "" : value );
  14208. };
  14209. if ( a == null ) {
  14210. return "";
  14211. }
  14212. // If an array was passed in, assume that it is an array of form elements.
  14213. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14214. // Serialize the form elements
  14215. jQuery.each( a, function() {
  14216. add( this.name, this.value );
  14217. } );
  14218. } else {
  14219. // If traditional, encode the "old" way (the way 1.3.2 or older
  14220. // did it), otherwise encode params recursively.
  14221. for ( prefix in a ) {
  14222. buildParams( prefix, a[ prefix ], traditional, add );
  14223. }
  14224. }
  14225. // Return the resulting serialization
  14226. return s.join( "&" );
  14227. };
  14228. jQuery.fn.extend( {
  14229. serialize: function() {
  14230. return jQuery.param( this.serializeArray() );
  14231. },
  14232. serializeArray: function() {
  14233. return this.map( function() {
  14234. // Can add propHook for "elements" to filter or add form elements
  14235. var elements = jQuery.prop( this, "elements" );
  14236. return elements ? jQuery.makeArray( elements ) : this;
  14237. } )
  14238. .filter( function() {
  14239. var type = this.type;
  14240. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14241. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14242. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14243. ( this.checked || !rcheckableType.test( type ) );
  14244. } )
  14245. .map( function( i, elem ) {
  14246. var val = jQuery( this ).val();
  14247. if ( val == null ) {
  14248. return null;
  14249. }
  14250. if ( Array.isArray( val ) ) {
  14251. return jQuery.map( val, function( val ) {
  14252. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14253. } );
  14254. }
  14255. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14256. } ).get();
  14257. }
  14258. } );
  14259. var
  14260. r20 = /%20/g,
  14261. rhash = /#.*$/,
  14262. rantiCache = /([?&])_=[^&]*/,
  14263. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14264. // #7653, #8125, #8152: local protocol detection
  14265. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14266. rnoContent = /^(?:GET|HEAD)$/,
  14267. rprotocol = /^\/\//,
  14268. /* Prefilters
  14269. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14270. * 2) These are called:
  14271. * - BEFORE asking for a transport
  14272. * - AFTER param serialization (s.data is a string if s.processData is true)
  14273. * 3) key is the dataType
  14274. * 4) the catchall symbol "*" can be used
  14275. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14276. */
  14277. prefilters = {},
  14278. /* Transports bindings
  14279. * 1) key is the dataType
  14280. * 2) the catchall symbol "*" can be used
  14281. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14282. */
  14283. transports = {},
  14284. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14285. allTypes = "*/".concat( "*" ),
  14286. // Anchor tag for parsing the document origin
  14287. originAnchor = document.createElement( "a" );
  14288. originAnchor.href = location.href;
  14289. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14290. function addToPrefiltersOrTransports( structure ) {
  14291. // dataTypeExpression is optional and defaults to "*"
  14292. return function( dataTypeExpression, func ) {
  14293. if ( typeof dataTypeExpression !== "string" ) {
  14294. func = dataTypeExpression;
  14295. dataTypeExpression = "*";
  14296. }
  14297. var dataType,
  14298. i = 0,
  14299. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14300. if ( isFunction( func ) ) {
  14301. // For each dataType in the dataTypeExpression
  14302. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14303. // Prepend if requested
  14304. if ( dataType[ 0 ] === "+" ) {
  14305. dataType = dataType.slice( 1 ) || "*";
  14306. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14307. // Otherwise append
  14308. } else {
  14309. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14310. }
  14311. }
  14312. }
  14313. };
  14314. }
  14315. // Base inspection function for prefilters and transports
  14316. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14317. var inspected = {},
  14318. seekingTransport = ( structure === transports );
  14319. function inspect( dataType ) {
  14320. var selected;
  14321. inspected[ dataType ] = true;
  14322. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14323. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14324. if ( typeof dataTypeOrTransport === "string" &&
  14325. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14326. options.dataTypes.unshift( dataTypeOrTransport );
  14327. inspect( dataTypeOrTransport );
  14328. return false;
  14329. } else if ( seekingTransport ) {
  14330. return !( selected = dataTypeOrTransport );
  14331. }
  14332. } );
  14333. return selected;
  14334. }
  14335. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14336. }
  14337. // A special extend for ajax options
  14338. // that takes "flat" options (not to be deep extended)
  14339. // Fixes #9887
  14340. function ajaxExtend( target, src ) {
  14341. var key, deep,
  14342. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14343. for ( key in src ) {
  14344. if ( src[ key ] !== undefined ) {
  14345. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14346. }
  14347. }
  14348. if ( deep ) {
  14349. jQuery.extend( true, target, deep );
  14350. }
  14351. return target;
  14352. }
  14353. /* Handles responses to an ajax request:
  14354. * - finds the right dataType (mediates between content-type and expected dataType)
  14355. * - returns the corresponding response
  14356. */
  14357. function ajaxHandleResponses( s, jqXHR, responses ) {
  14358. var ct, type, finalDataType, firstDataType,
  14359. contents = s.contents,
  14360. dataTypes = s.dataTypes;
  14361. // Remove auto dataType and get content-type in the process
  14362. while ( dataTypes[ 0 ] === "*" ) {
  14363. dataTypes.shift();
  14364. if ( ct === undefined ) {
  14365. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14366. }
  14367. }
  14368. // Check if we're dealing with a known content-type
  14369. if ( ct ) {
  14370. for ( type in contents ) {
  14371. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14372. dataTypes.unshift( type );
  14373. break;
  14374. }
  14375. }
  14376. }
  14377. // Check to see if we have a response for the expected dataType
  14378. if ( dataTypes[ 0 ] in responses ) {
  14379. finalDataType = dataTypes[ 0 ];
  14380. } else {
  14381. // Try convertible dataTypes
  14382. for ( type in responses ) {
  14383. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14384. finalDataType = type;
  14385. break;
  14386. }
  14387. if ( !firstDataType ) {
  14388. firstDataType = type;
  14389. }
  14390. }
  14391. // Or just use first one
  14392. finalDataType = finalDataType || firstDataType;
  14393. }
  14394. // If we found a dataType
  14395. // We add the dataType to the list if needed
  14396. // and return the corresponding response
  14397. if ( finalDataType ) {
  14398. if ( finalDataType !== dataTypes[ 0 ] ) {
  14399. dataTypes.unshift( finalDataType );
  14400. }
  14401. return responses[ finalDataType ];
  14402. }
  14403. }
  14404. /* Chain conversions given the request and the original response
  14405. * Also sets the responseXXX fields on the jqXHR instance
  14406. */
  14407. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14408. var conv2, current, conv, tmp, prev,
  14409. converters = {},
  14410. // Work with a copy of dataTypes in case we need to modify it for conversion
  14411. dataTypes = s.dataTypes.slice();
  14412. // Create converters map with lowercased keys
  14413. if ( dataTypes[ 1 ] ) {
  14414. for ( conv in s.converters ) {
  14415. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14416. }
  14417. }
  14418. current = dataTypes.shift();
  14419. // Convert to each sequential dataType
  14420. while ( current ) {
  14421. if ( s.responseFields[ current ] ) {
  14422. jqXHR[ s.responseFields[ current ] ] = response;
  14423. }
  14424. // Apply the dataFilter if provided
  14425. if ( !prev && isSuccess && s.dataFilter ) {
  14426. response = s.dataFilter( response, s.dataType );
  14427. }
  14428. prev = current;
  14429. current = dataTypes.shift();
  14430. if ( current ) {
  14431. // There's only work to do if current dataType is non-auto
  14432. if ( current === "*" ) {
  14433. current = prev;
  14434. // Convert response if prev dataType is non-auto and differs from current
  14435. } else if ( prev !== "*" && prev !== current ) {
  14436. // Seek a direct converter
  14437. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14438. // If none found, seek a pair
  14439. if ( !conv ) {
  14440. for ( conv2 in converters ) {
  14441. // If conv2 outputs current
  14442. tmp = conv2.split( " " );
  14443. if ( tmp[ 1 ] === current ) {
  14444. // If prev can be converted to accepted input
  14445. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14446. converters[ "* " + tmp[ 0 ] ];
  14447. if ( conv ) {
  14448. // Condense equivalence converters
  14449. if ( conv === true ) {
  14450. conv = converters[ conv2 ];
  14451. // Otherwise, insert the intermediate dataType
  14452. } else if ( converters[ conv2 ] !== true ) {
  14453. current = tmp[ 0 ];
  14454. dataTypes.unshift( tmp[ 1 ] );
  14455. }
  14456. break;
  14457. }
  14458. }
  14459. }
  14460. }
  14461. // Apply converter (if not an equivalence)
  14462. if ( conv !== true ) {
  14463. // Unless errors are allowed to bubble, catch and return them
  14464. if ( conv && s.throws ) {
  14465. response = conv( response );
  14466. } else {
  14467. try {
  14468. response = conv( response );
  14469. } catch ( e ) {
  14470. return {
  14471. state: "parsererror",
  14472. error: conv ? e : "No conversion from " + prev + " to " + current
  14473. };
  14474. }
  14475. }
  14476. }
  14477. }
  14478. }
  14479. }
  14480. return { state: "success", data: response };
  14481. }
  14482. jQuery.extend( {
  14483. // Counter for holding the number of active queries
  14484. active: 0,
  14485. // Last-Modified header cache for next request
  14486. lastModified: {},
  14487. etag: {},
  14488. ajaxSettings: {
  14489. url: location.href,
  14490. type: "GET",
  14491. isLocal: rlocalProtocol.test( location.protocol ),
  14492. global: true,
  14493. processData: true,
  14494. async: true,
  14495. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14496. /*
  14497. timeout: 0,
  14498. data: null,
  14499. dataType: null,
  14500. username: null,
  14501. password: null,
  14502. cache: null,
  14503. throws: false,
  14504. traditional: false,
  14505. headers: {},
  14506. */
  14507. accepts: {
  14508. "*": allTypes,
  14509. text: "text/plain",
  14510. html: "text/html",
  14511. xml: "application/xml, text/xml",
  14512. json: "application/json, text/javascript"
  14513. },
  14514. contents: {
  14515. xml: /\bxml\b/,
  14516. html: /\bhtml/,
  14517. json: /\bjson\b/
  14518. },
  14519. responseFields: {
  14520. xml: "responseXML",
  14521. text: "responseText",
  14522. json: "responseJSON"
  14523. },
  14524. // Data converters
  14525. // Keys separate source (or catchall "*") and destination types with a single space
  14526. converters: {
  14527. // Convert anything to text
  14528. "* text": String,
  14529. // Text to html (true = no transformation)
  14530. "text html": true,
  14531. // Evaluate text as a json expression
  14532. "text json": JSON.parse,
  14533. // Parse text as xml
  14534. "text xml": jQuery.parseXML
  14535. },
  14536. // For options that shouldn't be deep extended:
  14537. // you can add your own custom options here if
  14538. // and when you create one that shouldn't be
  14539. // deep extended (see ajaxExtend)
  14540. flatOptions: {
  14541. url: true,
  14542. context: true
  14543. }
  14544. },
  14545. // Creates a full fledged settings object into target
  14546. // with both ajaxSettings and settings fields.
  14547. // If target is omitted, writes into ajaxSettings.
  14548. ajaxSetup: function( target, settings ) {
  14549. return settings ?
  14550. // Building a settings object
  14551. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14552. // Extending ajaxSettings
  14553. ajaxExtend( jQuery.ajaxSettings, target );
  14554. },
  14555. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14556. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14557. // Main method
  14558. ajax: function( url, options ) {
  14559. // If url is an object, simulate pre-1.5 signature
  14560. if ( typeof url === "object" ) {
  14561. options = url;
  14562. url = undefined;
  14563. }
  14564. // Force options to be an object
  14565. options = options || {};
  14566. var transport,
  14567. // URL without anti-cache param
  14568. cacheURL,
  14569. // Response headers
  14570. responseHeadersString,
  14571. responseHeaders,
  14572. // timeout handle
  14573. timeoutTimer,
  14574. // Url cleanup var
  14575. urlAnchor,
  14576. // Request state (becomes false upon send and true upon completion)
  14577. completed,
  14578. // To know if global events are to be dispatched
  14579. fireGlobals,
  14580. // Loop variable
  14581. i,
  14582. // uncached part of the url
  14583. uncached,
  14584. // Create the final options object
  14585. s = jQuery.ajaxSetup( {}, options ),
  14586. // Callbacks context
  14587. callbackContext = s.context || s,
  14588. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14589. globalEventContext = s.context &&
  14590. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14591. jQuery( callbackContext ) :
  14592. jQuery.event,
  14593. // Deferreds
  14594. deferred = jQuery.Deferred(),
  14595. completeDeferred = jQuery.Callbacks( "once memory" ),
  14596. // Status-dependent callbacks
  14597. statusCode = s.statusCode || {},
  14598. // Headers (they are sent all at once)
  14599. requestHeaders = {},
  14600. requestHeadersNames = {},
  14601. // Default abort message
  14602. strAbort = "canceled",
  14603. // Fake xhr
  14604. jqXHR = {
  14605. readyState: 0,
  14606. // Builds headers hashtable if needed
  14607. getResponseHeader: function( key ) {
  14608. var match;
  14609. if ( completed ) {
  14610. if ( !responseHeaders ) {
  14611. responseHeaders = {};
  14612. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14613. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14614. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14615. .concat( match[ 2 ] );
  14616. }
  14617. }
  14618. match = responseHeaders[ key.toLowerCase() + " " ];
  14619. }
  14620. return match == null ? null : match.join( ", " );
  14621. },
  14622. // Raw string
  14623. getAllResponseHeaders: function() {
  14624. return completed ? responseHeadersString : null;
  14625. },
  14626. // Caches the header
  14627. setRequestHeader: function( name, value ) {
  14628. if ( completed == null ) {
  14629. name = requestHeadersNames[ name.toLowerCase() ] =
  14630. requestHeadersNames[ name.toLowerCase() ] || name;
  14631. requestHeaders[ name ] = value;
  14632. }
  14633. return this;
  14634. },
  14635. // Overrides response content-type header
  14636. overrideMimeType: function( type ) {
  14637. if ( completed == null ) {
  14638. s.mimeType = type;
  14639. }
  14640. return this;
  14641. },
  14642. // Status-dependent callbacks
  14643. statusCode: function( map ) {
  14644. var code;
  14645. if ( map ) {
  14646. if ( completed ) {
  14647. // Execute the appropriate callbacks
  14648. jqXHR.always( map[ jqXHR.status ] );
  14649. } else {
  14650. // Lazy-add the new callbacks in a way that preserves old ones
  14651. for ( code in map ) {
  14652. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14653. }
  14654. }
  14655. }
  14656. return this;
  14657. },
  14658. // Cancel the request
  14659. abort: function( statusText ) {
  14660. var finalText = statusText || strAbort;
  14661. if ( transport ) {
  14662. transport.abort( finalText );
  14663. }
  14664. done( 0, finalText );
  14665. return this;
  14666. }
  14667. };
  14668. // Attach deferreds
  14669. deferred.promise( jqXHR );
  14670. // Add protocol if not provided (prefilters might expect it)
  14671. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14672. // We also use the url parameter if available
  14673. s.url = ( ( url || s.url || location.href ) + "" )
  14674. .replace( rprotocol, location.protocol + "//" );
  14675. // Alias method option to type as per ticket #12004
  14676. s.type = options.method || options.type || s.method || s.type;
  14677. // Extract dataTypes list
  14678. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14679. // A cross-domain request is in order when the origin doesn't match the current origin.
  14680. if ( s.crossDomain == null ) {
  14681. urlAnchor = document.createElement( "a" );
  14682. // Support: IE <=8 - 11, Edge 12 - 15
  14683. // IE throws exception on accessing the href property if url is malformed,
  14684. // e.g. http://example.com:80x/
  14685. try {
  14686. urlAnchor.href = s.url;
  14687. // Support: IE <=8 - 11 only
  14688. // Anchor's host property isn't correctly set when s.url is relative
  14689. urlAnchor.href = urlAnchor.href;
  14690. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14691. urlAnchor.protocol + "//" + urlAnchor.host;
  14692. } catch ( e ) {
  14693. // If there is an error parsing the URL, assume it is crossDomain,
  14694. // it can be rejected by the transport if it is invalid
  14695. s.crossDomain = true;
  14696. }
  14697. }
  14698. // Convert data if not already a string
  14699. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14700. s.data = jQuery.param( s.data, s.traditional );
  14701. }
  14702. // Apply prefilters
  14703. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14704. // If request was aborted inside a prefilter, stop there
  14705. if ( completed ) {
  14706. return jqXHR;
  14707. }
  14708. // We can fire global events as of now if asked to
  14709. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14710. fireGlobals = jQuery.event && s.global;
  14711. // Watch for a new set of requests
  14712. if ( fireGlobals && jQuery.active++ === 0 ) {
  14713. jQuery.event.trigger( "ajaxStart" );
  14714. }
  14715. // Uppercase the type
  14716. s.type = s.type.toUpperCase();
  14717. // Determine if request has content
  14718. s.hasContent = !rnoContent.test( s.type );
  14719. // Save the URL in case we're toying with the If-Modified-Since
  14720. // and/or If-None-Match header later on
  14721. // Remove hash to simplify url manipulation
  14722. cacheURL = s.url.replace( rhash, "" );
  14723. // More options handling for requests with no content
  14724. if ( !s.hasContent ) {
  14725. // Remember the hash so we can put it back
  14726. uncached = s.url.slice( cacheURL.length );
  14727. // If data is available and should be processed, append data to url
  14728. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14729. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14730. // #9682: remove data so that it's not used in an eventual retry
  14731. delete s.data;
  14732. }
  14733. // Add or update anti-cache param if needed
  14734. if ( s.cache === false ) {
  14735. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14736. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14737. }
  14738. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14739. s.url = cacheURL + uncached;
  14740. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14741. } else if ( s.data && s.processData &&
  14742. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14743. s.data = s.data.replace( r20, "+" );
  14744. }
  14745. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14746. if ( s.ifModified ) {
  14747. if ( jQuery.lastModified[ cacheURL ] ) {
  14748. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14749. }
  14750. if ( jQuery.etag[ cacheURL ] ) {
  14751. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14752. }
  14753. }
  14754. // Set the correct header, if data is being sent
  14755. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14756. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14757. }
  14758. // Set the Accepts header for the server, depending on the dataType
  14759. jqXHR.setRequestHeader(
  14760. "Accept",
  14761. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14762. s.accepts[ s.dataTypes[ 0 ] ] +
  14763. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14764. s.accepts[ "*" ]
  14765. );
  14766. // Check for headers option
  14767. for ( i in s.headers ) {
  14768. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14769. }
  14770. // Allow custom headers/mimetypes and early abort
  14771. if ( s.beforeSend &&
  14772. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14773. // Abort if not done already and return
  14774. return jqXHR.abort();
  14775. }
  14776. // Aborting is no longer a cancellation
  14777. strAbort = "abort";
  14778. // Install callbacks on deferreds
  14779. completeDeferred.add( s.complete );
  14780. jqXHR.done( s.success );
  14781. jqXHR.fail( s.error );
  14782. // Get transport
  14783. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14784. // If no transport, we auto-abort
  14785. if ( !transport ) {
  14786. done( -1, "No Transport" );
  14787. } else {
  14788. jqXHR.readyState = 1;
  14789. // Send global event
  14790. if ( fireGlobals ) {
  14791. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14792. }
  14793. // If request was aborted inside ajaxSend, stop there
  14794. if ( completed ) {
  14795. return jqXHR;
  14796. }
  14797. // Timeout
  14798. if ( s.async && s.timeout > 0 ) {
  14799. timeoutTimer = window.setTimeout( function() {
  14800. jqXHR.abort( "timeout" );
  14801. }, s.timeout );
  14802. }
  14803. try {
  14804. completed = false;
  14805. transport.send( requestHeaders, done );
  14806. } catch ( e ) {
  14807. // Rethrow post-completion exceptions
  14808. if ( completed ) {
  14809. throw e;
  14810. }
  14811. // Propagate others as results
  14812. done( -1, e );
  14813. }
  14814. }
  14815. // Callback for when everything is done
  14816. function done( status, nativeStatusText, responses, headers ) {
  14817. var isSuccess, success, error, response, modified,
  14818. statusText = nativeStatusText;
  14819. // Ignore repeat invocations
  14820. if ( completed ) {
  14821. return;
  14822. }
  14823. completed = true;
  14824. // Clear timeout if it exists
  14825. if ( timeoutTimer ) {
  14826. window.clearTimeout( timeoutTimer );
  14827. }
  14828. // Dereference transport for early garbage collection
  14829. // (no matter how long the jqXHR object will be used)
  14830. transport = undefined;
  14831. // Cache response headers
  14832. responseHeadersString = headers || "";
  14833. // Set readyState
  14834. jqXHR.readyState = status > 0 ? 4 : 0;
  14835. // Determine if successful
  14836. isSuccess = status >= 200 && status < 300 || status === 304;
  14837. // Get response data
  14838. if ( responses ) {
  14839. response = ajaxHandleResponses( s, jqXHR, responses );
  14840. }
  14841. // Convert no matter what (that way responseXXX fields are always set)
  14842. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14843. // If successful, handle type chaining
  14844. if ( isSuccess ) {
  14845. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14846. if ( s.ifModified ) {
  14847. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14848. if ( modified ) {
  14849. jQuery.lastModified[ cacheURL ] = modified;
  14850. }
  14851. modified = jqXHR.getResponseHeader( "etag" );
  14852. if ( modified ) {
  14853. jQuery.etag[ cacheURL ] = modified;
  14854. }
  14855. }
  14856. // if no content
  14857. if ( status === 204 || s.type === "HEAD" ) {
  14858. statusText = "nocontent";
  14859. // if not modified
  14860. } else if ( status === 304 ) {
  14861. statusText = "notmodified";
  14862. // If we have data, let's convert it
  14863. } else {
  14864. statusText = response.state;
  14865. success = response.data;
  14866. error = response.error;
  14867. isSuccess = !error;
  14868. }
  14869. } else {
  14870. // Extract error from statusText and normalize for non-aborts
  14871. error = statusText;
  14872. if ( status || !statusText ) {
  14873. statusText = "error";
  14874. if ( status < 0 ) {
  14875. status = 0;
  14876. }
  14877. }
  14878. }
  14879. // Set data for the fake xhr object
  14880. jqXHR.status = status;
  14881. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14882. // Success/Error
  14883. if ( isSuccess ) {
  14884. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14885. } else {
  14886. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14887. }
  14888. // Status-dependent callbacks
  14889. jqXHR.statusCode( statusCode );
  14890. statusCode = undefined;
  14891. if ( fireGlobals ) {
  14892. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14893. [ jqXHR, s, isSuccess ? success : error ] );
  14894. }
  14895. // Complete
  14896. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14897. if ( fireGlobals ) {
  14898. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14899. // Handle the global AJAX counter
  14900. if ( !( --jQuery.active ) ) {
  14901. jQuery.event.trigger( "ajaxStop" );
  14902. }
  14903. }
  14904. }
  14905. return jqXHR;
  14906. },
  14907. getJSON: function( url, data, callback ) {
  14908. return jQuery.get( url, data, callback, "json" );
  14909. },
  14910. getScript: function( url, callback ) {
  14911. return jQuery.get( url, undefined, callback, "script" );
  14912. }
  14913. } );
  14914. jQuery.each( [ "get", "post" ], function( i, method ) {
  14915. jQuery[ method ] = function( url, data, callback, type ) {
  14916. // Shift arguments if data argument was omitted
  14917. if ( isFunction( data ) ) {
  14918. type = type || callback;
  14919. callback = data;
  14920. data = undefined;
  14921. }
  14922. // The url can be an options object (which then must have .url)
  14923. return jQuery.ajax( jQuery.extend( {
  14924. url: url,
  14925. type: method,
  14926. dataType: type,
  14927. data: data,
  14928. success: callback
  14929. }, jQuery.isPlainObject( url ) && url ) );
  14930. };
  14931. } );
  14932. jQuery._evalUrl = function( url, options ) {
  14933. return jQuery.ajax( {
  14934. url: url,
  14935. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14936. type: "GET",
  14937. dataType: "script",
  14938. cache: true,
  14939. async: false,
  14940. global: false,
  14941. // Only evaluate the response if it is successful (gh-4126)
  14942. // dataFilter is not invoked for failure responses, so using it instead
  14943. // of the default converter is kludgy but it works.
  14944. converters: {
  14945. "text script": function() {}
  14946. },
  14947. dataFilter: function( response ) {
  14948. jQuery.globalEval( response, options );
  14949. }
  14950. } );
  14951. };
  14952. jQuery.fn.extend( {
  14953. wrapAll: function( html ) {
  14954. var wrap;
  14955. if ( this[ 0 ] ) {
  14956. if ( isFunction( html ) ) {
  14957. html = html.call( this[ 0 ] );
  14958. }
  14959. // The elements to wrap the target around
  14960. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  14961. if ( this[ 0 ].parentNode ) {
  14962. wrap.insertBefore( this[ 0 ] );
  14963. }
  14964. wrap.map( function() {
  14965. var elem = this;
  14966. while ( elem.firstElementChild ) {
  14967. elem = elem.firstElementChild;
  14968. }
  14969. return elem;
  14970. } ).append( this );
  14971. }
  14972. return this;
  14973. },
  14974. wrapInner: function( html ) {
  14975. if ( isFunction( html ) ) {
  14976. return this.each( function( i ) {
  14977. jQuery( this ).wrapInner( html.call( this, i ) );
  14978. } );
  14979. }
  14980. return this.each( function() {
  14981. var self = jQuery( this ),
  14982. contents = self.contents();
  14983. if ( contents.length ) {
  14984. contents.wrapAll( html );
  14985. } else {
  14986. self.append( html );
  14987. }
  14988. } );
  14989. },
  14990. wrap: function( html ) {
  14991. var htmlIsFunction = isFunction( html );
  14992. return this.each( function( i ) {
  14993. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  14994. } );
  14995. },
  14996. unwrap: function( selector ) {
  14997. this.parent( selector ).not( "body" ).each( function() {
  14998. jQuery( this ).replaceWith( this.childNodes );
  14999. } );
  15000. return this;
  15001. }
  15002. } );
  15003. jQuery.expr.pseudos.hidden = function( elem ) {
  15004. return !jQuery.expr.pseudos.visible( elem );
  15005. };
  15006. jQuery.expr.pseudos.visible = function( elem ) {
  15007. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15008. };
  15009. jQuery.ajaxSettings.xhr = function() {
  15010. try {
  15011. return new window.XMLHttpRequest();
  15012. } catch ( e ) {}
  15013. };
  15014. var xhrSuccessStatus = {
  15015. // File protocol always yields status code 0, assume 200
  15016. 0: 200,
  15017. // Support: IE <=9 only
  15018. // #1450: sometimes IE returns 1223 when it should be 204
  15019. 1223: 204
  15020. },
  15021. xhrSupported = jQuery.ajaxSettings.xhr();
  15022. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15023. support.ajax = xhrSupported = !!xhrSupported;
  15024. jQuery.ajaxTransport( function( options ) {
  15025. var callback, errorCallback;
  15026. // Cross domain only allowed if supported through XMLHttpRequest
  15027. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15028. return {
  15029. send: function( headers, complete ) {
  15030. var i,
  15031. xhr = options.xhr();
  15032. xhr.open(
  15033. options.type,
  15034. options.url,
  15035. options.async,
  15036. options.username,
  15037. options.password
  15038. );
  15039. // Apply custom fields if provided
  15040. if ( options.xhrFields ) {
  15041. for ( i in options.xhrFields ) {
  15042. xhr[ i ] = options.xhrFields[ i ];
  15043. }
  15044. }
  15045. // Override mime type if needed
  15046. if ( options.mimeType && xhr.overrideMimeType ) {
  15047. xhr.overrideMimeType( options.mimeType );
  15048. }
  15049. // X-Requested-With header
  15050. // For cross-domain requests, seeing as conditions for a preflight are
  15051. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15052. // (it can always be set on a per-request basis or even using ajaxSetup)
  15053. // For same-domain requests, won't change header if already provided.
  15054. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15055. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15056. }
  15057. // Set headers
  15058. for ( i in headers ) {
  15059. xhr.setRequestHeader( i, headers[ i ] );
  15060. }
  15061. // Callback
  15062. callback = function( type ) {
  15063. return function() {
  15064. if ( callback ) {
  15065. callback = errorCallback = xhr.onload =
  15066. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15067. xhr.onreadystatechange = null;
  15068. if ( type === "abort" ) {
  15069. xhr.abort();
  15070. } else if ( type === "error" ) {
  15071. // Support: IE <=9 only
  15072. // On a manual native abort, IE9 throws
  15073. // errors on any property access that is not readyState
  15074. if ( typeof xhr.status !== "number" ) {
  15075. complete( 0, "error" );
  15076. } else {
  15077. complete(
  15078. // File: protocol always yields status 0; see #8605, #14207
  15079. xhr.status,
  15080. xhr.statusText
  15081. );
  15082. }
  15083. } else {
  15084. complete(
  15085. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15086. xhr.statusText,
  15087. // Support: IE <=9 only
  15088. // IE9 has no XHR2 but throws on binary (trac-11426)
  15089. // For XHR2 non-text, let the caller handle it (gh-2498)
  15090. ( xhr.responseType || "text" ) !== "text" ||
  15091. typeof xhr.responseText !== "string" ?
  15092. { binary: xhr.response } :
  15093. { text: xhr.responseText },
  15094. xhr.getAllResponseHeaders()
  15095. );
  15096. }
  15097. }
  15098. };
  15099. };
  15100. // Listen to events
  15101. xhr.onload = callback();
  15102. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15103. // Support: IE 9 only
  15104. // Use onreadystatechange to replace onabort
  15105. // to handle uncaught aborts
  15106. if ( xhr.onabort !== undefined ) {
  15107. xhr.onabort = errorCallback;
  15108. } else {
  15109. xhr.onreadystatechange = function() {
  15110. // Check readyState before timeout as it changes
  15111. if ( xhr.readyState === 4 ) {
  15112. // Allow onerror to be called first,
  15113. // but that will not handle a native abort
  15114. // Also, save errorCallback to a variable
  15115. // as xhr.onerror cannot be accessed
  15116. window.setTimeout( function() {
  15117. if ( callback ) {
  15118. errorCallback();
  15119. }
  15120. } );
  15121. }
  15122. };
  15123. }
  15124. // Create the abort callback
  15125. callback = callback( "abort" );
  15126. try {
  15127. // Do send the request (this may raise an exception)
  15128. xhr.send( options.hasContent && options.data || null );
  15129. } catch ( e ) {
  15130. // #14683: Only rethrow if this hasn't been notified as an error yet
  15131. if ( callback ) {
  15132. throw e;
  15133. }
  15134. }
  15135. },
  15136. abort: function() {
  15137. if ( callback ) {
  15138. callback();
  15139. }
  15140. }
  15141. };
  15142. }
  15143. } );
  15144. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15145. jQuery.ajaxPrefilter( function( s ) {
  15146. if ( s.crossDomain ) {
  15147. s.contents.script = false;
  15148. }
  15149. } );
  15150. // Install script dataType
  15151. jQuery.ajaxSetup( {
  15152. accepts: {
  15153. script: "text/javascript, application/javascript, " +
  15154. "application/ecmascript, application/x-ecmascript"
  15155. },
  15156. contents: {
  15157. script: /\b(?:java|ecma)script\b/
  15158. },
  15159. converters: {
  15160. "text script": function( text ) {
  15161. jQuery.globalEval( text );
  15162. return text;
  15163. }
  15164. }
  15165. } );
  15166. // Handle cache's special case and crossDomain
  15167. jQuery.ajaxPrefilter( "script", function( s ) {
  15168. if ( s.cache === undefined ) {
  15169. s.cache = false;
  15170. }
  15171. if ( s.crossDomain ) {
  15172. s.type = "GET";
  15173. }
  15174. } );
  15175. // Bind script tag hack transport
  15176. jQuery.ajaxTransport( "script", function( s ) {
  15177. // This transport only deals with cross domain or forced-by-attrs requests
  15178. if ( s.crossDomain || s.scriptAttrs ) {
  15179. var script, callback;
  15180. return {
  15181. send: function( _, complete ) {
  15182. script = jQuery( "<script>" )
  15183. .attr( s.scriptAttrs || {} )
  15184. .prop( { charset: s.scriptCharset, src: s.url } )
  15185. .on( "load error", callback = function( evt ) {
  15186. script.remove();
  15187. callback = null;
  15188. if ( evt ) {
  15189. complete( evt.type === "error" ? 404 : 200, evt.type );
  15190. }
  15191. } );
  15192. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15193. document.head.appendChild( script[ 0 ] );
  15194. },
  15195. abort: function() {
  15196. if ( callback ) {
  15197. callback();
  15198. }
  15199. }
  15200. };
  15201. }
  15202. } );
  15203. var oldCallbacks = [],
  15204. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15205. // Default jsonp settings
  15206. jQuery.ajaxSetup( {
  15207. jsonp: "callback",
  15208. jsonpCallback: function() {
  15209. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15210. this[ callback ] = true;
  15211. return callback;
  15212. }
  15213. } );
  15214. // Detect, normalize options and install callbacks for jsonp requests
  15215. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15216. var callbackName, overwritten, responseContainer,
  15217. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15218. "url" :
  15219. typeof s.data === "string" &&
  15220. ( s.contentType || "" )
  15221. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15222. rjsonp.test( s.data ) && "data"
  15223. );
  15224. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15225. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15226. // Get callback name, remembering preexisting value associated with it
  15227. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15228. s.jsonpCallback() :
  15229. s.jsonpCallback;
  15230. // Insert callback into url or form data
  15231. if ( jsonProp ) {
  15232. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15233. } else if ( s.jsonp !== false ) {
  15234. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15235. }
  15236. // Use data converter to retrieve json after script execution
  15237. s.converters[ "script json" ] = function() {
  15238. if ( !responseContainer ) {
  15239. jQuery.error( callbackName + " was not called" );
  15240. }
  15241. return responseContainer[ 0 ];
  15242. };
  15243. // Force json dataType
  15244. s.dataTypes[ 0 ] = "json";
  15245. // Install callback
  15246. overwritten = window[ callbackName ];
  15247. window[ callbackName ] = function() {
  15248. responseContainer = arguments;
  15249. };
  15250. // Clean-up function (fires after converters)
  15251. jqXHR.always( function() {
  15252. // If previous value didn't exist - remove it
  15253. if ( overwritten === undefined ) {
  15254. jQuery( window ).removeProp( callbackName );
  15255. // Otherwise restore preexisting value
  15256. } else {
  15257. window[ callbackName ] = overwritten;
  15258. }
  15259. // Save back as free
  15260. if ( s[ callbackName ] ) {
  15261. // Make sure that re-using the options doesn't screw things around
  15262. s.jsonpCallback = originalSettings.jsonpCallback;
  15263. // Save the callback name for future use
  15264. oldCallbacks.push( callbackName );
  15265. }
  15266. // Call if it was a function and we have a response
  15267. if ( responseContainer && isFunction( overwritten ) ) {
  15268. overwritten( responseContainer[ 0 ] );
  15269. }
  15270. responseContainer = overwritten = undefined;
  15271. } );
  15272. // Delegate to script
  15273. return "script";
  15274. }
  15275. } );
  15276. // Support: Safari 8 only
  15277. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15278. // collapse sibling forms: the second one becomes a child of the first one.
  15279. // Because of that, this security measure has to be disabled in Safari 8.
  15280. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15281. support.createHTMLDocument = ( function() {
  15282. var body = document.implementation.createHTMLDocument( "" ).body;
  15283. body.innerHTML = "<form></form><form></form>";
  15284. return body.childNodes.length === 2;
  15285. } )();
  15286. // Argument "data" should be string of html
  15287. // context (optional): If specified, the fragment will be created in this context,
  15288. // defaults to document
  15289. // keepScripts (optional): If true, will include scripts passed in the html string
  15290. jQuery.parseHTML = function( data, context, keepScripts ) {
  15291. if ( typeof data !== "string" ) {
  15292. return [];
  15293. }
  15294. if ( typeof context === "boolean" ) {
  15295. keepScripts = context;
  15296. context = false;
  15297. }
  15298. var base, parsed, scripts;
  15299. if ( !context ) {
  15300. // Stop scripts or inline event handlers from being executed immediately
  15301. // by using document.implementation
  15302. if ( support.createHTMLDocument ) {
  15303. context = document.implementation.createHTMLDocument( "" );
  15304. // Set the base href for the created document
  15305. // so any parsed elements with URLs
  15306. // are based on the document's URL (gh-2965)
  15307. base = context.createElement( "base" );
  15308. base.href = document.location.href;
  15309. context.head.appendChild( base );
  15310. } else {
  15311. context = document;
  15312. }
  15313. }
  15314. parsed = rsingleTag.exec( data );
  15315. scripts = !keepScripts && [];
  15316. // Single tag
  15317. if ( parsed ) {
  15318. return [ context.createElement( parsed[ 1 ] ) ];
  15319. }
  15320. parsed = buildFragment( [ data ], context, scripts );
  15321. if ( scripts && scripts.length ) {
  15322. jQuery( scripts ).remove();
  15323. }
  15324. return jQuery.merge( [], parsed.childNodes );
  15325. };
  15326. /**
  15327. * Load a url into a page
  15328. */
  15329. jQuery.fn.load = function( url, params, callback ) {
  15330. var selector, type, response,
  15331. self = this,
  15332. off = url.indexOf( " " );
  15333. if ( off > -1 ) {
  15334. selector = stripAndCollapse( url.slice( off ) );
  15335. url = url.slice( 0, off );
  15336. }
  15337. // If it's a function
  15338. if ( isFunction( params ) ) {
  15339. // We assume that it's the callback
  15340. callback = params;
  15341. params = undefined;
  15342. // Otherwise, build a param string
  15343. } else if ( params && typeof params === "object" ) {
  15344. type = "POST";
  15345. }
  15346. // If we have elements to modify, make the request
  15347. if ( self.length > 0 ) {
  15348. jQuery.ajax( {
  15349. url: url,
  15350. // If "type" variable is undefined, then "GET" method will be used.
  15351. // Make value of this field explicit since
  15352. // user can override it through ajaxSetup method
  15353. type: type || "GET",
  15354. dataType: "html",
  15355. data: params
  15356. } ).done( function( responseText ) {
  15357. // Save response for use in complete callback
  15358. response = arguments;
  15359. self.html( selector ?
  15360. // If a selector was specified, locate the right elements in a dummy div
  15361. // Exclude scripts to avoid IE 'Permission Denied' errors
  15362. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15363. // Otherwise use the full result
  15364. responseText );
  15365. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15366. // but they are ignored because response was set above.
  15367. // If it fails, this function gets "jqXHR", "status", "error"
  15368. } ).always( callback && function( jqXHR, status ) {
  15369. self.each( function() {
  15370. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15371. } );
  15372. } );
  15373. }
  15374. return this;
  15375. };
  15376. // Attach a bunch of functions for handling common AJAX events
  15377. jQuery.each( [
  15378. "ajaxStart",
  15379. "ajaxStop",
  15380. "ajaxComplete",
  15381. "ajaxError",
  15382. "ajaxSuccess",
  15383. "ajaxSend"
  15384. ], function( i, type ) {
  15385. jQuery.fn[ type ] = function( fn ) {
  15386. return this.on( type, fn );
  15387. };
  15388. } );
  15389. jQuery.expr.pseudos.animated = function( elem ) {
  15390. return jQuery.grep( jQuery.timers, function( fn ) {
  15391. return elem === fn.elem;
  15392. } ).length;
  15393. };
  15394. jQuery.offset = {
  15395. setOffset: function( elem, options, i ) {
  15396. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15397. position = jQuery.css( elem, "position" ),
  15398. curElem = jQuery( elem ),
  15399. props = {};
  15400. // Set position first, in-case top/left are set even on static elem
  15401. if ( position === "static" ) {
  15402. elem.style.position = "relative";
  15403. }
  15404. curOffset = curElem.offset();
  15405. curCSSTop = jQuery.css( elem, "top" );
  15406. curCSSLeft = jQuery.css( elem, "left" );
  15407. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15408. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15409. // Need to be able to calculate position if either
  15410. // top or left is auto and position is either absolute or fixed
  15411. if ( calculatePosition ) {
  15412. curPosition = curElem.position();
  15413. curTop = curPosition.top;
  15414. curLeft = curPosition.left;
  15415. } else {
  15416. curTop = parseFloat( curCSSTop ) || 0;
  15417. curLeft = parseFloat( curCSSLeft ) || 0;
  15418. }
  15419. if ( isFunction( options ) ) {
  15420. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15421. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15422. }
  15423. if ( options.top != null ) {
  15424. props.top = ( options.top - curOffset.top ) + curTop;
  15425. }
  15426. if ( options.left != null ) {
  15427. props.left = ( options.left - curOffset.left ) + curLeft;
  15428. }
  15429. if ( "using" in options ) {
  15430. options.using.call( elem, props );
  15431. } else {
  15432. curElem.css( props );
  15433. }
  15434. }
  15435. };
  15436. jQuery.fn.extend( {
  15437. // offset() relates an element's border box to the document origin
  15438. offset: function( options ) {
  15439. // Preserve chaining for setter
  15440. if ( arguments.length ) {
  15441. return options === undefined ?
  15442. this :
  15443. this.each( function( i ) {
  15444. jQuery.offset.setOffset( this, options, i );
  15445. } );
  15446. }
  15447. var rect, win,
  15448. elem = this[ 0 ];
  15449. if ( !elem ) {
  15450. return;
  15451. }
  15452. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15453. // Support: IE <=11 only
  15454. // Running getBoundingClientRect on a
  15455. // disconnected node in IE throws an error
  15456. if ( !elem.getClientRects().length ) {
  15457. return { top: 0, left: 0 };
  15458. }
  15459. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15460. rect = elem.getBoundingClientRect();
  15461. win = elem.ownerDocument.defaultView;
  15462. return {
  15463. top: rect.top + win.pageYOffset,
  15464. left: rect.left + win.pageXOffset
  15465. };
  15466. },
  15467. // position() relates an element's margin box to its offset parent's padding box
  15468. // This corresponds to the behavior of CSS absolute positioning
  15469. position: function() {
  15470. if ( !this[ 0 ] ) {
  15471. return;
  15472. }
  15473. var offsetParent, offset, doc,
  15474. elem = this[ 0 ],
  15475. parentOffset = { top: 0, left: 0 };
  15476. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15477. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15478. // Assume position:fixed implies availability of getBoundingClientRect
  15479. offset = elem.getBoundingClientRect();
  15480. } else {
  15481. offset = this.offset();
  15482. // Account for the *real* offset parent, which can be the document or its root element
  15483. // when a statically positioned element is identified
  15484. doc = elem.ownerDocument;
  15485. offsetParent = elem.offsetParent || doc.documentElement;
  15486. while ( offsetParent &&
  15487. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15488. jQuery.css( offsetParent, "position" ) === "static" ) {
  15489. offsetParent = offsetParent.parentNode;
  15490. }
  15491. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15492. // Incorporate borders into its offset, since they are outside its content origin
  15493. parentOffset = jQuery( offsetParent ).offset();
  15494. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15495. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15496. }
  15497. }
  15498. // Subtract parent offsets and element margins
  15499. return {
  15500. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15501. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15502. };
  15503. },
  15504. // This method will return documentElement in the following cases:
  15505. // 1) For the element inside the iframe without offsetParent, this method will return
  15506. // documentElement of the parent window
  15507. // 2) For the hidden or detached element
  15508. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15509. //
  15510. // but those exceptions were never presented as a real life use-cases
  15511. // and might be considered as more preferable results.
  15512. //
  15513. // This logic, however, is not guaranteed and can change at any point in the future
  15514. offsetParent: function() {
  15515. return this.map( function() {
  15516. var offsetParent = this.offsetParent;
  15517. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15518. offsetParent = offsetParent.offsetParent;
  15519. }
  15520. return offsetParent || documentElement;
  15521. } );
  15522. }
  15523. } );
  15524. // Create scrollLeft and scrollTop methods
  15525. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15526. var top = "pageYOffset" === prop;
  15527. jQuery.fn[ method ] = function( val ) {
  15528. return access( this, function( elem, method, val ) {
  15529. // Coalesce documents and windows
  15530. var win;
  15531. if ( isWindow( elem ) ) {
  15532. win = elem;
  15533. } else if ( elem.nodeType === 9 ) {
  15534. win = elem.defaultView;
  15535. }
  15536. if ( val === undefined ) {
  15537. return win ? win[ prop ] : elem[ method ];
  15538. }
  15539. if ( win ) {
  15540. win.scrollTo(
  15541. !top ? val : win.pageXOffset,
  15542. top ? val : win.pageYOffset
  15543. );
  15544. } else {
  15545. elem[ method ] = val;
  15546. }
  15547. }, method, val, arguments.length );
  15548. };
  15549. } );
  15550. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15551. // Add the top/left cssHooks using jQuery.fn.position
  15552. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15553. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15554. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15555. // rather than make the css module depend on the offset module, just check for it here
  15556. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15557. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15558. function( elem, computed ) {
  15559. if ( computed ) {
  15560. computed = curCSS( elem, prop );
  15561. // If curCSS returns percentage, fallback to offset
  15562. return rnumnonpx.test( computed ) ?
  15563. jQuery( elem ).position()[ prop ] + "px" :
  15564. computed;
  15565. }
  15566. }
  15567. );
  15568. } );
  15569. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15570. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15571. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15572. function( defaultExtra, funcName ) {
  15573. // Margin is only for outerHeight, outerWidth
  15574. jQuery.fn[ funcName ] = function( margin, value ) {
  15575. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15576. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15577. return access( this, function( elem, type, value ) {
  15578. var doc;
  15579. if ( isWindow( elem ) ) {
  15580. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15581. return funcName.indexOf( "outer" ) === 0 ?
  15582. elem[ "inner" + name ] :
  15583. elem.document.documentElement[ "client" + name ];
  15584. }
  15585. // Get document width or height
  15586. if ( elem.nodeType === 9 ) {
  15587. doc = elem.documentElement;
  15588. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15589. // whichever is greatest
  15590. return Math.max(
  15591. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15592. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15593. doc[ "client" + name ]
  15594. );
  15595. }
  15596. return value === undefined ?
  15597. // Get width or height on the element, requesting but not forcing parseFloat
  15598. jQuery.css( elem, type, extra ) :
  15599. // Set width or height on the element
  15600. jQuery.style( elem, type, value, extra );
  15601. }, type, chainable ? margin : undefined, chainable );
  15602. };
  15603. } );
  15604. } );
  15605. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15606. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15607. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15608. function( i, name ) {
  15609. // Handle event binding
  15610. jQuery.fn[ name ] = function( data, fn ) {
  15611. return arguments.length > 0 ?
  15612. this.on( name, null, data, fn ) :
  15613. this.trigger( name );
  15614. };
  15615. } );
  15616. jQuery.fn.extend( {
  15617. hover: function( fnOver, fnOut ) {
  15618. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15619. }
  15620. } );
  15621. jQuery.fn.extend( {
  15622. bind: function( types, data, fn ) {
  15623. return this.on( types, null, data, fn );
  15624. },
  15625. unbind: function( types, fn ) {
  15626. return this.off( types, null, fn );
  15627. },
  15628. delegate: function( selector, types, data, fn ) {
  15629. return this.on( types, selector, data, fn );
  15630. },
  15631. undelegate: function( selector, types, fn ) {
  15632. // ( namespace ) or ( selector, types [, fn] )
  15633. return arguments.length === 1 ?
  15634. this.off( selector, "**" ) :
  15635. this.off( types, selector || "**", fn );
  15636. }
  15637. } );
  15638. // Bind a function to a context, optionally partially applying any
  15639. // arguments.
  15640. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15641. // However, it is not slated for removal any time soon
  15642. jQuery.proxy = function( fn, context ) {
  15643. var tmp, args, proxy;
  15644. if ( typeof context === "string" ) {
  15645. tmp = fn[ context ];
  15646. context = fn;
  15647. fn = tmp;
  15648. }
  15649. // Quick check to determine if target is callable, in the spec
  15650. // this throws a TypeError, but we will just return undefined.
  15651. if ( !isFunction( fn ) ) {
  15652. return undefined;
  15653. }
  15654. // Simulated bind
  15655. args = slice.call( arguments, 2 );
  15656. proxy = function() {
  15657. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15658. };
  15659. // Set the guid of unique handler to the same of original handler, so it can be removed
  15660. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15661. return proxy;
  15662. };
  15663. jQuery.holdReady = function( hold ) {
  15664. if ( hold ) {
  15665. jQuery.readyWait++;
  15666. } else {
  15667. jQuery.ready( true );
  15668. }
  15669. };
  15670. jQuery.isArray = Array.isArray;
  15671. jQuery.parseJSON = JSON.parse;
  15672. jQuery.nodeName = nodeName;
  15673. jQuery.isFunction = isFunction;
  15674. jQuery.isWindow = isWindow;
  15675. jQuery.camelCase = camelCase;
  15676. jQuery.type = toType;
  15677. jQuery.now = Date.now;
  15678. jQuery.isNumeric = function( obj ) {
  15679. // As of jQuery 3.0, isNumeric is limited to
  15680. // strings and numbers (primitives or objects)
  15681. // that can be coerced to finite numbers (gh-2662)
  15682. var type = jQuery.type( obj );
  15683. return ( type === "number" || type === "string" ) &&
  15684. // parseFloat NaNs numeric-cast false positives ("")
  15685. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15686. // subtraction forces infinities to NaN
  15687. !isNaN( obj - parseFloat( obj ) );
  15688. };
  15689. // Register as a named AMD module, since jQuery can be concatenated with other
  15690. // files that may use define, but not via a proper concatenation script that
  15691. // understands anonymous AMD modules. A named AMD is safest and most robust
  15692. // way to register. Lowercase jquery is used because AMD module names are
  15693. // derived from file names, and jQuery is normally delivered in a lowercase
  15694. // file name. Do this after creating the global so that if an AMD module wants
  15695. // to call noConflict to hide this version of jQuery, it will work.
  15696. // Note that for maximum portability, libraries that are not jQuery should
  15697. // declare themselves as anonymous modules, and avoid setting a global if an
  15698. // AMD loader is present. jQuery is a special case. For more information, see
  15699. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15700. if ( true ) {
  15701. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15702. return jQuery;
  15703. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15704. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15705. }
  15706. var
  15707. // Map over jQuery in case of overwrite
  15708. _jQuery = window.jQuery,
  15709. // Map over the $ in case of overwrite
  15710. _$ = window.$;
  15711. jQuery.noConflict = function( deep ) {
  15712. if ( window.$ === jQuery ) {
  15713. window.$ = _$;
  15714. }
  15715. if ( deep && window.jQuery === jQuery ) {
  15716. window.jQuery = _jQuery;
  15717. }
  15718. return jQuery;
  15719. };
  15720. // Expose jQuery and $ identifiers, even in AMD
  15721. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15722. // and CommonJS for browser emulators (#13566)
  15723. if ( !noGlobal ) {
  15724. window.jQuery = window.$ = jQuery;
  15725. }
  15726. return jQuery;
  15727. } );
  15728. /***/ }),
  15729. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15730. /*!************************************************!*\
  15731. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15732. \************************************************/
  15733. /*! exports provided: default */
  15734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15735. "use strict";
  15736. __webpack_require__.r(__webpack_exports__);
  15737. var classCallCheck = function (instance, Constructor) {
  15738. if (!(instance instanceof Constructor)) {
  15739. throw new TypeError("Cannot call a class as a function");
  15740. }
  15741. };
  15742. var createClass = function () {
  15743. function defineProperties(target, props) {
  15744. for (var i = 0; i < props.length; i++) {
  15745. var descriptor = props[i];
  15746. descriptor.enumerable = descriptor.enumerable || false;
  15747. descriptor.configurable = true;
  15748. if ("value" in descriptor) descriptor.writable = true;
  15749. Object.defineProperty(target, descriptor.key, descriptor);
  15750. }
  15751. }
  15752. return function (Constructor, protoProps, staticProps) {
  15753. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15754. if (staticProps) defineProperties(Constructor, staticProps);
  15755. return Constructor;
  15756. };
  15757. }();
  15758. var _extends = Object.assign || function (target) {
  15759. for (var i = 1; i < arguments.length; i++) {
  15760. var source = arguments[i];
  15761. for (var key in source) {
  15762. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15763. target[key] = source[key];
  15764. }
  15765. }
  15766. }
  15767. return target;
  15768. };
  15769. var inherits = function (subClass, superClass) {
  15770. if (typeof superClass !== "function" && superClass !== null) {
  15771. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15772. }
  15773. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15774. constructor: {
  15775. value: subClass,
  15776. enumerable: false,
  15777. writable: true,
  15778. configurable: true
  15779. }
  15780. });
  15781. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15782. };
  15783. var possibleConstructorReturn = function (self, call) {
  15784. if (!self) {
  15785. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15786. }
  15787. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15788. };
  15789. var Connector = function () {
  15790. /**
  15791. * Create a new class instance.
  15792. */
  15793. function Connector(options) {
  15794. classCallCheck(this, Connector);
  15795. /**
  15796. * Default connector options.
  15797. */
  15798. this._defaultOptions = {
  15799. auth: {
  15800. headers: {}
  15801. },
  15802. authEndpoint: '/broadcasting/auth',
  15803. broadcaster: 'pusher',
  15804. csrfToken: null,
  15805. host: null,
  15806. key: null,
  15807. namespace: 'App.Events'
  15808. };
  15809. this.setOptions(options);
  15810. this.connect();
  15811. }
  15812. /**
  15813. * Merge the custom options with the defaults.
  15814. */
  15815. createClass(Connector, [{
  15816. key: 'setOptions',
  15817. value: function setOptions(options) {
  15818. this.options = _extends(this._defaultOptions, options);
  15819. if (this.csrfToken()) {
  15820. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15821. }
  15822. return options;
  15823. }
  15824. /**
  15825. * Extract the CSRF token from the page.
  15826. */
  15827. }, {
  15828. key: 'csrfToken',
  15829. value: function csrfToken() {
  15830. var selector = void 0;
  15831. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15832. return window['Laravel'].csrfToken;
  15833. } else if (this.options.csrfToken) {
  15834. return this.options.csrfToken;
  15835. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15836. return selector.getAttribute('content');
  15837. }
  15838. return null;
  15839. }
  15840. }]);
  15841. return Connector;
  15842. }();
  15843. /**
  15844. * This class represents a basic channel.
  15845. */
  15846. var Channel = function () {
  15847. function Channel() {
  15848. classCallCheck(this, Channel);
  15849. }
  15850. createClass(Channel, [{
  15851. key: 'listenForWhisper',
  15852. /**
  15853. * Listen for a whisper event on the channel instance.
  15854. */
  15855. value: function listenForWhisper(event, callback) {
  15856. return this.listen('.client-' + event, callback);
  15857. }
  15858. /**
  15859. * Listen for an event on the channel instance.
  15860. */
  15861. }, {
  15862. key: 'notification',
  15863. value: function notification(callback) {
  15864. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15865. }
  15866. /**
  15867. * Stop listening for a whispser event on the channel instance.
  15868. */
  15869. }, {
  15870. key: 'stopListeningForWhisper',
  15871. value: function stopListeningForWhisper(event) {
  15872. return this.stopListening('.client-' + event);
  15873. }
  15874. }]);
  15875. return Channel;
  15876. }();
  15877. /**
  15878. * Event name formatter
  15879. */
  15880. var EventFormatter = function () {
  15881. /**
  15882. * Create a new class instance.
  15883. */
  15884. function EventFormatter(namespace) {
  15885. classCallCheck(this, EventFormatter);
  15886. this.setNamespace(namespace);
  15887. }
  15888. /**
  15889. * Format the given event name.
  15890. */
  15891. createClass(EventFormatter, [{
  15892. key: 'format',
  15893. value: function format(event) {
  15894. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15895. return event.substr(1);
  15896. } else if (this.namespace) {
  15897. event = this.namespace + '.' + event;
  15898. }
  15899. return event.replace(/\./g, '\\');
  15900. }
  15901. /**
  15902. * Set the event namespace.
  15903. */
  15904. }, {
  15905. key: 'setNamespace',
  15906. value: function setNamespace(value) {
  15907. this.namespace = value;
  15908. }
  15909. }]);
  15910. return EventFormatter;
  15911. }();
  15912. /**
  15913. * This class represents a Pusher channel.
  15914. */
  15915. var PusherChannel = function (_Channel) {
  15916. inherits(PusherChannel, _Channel);
  15917. /**
  15918. * Create a new class instance.
  15919. */
  15920. function PusherChannel(pusher, name, options) {
  15921. classCallCheck(this, PusherChannel);
  15922. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15923. _this.name = name;
  15924. _this.pusher = pusher;
  15925. _this.options = options;
  15926. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15927. _this.subscribe();
  15928. return _this;
  15929. }
  15930. /**
  15931. * Subscribe to a Pusher channel.
  15932. */
  15933. createClass(PusherChannel, [{
  15934. key: 'subscribe',
  15935. value: function subscribe() {
  15936. this.subscription = this.pusher.subscribe(this.name);
  15937. }
  15938. /**
  15939. * Unsubscribe from a Pusher channel.
  15940. */
  15941. }, {
  15942. key: 'unsubscribe',
  15943. value: function unsubscribe() {
  15944. this.pusher.unsubscribe(this.name);
  15945. }
  15946. /**
  15947. * Listen for an event on the channel instance.
  15948. */
  15949. }, {
  15950. key: 'listen',
  15951. value: function listen(event, callback) {
  15952. this.on(this.eventFormatter.format(event), callback);
  15953. return this;
  15954. }
  15955. /**
  15956. * Stop listening for an event on the channel instance.
  15957. */
  15958. }, {
  15959. key: 'stopListening',
  15960. value: function stopListening(event) {
  15961. this.subscription.unbind(this.eventFormatter.format(event));
  15962. return this;
  15963. }
  15964. /**
  15965. * Bind a channel to an event.
  15966. */
  15967. }, {
  15968. key: 'on',
  15969. value: function on(event, callback) {
  15970. this.subscription.bind(event, callback);
  15971. return this;
  15972. }
  15973. }]);
  15974. return PusherChannel;
  15975. }(Channel);
  15976. /**
  15977. * This class represents a Pusher private channel.
  15978. */
  15979. var PusherPrivateChannel = function (_PusherChannel) {
  15980. inherits(PusherPrivateChannel, _PusherChannel);
  15981. function PusherPrivateChannel() {
  15982. classCallCheck(this, PusherPrivateChannel);
  15983. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  15984. }
  15985. createClass(PusherPrivateChannel, [{
  15986. key: 'whisper',
  15987. /**
  15988. * Trigger client event on the channel.
  15989. */
  15990. value: function whisper(eventName, data) {
  15991. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  15992. return this;
  15993. }
  15994. }]);
  15995. return PusherPrivateChannel;
  15996. }(PusherChannel);
  15997. /**
  15998. * This class represents a Pusher presence channel.
  15999. */
  16000. var PusherPresenceChannel = function (_PusherChannel) {
  16001. inherits(PusherPresenceChannel, _PusherChannel);
  16002. function PusherPresenceChannel() {
  16003. classCallCheck(this, PusherPresenceChannel);
  16004. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16005. }
  16006. createClass(PusherPresenceChannel, [{
  16007. key: 'here',
  16008. /**
  16009. * Register a callback to be called anytime the member list changes.
  16010. */
  16011. value: function here(callback) {
  16012. this.on('pusher:subscription_succeeded', function (data) {
  16013. callback(Object.keys(data.members).map(function (k) {
  16014. return data.members[k];
  16015. }));
  16016. });
  16017. return this;
  16018. }
  16019. /**
  16020. * Listen for someone joining the channel.
  16021. */
  16022. }, {
  16023. key: 'joining',
  16024. value: function joining(callback) {
  16025. this.on('pusher:member_added', function (member) {
  16026. callback(member.info);
  16027. });
  16028. return this;
  16029. }
  16030. /**
  16031. * Listen for someone leaving the channel.
  16032. */
  16033. }, {
  16034. key: 'leaving',
  16035. value: function leaving(callback) {
  16036. this.on('pusher:member_removed', function (member) {
  16037. callback(member.info);
  16038. });
  16039. return this;
  16040. }
  16041. /**
  16042. * Trigger client event on the channel.
  16043. */
  16044. }, {
  16045. key: 'whisper',
  16046. value: function whisper(eventName, data) {
  16047. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16048. return this;
  16049. }
  16050. }]);
  16051. return PusherPresenceChannel;
  16052. }(PusherChannel);
  16053. /**
  16054. * This class represents a Socket.io channel.
  16055. */
  16056. var SocketIoChannel = function (_Channel) {
  16057. inherits(SocketIoChannel, _Channel);
  16058. /**
  16059. * Create a new class instance.
  16060. */
  16061. function SocketIoChannel(socket, name, options) {
  16062. classCallCheck(this, SocketIoChannel);
  16063. /**
  16064. * The event callbacks applied to the channel.
  16065. */
  16066. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16067. _this.events = {};
  16068. _this.name = name;
  16069. _this.socket = socket;
  16070. _this.options = options;
  16071. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16072. _this.subscribe();
  16073. _this.configureReconnector();
  16074. return _this;
  16075. }
  16076. /**
  16077. * Subscribe to a Socket.io channel.
  16078. */
  16079. createClass(SocketIoChannel, [{
  16080. key: 'subscribe',
  16081. value: function subscribe() {
  16082. this.socket.emit('subscribe', {
  16083. channel: this.name,
  16084. auth: this.options.auth || {}
  16085. });
  16086. }
  16087. /**
  16088. * Unsubscribe from channel and ubind event callbacks.
  16089. */
  16090. }, {
  16091. key: 'unsubscribe',
  16092. value: function unsubscribe() {
  16093. this.unbind();
  16094. this.socket.emit('unsubscribe', {
  16095. channel: this.name,
  16096. auth: this.options.auth || {}
  16097. });
  16098. }
  16099. /**
  16100. * Listen for an event on the channel instance.
  16101. */
  16102. }, {
  16103. key: 'listen',
  16104. value: function listen(event, callback) {
  16105. this.on(this.eventFormatter.format(event), callback);
  16106. return this;
  16107. }
  16108. /**
  16109. * Stop listening for an event on the channel instance.
  16110. */
  16111. }, {
  16112. key: 'stopListening',
  16113. value: function stopListening(event) {
  16114. var name = this.eventFormatter.format(event);
  16115. this.socket.removeListener(name);
  16116. delete this.events[name];
  16117. return this;
  16118. }
  16119. /**
  16120. * Bind the channel's socket to an event and store the callback.
  16121. */
  16122. }, {
  16123. key: 'on',
  16124. value: function on(event, callback) {
  16125. var _this2 = this;
  16126. var listener = function listener(channel, data) {
  16127. if (_this2.name == channel) {
  16128. callback(data);
  16129. }
  16130. };
  16131. this.socket.on(event, listener);
  16132. this.bind(event, listener);
  16133. }
  16134. /**
  16135. * Attach a 'reconnect' listener and bind the event.
  16136. */
  16137. }, {
  16138. key: 'configureReconnector',
  16139. value: function configureReconnector() {
  16140. var _this3 = this;
  16141. var listener = function listener() {
  16142. _this3.subscribe();
  16143. };
  16144. this.socket.on('reconnect', listener);
  16145. this.bind('reconnect', listener);
  16146. }
  16147. /**
  16148. * Bind the channel's socket to an event and store the callback.
  16149. */
  16150. }, {
  16151. key: 'bind',
  16152. value: function bind(event, callback) {
  16153. this.events[event] = this.events[event] || [];
  16154. this.events[event].push(callback);
  16155. }
  16156. /**
  16157. * Unbind the channel's socket from all stored event callbacks.
  16158. */
  16159. }, {
  16160. key: 'unbind',
  16161. value: function unbind() {
  16162. var _this4 = this;
  16163. Object.keys(this.events).forEach(function (event) {
  16164. _this4.events[event].forEach(function (callback) {
  16165. _this4.socket.removeListener(event, callback);
  16166. });
  16167. delete _this4.events[event];
  16168. });
  16169. }
  16170. }]);
  16171. return SocketIoChannel;
  16172. }(Channel);
  16173. /**
  16174. * This class represents a Socket.io presence channel.
  16175. */
  16176. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16177. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16178. function SocketIoPrivateChannel() {
  16179. classCallCheck(this, SocketIoPrivateChannel);
  16180. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16181. }
  16182. createClass(SocketIoPrivateChannel, [{
  16183. key: 'whisper',
  16184. /**
  16185. * Trigger client event on the channel.
  16186. */
  16187. value: function whisper(eventName, data) {
  16188. this.socket.emit('client event', {
  16189. channel: this.name,
  16190. event: 'client-' + eventName,
  16191. data: data
  16192. });
  16193. return this;
  16194. }
  16195. }]);
  16196. return SocketIoPrivateChannel;
  16197. }(SocketIoChannel);
  16198. /**
  16199. * This class represents a Socket.io presence channel.
  16200. */
  16201. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16202. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16203. function SocketIoPresenceChannel() {
  16204. classCallCheck(this, SocketIoPresenceChannel);
  16205. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16206. }
  16207. createClass(SocketIoPresenceChannel, [{
  16208. key: 'here',
  16209. /**
  16210. * Register a callback to be called anytime the member list changes.
  16211. */
  16212. value: function here(callback) {
  16213. this.on('presence:subscribed', function (members) {
  16214. callback(members.map(function (m) {
  16215. return m.user_info;
  16216. }));
  16217. });
  16218. return this;
  16219. }
  16220. /**
  16221. * Listen for someone joining the channel.
  16222. */
  16223. }, {
  16224. key: 'joining',
  16225. value: function joining(callback) {
  16226. this.on('presence:joining', function (member) {
  16227. return callback(member.user_info);
  16228. });
  16229. return this;
  16230. }
  16231. /**
  16232. * Listen for someone leaving the channel.
  16233. */
  16234. }, {
  16235. key: 'leaving',
  16236. value: function leaving(callback) {
  16237. this.on('presence:leaving', function (member) {
  16238. return callback(member.user_info);
  16239. });
  16240. return this;
  16241. }
  16242. }]);
  16243. return SocketIoPresenceChannel;
  16244. }(SocketIoPrivateChannel);
  16245. /**
  16246. * This class represents a null channel.
  16247. */
  16248. var NullChannel = function (_Channel) {
  16249. inherits(NullChannel, _Channel);
  16250. function NullChannel() {
  16251. classCallCheck(this, NullChannel);
  16252. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16253. }
  16254. createClass(NullChannel, [{
  16255. key: 'subscribe',
  16256. /**
  16257. * Subscribe to a channel.
  16258. */
  16259. value: function subscribe() {}
  16260. //
  16261. /**
  16262. * Unsubscribe from a channel.
  16263. */
  16264. }, {
  16265. key: 'unsubscribe',
  16266. value: function unsubscribe() {}
  16267. //
  16268. /**
  16269. * Listen for an event on the channel instance.
  16270. */
  16271. }, {
  16272. key: 'listen',
  16273. value: function listen(event, callback) {
  16274. return this;
  16275. }
  16276. /**
  16277. * Stop listening for an event on the channel instance.
  16278. */
  16279. }, {
  16280. key: 'stopListening',
  16281. value: function stopListening(event) {
  16282. return this;
  16283. }
  16284. /**
  16285. * Bind a channel to an event.
  16286. */
  16287. }, {
  16288. key: 'on',
  16289. value: function on(event, callback) {
  16290. return this;
  16291. }
  16292. }]);
  16293. return NullChannel;
  16294. }(Channel);
  16295. /**
  16296. * This class represents a null private channel.
  16297. */
  16298. var NullPrivateChannel = function (_NullChannel) {
  16299. inherits(NullPrivateChannel, _NullChannel);
  16300. function NullPrivateChannel() {
  16301. classCallCheck(this, NullPrivateChannel);
  16302. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16303. }
  16304. createClass(NullPrivateChannel, [{
  16305. key: 'whisper',
  16306. /**
  16307. * Trigger client event on the channel.
  16308. */
  16309. value: function whisper(eventName, data) {
  16310. return this;
  16311. }
  16312. }]);
  16313. return NullPrivateChannel;
  16314. }(NullChannel);
  16315. /**
  16316. * This class represents a null presence channel.
  16317. */
  16318. var NullPresenceChannel = function (_NullChannel) {
  16319. inherits(NullPresenceChannel, _NullChannel);
  16320. function NullPresenceChannel() {
  16321. classCallCheck(this, NullPresenceChannel);
  16322. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16323. }
  16324. createClass(NullPresenceChannel, [{
  16325. key: 'here',
  16326. /**
  16327. * Register a callback to be called anytime the member list changes.
  16328. */
  16329. value: function here(callback) {
  16330. return this;
  16331. }
  16332. /**
  16333. * Listen for someone joining the channel.
  16334. */
  16335. }, {
  16336. key: 'joining',
  16337. value: function joining(callback) {
  16338. return this;
  16339. }
  16340. /**
  16341. * Listen for someone leaving the channel.
  16342. */
  16343. }, {
  16344. key: 'leaving',
  16345. value: function leaving(callback) {
  16346. return this;
  16347. }
  16348. /**
  16349. * Trigger client event on the channel.
  16350. */
  16351. }, {
  16352. key: 'whisper',
  16353. value: function whisper(eventName, data) {
  16354. return this;
  16355. }
  16356. }]);
  16357. return NullPresenceChannel;
  16358. }(NullChannel);
  16359. /**
  16360. * This class creates a connector to Pusher.
  16361. */
  16362. var PusherConnector = function (_Connector) {
  16363. inherits(PusherConnector, _Connector);
  16364. function PusherConnector() {
  16365. classCallCheck(this, PusherConnector);
  16366. /**
  16367. * All of the subscribed channel names.
  16368. */
  16369. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16370. _this.channels = {};
  16371. return _this;
  16372. }
  16373. /**
  16374. * Create a fresh Pusher connection.
  16375. */
  16376. createClass(PusherConnector, [{
  16377. key: 'connect',
  16378. value: function connect() {
  16379. if (typeof this.options.client !== 'undefined') {
  16380. this.pusher = this.options.client;
  16381. } else {
  16382. this.pusher = new Pusher(this.options.key, this.options);
  16383. }
  16384. }
  16385. /**
  16386. * Listen for an event on a channel instance.
  16387. */
  16388. }, {
  16389. key: 'listen',
  16390. value: function listen(name, event, callback) {
  16391. return this.channel(name).listen(event, callback);
  16392. }
  16393. /**
  16394. * Get a channel instance by name.
  16395. */
  16396. }, {
  16397. key: 'channel',
  16398. value: function channel(name) {
  16399. if (!this.channels[name]) {
  16400. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16401. }
  16402. return this.channels[name];
  16403. }
  16404. /**
  16405. * Get a private channel instance by name.
  16406. */
  16407. }, {
  16408. key: 'privateChannel',
  16409. value: function privateChannel(name) {
  16410. if (!this.channels['private-' + name]) {
  16411. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16412. }
  16413. return this.channels['private-' + name];
  16414. }
  16415. /**
  16416. * Get a presence channel instance by name.
  16417. */
  16418. }, {
  16419. key: 'presenceChannel',
  16420. value: function presenceChannel(name) {
  16421. if (!this.channels['presence-' + name]) {
  16422. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16423. }
  16424. return this.channels['presence-' + name];
  16425. }
  16426. /**
  16427. * Leave the given channel, as well as its private and presence variants.
  16428. */
  16429. }, {
  16430. key: 'leave',
  16431. value: function leave(name) {
  16432. var _this2 = this;
  16433. var channels = [name, 'private-' + name, 'presence-' + name];
  16434. channels.forEach(function (name, index) {
  16435. _this2.leaveChannel(name);
  16436. });
  16437. }
  16438. /**
  16439. * Leave the given channel.
  16440. */
  16441. }, {
  16442. key: 'leaveChannel',
  16443. value: function leaveChannel(name) {
  16444. if (this.channels[name]) {
  16445. this.channels[name].unsubscribe();
  16446. delete this.channels[name];
  16447. }
  16448. }
  16449. /**
  16450. * Get the socket ID for the connection.
  16451. */
  16452. }, {
  16453. key: 'socketId',
  16454. value: function socketId() {
  16455. return this.pusher.connection.socket_id;
  16456. }
  16457. /**
  16458. * Disconnect Pusher connection.
  16459. */
  16460. }, {
  16461. key: 'disconnect',
  16462. value: function disconnect() {
  16463. this.pusher.disconnect();
  16464. }
  16465. }]);
  16466. return PusherConnector;
  16467. }(Connector);
  16468. /**
  16469. * This class creates a connnector to a Socket.io server.
  16470. */
  16471. var SocketIoConnector = function (_Connector) {
  16472. inherits(SocketIoConnector, _Connector);
  16473. function SocketIoConnector() {
  16474. classCallCheck(this, SocketIoConnector);
  16475. /**
  16476. * All of the subscribed channel names.
  16477. */
  16478. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16479. _this.channels = {};
  16480. return _this;
  16481. }
  16482. /**
  16483. * Create a fresh Socket.io connection.
  16484. */
  16485. createClass(SocketIoConnector, [{
  16486. key: 'connect',
  16487. value: function connect() {
  16488. var io = this.getSocketIO();
  16489. this.socket = io(this.options.host, this.options);
  16490. return this.socket;
  16491. }
  16492. /**
  16493. * Get socket.io module from global scope or options.
  16494. */
  16495. }, {
  16496. key: 'getSocketIO',
  16497. value: function getSocketIO() {
  16498. if (typeof this.options.client !== 'undefined') {
  16499. return this.options.client;
  16500. }
  16501. if (typeof io !== 'undefined') {
  16502. return io;
  16503. }
  16504. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16505. }
  16506. /**
  16507. * Listen for an event on a channel instance.
  16508. */
  16509. }, {
  16510. key: 'listen',
  16511. value: function listen(name, event, callback) {
  16512. return this.channel(name).listen(event, callback);
  16513. }
  16514. /**
  16515. * Get a channel instance by name.
  16516. */
  16517. }, {
  16518. key: 'channel',
  16519. value: function channel(name) {
  16520. if (!this.channels[name]) {
  16521. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16522. }
  16523. return this.channels[name];
  16524. }
  16525. /**
  16526. * Get a private channel instance by name.
  16527. */
  16528. }, {
  16529. key: 'privateChannel',
  16530. value: function privateChannel(name) {
  16531. if (!this.channels['private-' + name]) {
  16532. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16533. }
  16534. return this.channels['private-' + name];
  16535. }
  16536. /**
  16537. * Get a presence channel instance by name.
  16538. */
  16539. }, {
  16540. key: 'presenceChannel',
  16541. value: function presenceChannel(name) {
  16542. if (!this.channels['presence-' + name]) {
  16543. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16544. }
  16545. return this.channels['presence-' + name];
  16546. }
  16547. /**
  16548. * Leave the given channel, as well as its private and presence variants.
  16549. */
  16550. }, {
  16551. key: 'leave',
  16552. value: function leave(name) {
  16553. var _this2 = this;
  16554. var channels = [name, 'private-' + name, 'presence-' + name];
  16555. channels.forEach(function (name) {
  16556. _this2.leaveChannel(name);
  16557. });
  16558. }
  16559. /**
  16560. * Leave the given channel.
  16561. */
  16562. }, {
  16563. key: 'leaveChannel',
  16564. value: function leaveChannel(name) {
  16565. if (this.channels[name]) {
  16566. this.channels[name].unsubscribe();
  16567. delete this.channels[name];
  16568. }
  16569. }
  16570. /**
  16571. * Get the socket ID for the connection.
  16572. */
  16573. }, {
  16574. key: 'socketId',
  16575. value: function socketId() {
  16576. return this.socket.id;
  16577. }
  16578. /**
  16579. * Disconnect Socketio connection.
  16580. */
  16581. }, {
  16582. key: 'disconnect',
  16583. value: function disconnect() {
  16584. this.socket.disconnect();
  16585. }
  16586. }]);
  16587. return SocketIoConnector;
  16588. }(Connector);
  16589. /**
  16590. * This class creates a null connector.
  16591. */
  16592. var NullConnector = function (_Connector) {
  16593. inherits(NullConnector, _Connector);
  16594. function NullConnector() {
  16595. classCallCheck(this, NullConnector);
  16596. /**
  16597. * All of the subscribed channel names.
  16598. */
  16599. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16600. _this.channels = {};
  16601. return _this;
  16602. }
  16603. /**
  16604. * Create a fresh connection.
  16605. */
  16606. createClass(NullConnector, [{
  16607. key: 'connect',
  16608. value: function connect() {}
  16609. //
  16610. /**
  16611. * Listen for an event on a channel instance.
  16612. */
  16613. }, {
  16614. key: 'listen',
  16615. value: function listen(name, event, callback) {
  16616. return new NullChannel();
  16617. }
  16618. /**
  16619. * Get a channel instance by name.
  16620. */
  16621. }, {
  16622. key: 'channel',
  16623. value: function channel(name) {
  16624. return new NullChannel();
  16625. }
  16626. /**
  16627. * Get a private channel instance by name.
  16628. */
  16629. }, {
  16630. key: 'privateChannel',
  16631. value: function privateChannel(name) {
  16632. return new NullPrivateChannel();
  16633. }
  16634. /**
  16635. * Get a presence channel instance by name.
  16636. */
  16637. }, {
  16638. key: 'presenceChannel',
  16639. value: function presenceChannel(name) {
  16640. return new NullPresenceChannel();
  16641. }
  16642. /**
  16643. * Leave the given channel, as well as its private and presence variants.
  16644. */
  16645. }, {
  16646. key: 'leave',
  16647. value: function leave(name) {}
  16648. //
  16649. /**
  16650. * Leave the given channel.
  16651. */
  16652. }, {
  16653. key: 'leaveChannel',
  16654. value: function leaveChannel(name) {}
  16655. //
  16656. /**
  16657. * Get the socket ID for the connection.
  16658. */
  16659. }, {
  16660. key: 'socketId',
  16661. value: function socketId() {
  16662. return 'fake-socket-id';
  16663. }
  16664. /**
  16665. * Disconnect the connection.
  16666. */
  16667. }, {
  16668. key: 'disconnect',
  16669. value: function disconnect() {
  16670. //
  16671. }
  16672. }]);
  16673. return NullConnector;
  16674. }(Connector);
  16675. /**
  16676. * This class is the primary API for interacting with broadcasting.
  16677. */
  16678. var Echo = function () {
  16679. /**
  16680. * Create a new class instance.
  16681. */
  16682. function Echo(options) {
  16683. classCallCheck(this, Echo);
  16684. this.options = options;
  16685. this.connect();
  16686. if (!this.options.withoutInterceptors) {
  16687. this.registerInterceptors();
  16688. }
  16689. }
  16690. /**
  16691. * Get a channel instance by name.
  16692. */
  16693. createClass(Echo, [{
  16694. key: 'channel',
  16695. value: function channel(_channel) {
  16696. return this.connector.channel(_channel);
  16697. }
  16698. /**
  16699. * Create a new connection.
  16700. */
  16701. }, {
  16702. key: 'connect',
  16703. value: function connect() {
  16704. if (this.options.broadcaster == 'pusher') {
  16705. this.connector = new PusherConnector(this.options);
  16706. } else if (this.options.broadcaster == 'socket.io') {
  16707. this.connector = new SocketIoConnector(this.options);
  16708. } else if (this.options.broadcaster == 'null') {
  16709. this.connector = new NullConnector(this.options);
  16710. } else if (typeof this.options.broadcaster == 'function') {
  16711. this.connector = new this.options.broadcaster(this.options);
  16712. }
  16713. }
  16714. /**
  16715. * Disconnect from the Echo server.
  16716. */
  16717. }, {
  16718. key: 'disconnect',
  16719. value: function disconnect() {
  16720. this.connector.disconnect();
  16721. }
  16722. /**
  16723. * Get a presence channel instance by name.
  16724. */
  16725. }, {
  16726. key: 'join',
  16727. value: function join(channel) {
  16728. return this.connector.presenceChannel(channel);
  16729. }
  16730. /**
  16731. * Leave the given channel, as well as its private and presence variants.
  16732. */
  16733. }, {
  16734. key: 'leave',
  16735. value: function leave(channel) {
  16736. this.connector.leave(channel);
  16737. }
  16738. /**
  16739. * Leave the given channel.
  16740. */
  16741. }, {
  16742. key: 'leaveChannel',
  16743. value: function leaveChannel(channel) {
  16744. this.connector.leaveChannel(channel);
  16745. }
  16746. /**
  16747. * Listen for an event on a channel instance.
  16748. */
  16749. }, {
  16750. key: 'listen',
  16751. value: function listen(channel, event, callback) {
  16752. return this.connector.listen(channel, event, callback);
  16753. }
  16754. /**
  16755. * Get a private channel instance by name.
  16756. */
  16757. }, {
  16758. key: 'private',
  16759. value: function _private(channel) {
  16760. return this.connector.privateChannel(channel);
  16761. }
  16762. /**
  16763. * Get the Socket ID for the connection.
  16764. */
  16765. }, {
  16766. key: 'socketId',
  16767. value: function socketId() {
  16768. return this.connector.socketId();
  16769. }
  16770. /**
  16771. * Register 3rd party request interceptiors. These are used to automatically
  16772. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16773. */
  16774. }, {
  16775. key: 'registerInterceptors',
  16776. value: function registerInterceptors() {
  16777. if (typeof Vue === 'function' && Vue.http) {
  16778. this.registerVueRequestInterceptor();
  16779. }
  16780. if (typeof axios === 'function') {
  16781. this.registerAxiosRequestInterceptor();
  16782. }
  16783. if (typeof jQuery === 'function') {
  16784. this.registerjQueryAjaxSetup();
  16785. }
  16786. }
  16787. /**
  16788. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16789. */
  16790. }, {
  16791. key: 'registerVueRequestInterceptor',
  16792. value: function registerVueRequestInterceptor() {
  16793. var _this = this;
  16794. Vue.http.interceptors.push(function (request, next) {
  16795. if (_this.socketId()) {
  16796. request.headers.set('X-Socket-ID', _this.socketId());
  16797. }
  16798. next();
  16799. });
  16800. }
  16801. /**
  16802. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16803. */
  16804. }, {
  16805. key: 'registerAxiosRequestInterceptor',
  16806. value: function registerAxiosRequestInterceptor() {
  16807. var _this2 = this;
  16808. axios.interceptors.request.use(function (config) {
  16809. if (_this2.socketId()) {
  16810. config.headers['X-Socket-Id'] = _this2.socketId();
  16811. }
  16812. return config;
  16813. });
  16814. }
  16815. /**
  16816. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16817. */
  16818. }, {
  16819. key: 'registerjQueryAjaxSetup',
  16820. value: function registerjQueryAjaxSetup() {
  16821. var _this3 = this;
  16822. if (typeof jQuery.ajax != 'undefined') {
  16823. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16824. if (_this3.socketId()) {
  16825. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16826. }
  16827. });
  16828. }
  16829. }
  16830. }]);
  16831. return Echo;
  16832. }();
  16833. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16834. /***/ }),
  16835. /***/ "./node_modules/lodash/lodash.js":
  16836. /*!***************************************!*\
  16837. !*** ./node_modules/lodash/lodash.js ***!
  16838. \***************************************/
  16839. /*! no static exports found */
  16840. /***/ (function(module, exports, __webpack_require__) {
  16841. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16842. * @license
  16843. * Lodash <https://lodash.com/>
  16844. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16845. * Released under MIT license <https://lodash.com/license>
  16846. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16847. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16848. */
  16849. ;(function() {
  16850. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16851. var undefined;
  16852. /** Used as the semantic version number. */
  16853. var VERSION = '4.17.15';
  16854. /** Used as the size to enable large array optimizations. */
  16855. var LARGE_ARRAY_SIZE = 200;
  16856. /** Error message constants. */
  16857. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16858. FUNC_ERROR_TEXT = 'Expected a function';
  16859. /** Used to stand-in for `undefined` hash values. */
  16860. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16861. /** Used as the maximum memoize cache size. */
  16862. var MAX_MEMOIZE_SIZE = 500;
  16863. /** Used as the internal argument placeholder. */
  16864. var PLACEHOLDER = '__lodash_placeholder__';
  16865. /** Used to compose bitmasks for cloning. */
  16866. var CLONE_DEEP_FLAG = 1,
  16867. CLONE_FLAT_FLAG = 2,
  16868. CLONE_SYMBOLS_FLAG = 4;
  16869. /** Used to compose bitmasks for value comparisons. */
  16870. var COMPARE_PARTIAL_FLAG = 1,
  16871. COMPARE_UNORDERED_FLAG = 2;
  16872. /** Used to compose bitmasks for function metadata. */
  16873. var WRAP_BIND_FLAG = 1,
  16874. WRAP_BIND_KEY_FLAG = 2,
  16875. WRAP_CURRY_BOUND_FLAG = 4,
  16876. WRAP_CURRY_FLAG = 8,
  16877. WRAP_CURRY_RIGHT_FLAG = 16,
  16878. WRAP_PARTIAL_FLAG = 32,
  16879. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16880. WRAP_ARY_FLAG = 128,
  16881. WRAP_REARG_FLAG = 256,
  16882. WRAP_FLIP_FLAG = 512;
  16883. /** Used as default options for `_.truncate`. */
  16884. var DEFAULT_TRUNC_LENGTH = 30,
  16885. DEFAULT_TRUNC_OMISSION = '...';
  16886. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16887. var HOT_COUNT = 800,
  16888. HOT_SPAN = 16;
  16889. /** Used to indicate the type of lazy iteratees. */
  16890. var LAZY_FILTER_FLAG = 1,
  16891. LAZY_MAP_FLAG = 2,
  16892. LAZY_WHILE_FLAG = 3;
  16893. /** Used as references for various `Number` constants. */
  16894. var INFINITY = 1 / 0,
  16895. MAX_SAFE_INTEGER = 9007199254740991,
  16896. MAX_INTEGER = 1.7976931348623157e+308,
  16897. NAN = 0 / 0;
  16898. /** Used as references for the maximum length and index of an array. */
  16899. var MAX_ARRAY_LENGTH = 4294967295,
  16900. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16901. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16902. /** Used to associate wrap methods with their bit flags. */
  16903. var wrapFlags = [
  16904. ['ary', WRAP_ARY_FLAG],
  16905. ['bind', WRAP_BIND_FLAG],
  16906. ['bindKey', WRAP_BIND_KEY_FLAG],
  16907. ['curry', WRAP_CURRY_FLAG],
  16908. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16909. ['flip', WRAP_FLIP_FLAG],
  16910. ['partial', WRAP_PARTIAL_FLAG],
  16911. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16912. ['rearg', WRAP_REARG_FLAG]
  16913. ];
  16914. /** `Object#toString` result references. */
  16915. var argsTag = '[object Arguments]',
  16916. arrayTag = '[object Array]',
  16917. asyncTag = '[object AsyncFunction]',
  16918. boolTag = '[object Boolean]',
  16919. dateTag = '[object Date]',
  16920. domExcTag = '[object DOMException]',
  16921. errorTag = '[object Error]',
  16922. funcTag = '[object Function]',
  16923. genTag = '[object GeneratorFunction]',
  16924. mapTag = '[object Map]',
  16925. numberTag = '[object Number]',
  16926. nullTag = '[object Null]',
  16927. objectTag = '[object Object]',
  16928. promiseTag = '[object Promise]',
  16929. proxyTag = '[object Proxy]',
  16930. regexpTag = '[object RegExp]',
  16931. setTag = '[object Set]',
  16932. stringTag = '[object String]',
  16933. symbolTag = '[object Symbol]',
  16934. undefinedTag = '[object Undefined]',
  16935. weakMapTag = '[object WeakMap]',
  16936. weakSetTag = '[object WeakSet]';
  16937. var arrayBufferTag = '[object ArrayBuffer]',
  16938. dataViewTag = '[object DataView]',
  16939. float32Tag = '[object Float32Array]',
  16940. float64Tag = '[object Float64Array]',
  16941. int8Tag = '[object Int8Array]',
  16942. int16Tag = '[object Int16Array]',
  16943. int32Tag = '[object Int32Array]',
  16944. uint8Tag = '[object Uint8Array]',
  16945. uint8ClampedTag = '[object Uint8ClampedArray]',
  16946. uint16Tag = '[object Uint16Array]',
  16947. uint32Tag = '[object Uint32Array]';
  16948. /** Used to match empty string literals in compiled template source. */
  16949. var reEmptyStringLeading = /\b__p \+= '';/g,
  16950. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16951. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16952. /** Used to match HTML entities and HTML characters. */
  16953. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16954. reUnescapedHtml = /[&<>"']/g,
  16955. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  16956. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  16957. /** Used to match template delimiters. */
  16958. var reEscape = /<%-([\s\S]+?)%>/g,
  16959. reEvaluate = /<%([\s\S]+?)%>/g,
  16960. reInterpolate = /<%=([\s\S]+?)%>/g;
  16961. /** Used to match property names within property paths. */
  16962. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  16963. reIsPlainProp = /^\w*$/,
  16964. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  16965. /**
  16966. * Used to match `RegExp`
  16967. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  16968. */
  16969. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  16970. reHasRegExpChar = RegExp(reRegExpChar.source);
  16971. /** Used to match leading and trailing whitespace. */
  16972. var reTrim = /^\s+|\s+$/g,
  16973. reTrimStart = /^\s+/,
  16974. reTrimEnd = /\s+$/;
  16975. /** Used to match wrap detail comments. */
  16976. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  16977. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  16978. reSplitDetails = /,? & /;
  16979. /** Used to match words composed of alphanumeric characters. */
  16980. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  16981. /** Used to match backslashes in property paths. */
  16982. var reEscapeChar = /\\(\\)?/g;
  16983. /**
  16984. * Used to match
  16985. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  16986. */
  16987. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  16988. /** Used to match `RegExp` flags from their coerced string values. */
  16989. var reFlags = /\w*$/;
  16990. /** Used to detect bad signed hexadecimal string values. */
  16991. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  16992. /** Used to detect binary string values. */
  16993. var reIsBinary = /^0b[01]+$/i;
  16994. /** Used to detect host constructors (Safari). */
  16995. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  16996. /** Used to detect octal string values. */
  16997. var reIsOctal = /^0o[0-7]+$/i;
  16998. /** Used to detect unsigned integer values. */
  16999. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17000. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17001. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17002. /** Used to ensure capturing order of template delimiters. */
  17003. var reNoMatch = /($^)/;
  17004. /** Used to match unescaped characters in compiled string literals. */
  17005. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17006. /** Used to compose unicode character classes. */
  17007. var rsAstralRange = '\\ud800-\\udfff',
  17008. rsComboMarksRange = '\\u0300-\\u036f',
  17009. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17010. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17011. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17012. rsDingbatRange = '\\u2700-\\u27bf',
  17013. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17014. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17015. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17016. rsPunctuationRange = '\\u2000-\\u206f',
  17017. 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',
  17018. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17019. rsVarRange = '\\ufe0e\\ufe0f',
  17020. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17021. /** Used to compose unicode capture groups. */
  17022. var rsApos = "['\u2019]",
  17023. rsAstral = '[' + rsAstralRange + ']',
  17024. rsBreak = '[' + rsBreakRange + ']',
  17025. rsCombo = '[' + rsComboRange + ']',
  17026. rsDigits = '\\d+',
  17027. rsDingbat = '[' + rsDingbatRange + ']',
  17028. rsLower = '[' + rsLowerRange + ']',
  17029. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17030. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17031. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17032. rsNonAstral = '[^' + rsAstralRange + ']',
  17033. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17034. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17035. rsUpper = '[' + rsUpperRange + ']',
  17036. rsZWJ = '\\u200d';
  17037. /** Used to compose unicode regexes. */
  17038. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17039. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17040. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17041. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17042. reOptMod = rsModifier + '?',
  17043. rsOptVar = '[' + rsVarRange + ']?',
  17044. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17045. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17046. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17047. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17048. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17049. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17050. /** Used to match apostrophes. */
  17051. var reApos = RegExp(rsApos, 'g');
  17052. /**
  17053. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17054. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17055. */
  17056. var reComboMark = RegExp(rsCombo, 'g');
  17057. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17058. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17059. /** Used to match complex or compound words. */
  17060. var reUnicodeWord = RegExp([
  17061. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17062. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17063. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17064. rsUpper + '+' + rsOptContrUpper,
  17065. rsOrdUpper,
  17066. rsOrdLower,
  17067. rsDigits,
  17068. rsEmoji
  17069. ].join('|'), 'g');
  17070. /** 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/). */
  17071. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17072. /** Used to detect strings that need a more robust regexp to match words. */
  17073. 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 ]/;
  17074. /** Used to assign default `context` object properties. */
  17075. var contextProps = [
  17076. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17077. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17078. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17079. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17080. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17081. ];
  17082. /** Used to make template sourceURLs easier to identify. */
  17083. var templateCounter = -1;
  17084. /** Used to identify `toStringTag` values of typed arrays. */
  17085. var typedArrayTags = {};
  17086. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17087. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17088. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17089. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17090. typedArrayTags[uint32Tag] = true;
  17091. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17092. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17093. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17094. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17095. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17096. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17097. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17098. typedArrayTags[weakMapTag] = false;
  17099. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17100. var cloneableTags = {};
  17101. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17102. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17103. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17104. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17105. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17106. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17107. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17108. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17109. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17110. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17111. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17112. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17113. cloneableTags[weakMapTag] = false;
  17114. /** Used to map Latin Unicode letters to basic Latin letters. */
  17115. var deburredLetters = {
  17116. // Latin-1 Supplement block.
  17117. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17118. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17119. '\xc7': 'C', '\xe7': 'c',
  17120. '\xd0': 'D', '\xf0': 'd',
  17121. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17122. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17123. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17124. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17125. '\xd1': 'N', '\xf1': 'n',
  17126. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17127. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17128. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17129. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17130. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17131. '\xc6': 'Ae', '\xe6': 'ae',
  17132. '\xde': 'Th', '\xfe': 'th',
  17133. '\xdf': 'ss',
  17134. // Latin Extended-A block.
  17135. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17136. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17137. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17138. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17139. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17140. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17141. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17142. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17143. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17144. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17145. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17146. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17147. '\u0134': 'J', '\u0135': 'j',
  17148. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17149. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17150. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17151. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17152. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17153. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17154. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17155. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17156. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17157. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17158. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17159. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17160. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17161. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17162. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17163. '\u0174': 'W', '\u0175': 'w',
  17164. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17165. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17166. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17167. '\u0132': 'IJ', '\u0133': 'ij',
  17168. '\u0152': 'Oe', '\u0153': 'oe',
  17169. '\u0149': "'n", '\u017f': 's'
  17170. };
  17171. /** Used to map characters to HTML entities. */
  17172. var htmlEscapes = {
  17173. '&': '&amp;',
  17174. '<': '&lt;',
  17175. '>': '&gt;',
  17176. '"': '&quot;',
  17177. "'": '&#39;'
  17178. };
  17179. /** Used to map HTML entities to characters. */
  17180. var htmlUnescapes = {
  17181. '&amp;': '&',
  17182. '&lt;': '<',
  17183. '&gt;': '>',
  17184. '&quot;': '"',
  17185. '&#39;': "'"
  17186. };
  17187. /** Used to escape characters for inclusion in compiled string literals. */
  17188. var stringEscapes = {
  17189. '\\': '\\',
  17190. "'": "'",
  17191. '\n': 'n',
  17192. '\r': 'r',
  17193. '\u2028': 'u2028',
  17194. '\u2029': 'u2029'
  17195. };
  17196. /** Built-in method references without a dependency on `root`. */
  17197. var freeParseFloat = parseFloat,
  17198. freeParseInt = parseInt;
  17199. /** Detect free variable `global` from Node.js. */
  17200. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17201. /** Detect free variable `self`. */
  17202. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17203. /** Used as a reference to the global object. */
  17204. var root = freeGlobal || freeSelf || Function('return this')();
  17205. /** Detect free variable `exports`. */
  17206. var freeExports = true && exports && !exports.nodeType && exports;
  17207. /** Detect free variable `module`. */
  17208. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17209. /** Detect the popular CommonJS extension `module.exports`. */
  17210. var moduleExports = freeModule && freeModule.exports === freeExports;
  17211. /** Detect free variable `process` from Node.js. */
  17212. var freeProcess = moduleExports && freeGlobal.process;
  17213. /** Used to access faster Node.js helpers. */
  17214. var nodeUtil = (function() {
  17215. try {
  17216. // Use `util.types` for Node.js 10+.
  17217. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17218. if (types) {
  17219. return types;
  17220. }
  17221. // Legacy `process.binding('util')` for Node.js < 10.
  17222. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17223. } catch (e) {}
  17224. }());
  17225. /* Node.js helper references. */
  17226. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17227. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17228. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17229. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17230. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17231. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17232. /*--------------------------------------------------------------------------*/
  17233. /**
  17234. * A faster alternative to `Function#apply`, this function invokes `func`
  17235. * with the `this` binding of `thisArg` and the arguments of `args`.
  17236. *
  17237. * @private
  17238. * @param {Function} func The function to invoke.
  17239. * @param {*} thisArg The `this` binding of `func`.
  17240. * @param {Array} args The arguments to invoke `func` with.
  17241. * @returns {*} Returns the result of `func`.
  17242. */
  17243. function apply(func, thisArg, args) {
  17244. switch (args.length) {
  17245. case 0: return func.call(thisArg);
  17246. case 1: return func.call(thisArg, args[0]);
  17247. case 2: return func.call(thisArg, args[0], args[1]);
  17248. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17249. }
  17250. return func.apply(thisArg, args);
  17251. }
  17252. /**
  17253. * A specialized version of `baseAggregator` for arrays.
  17254. *
  17255. * @private
  17256. * @param {Array} [array] The array to iterate over.
  17257. * @param {Function} setter The function to set `accumulator` values.
  17258. * @param {Function} iteratee The iteratee to transform keys.
  17259. * @param {Object} accumulator The initial aggregated object.
  17260. * @returns {Function} Returns `accumulator`.
  17261. */
  17262. function arrayAggregator(array, setter, iteratee, accumulator) {
  17263. var index = -1,
  17264. length = array == null ? 0 : array.length;
  17265. while (++index < length) {
  17266. var value = array[index];
  17267. setter(accumulator, value, iteratee(value), array);
  17268. }
  17269. return accumulator;
  17270. }
  17271. /**
  17272. * A specialized version of `_.forEach` for arrays without support for
  17273. * iteratee shorthands.
  17274. *
  17275. * @private
  17276. * @param {Array} [array] The array to iterate over.
  17277. * @param {Function} iteratee The function invoked per iteration.
  17278. * @returns {Array} Returns `array`.
  17279. */
  17280. function arrayEach(array, iteratee) {
  17281. var index = -1,
  17282. length = array == null ? 0 : array.length;
  17283. while (++index < length) {
  17284. if (iteratee(array[index], index, array) === false) {
  17285. break;
  17286. }
  17287. }
  17288. return array;
  17289. }
  17290. /**
  17291. * A specialized version of `_.forEachRight` for arrays without support for
  17292. * iteratee shorthands.
  17293. *
  17294. * @private
  17295. * @param {Array} [array] The array to iterate over.
  17296. * @param {Function} iteratee The function invoked per iteration.
  17297. * @returns {Array} Returns `array`.
  17298. */
  17299. function arrayEachRight(array, iteratee) {
  17300. var length = array == null ? 0 : array.length;
  17301. while (length--) {
  17302. if (iteratee(array[length], length, array) === false) {
  17303. break;
  17304. }
  17305. }
  17306. return array;
  17307. }
  17308. /**
  17309. * A specialized version of `_.every` for arrays without support for
  17310. * iteratee shorthands.
  17311. *
  17312. * @private
  17313. * @param {Array} [array] The array to iterate over.
  17314. * @param {Function} predicate The function invoked per iteration.
  17315. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17316. * else `false`.
  17317. */
  17318. function arrayEvery(array, predicate) {
  17319. var index = -1,
  17320. length = array == null ? 0 : array.length;
  17321. while (++index < length) {
  17322. if (!predicate(array[index], index, array)) {
  17323. return false;
  17324. }
  17325. }
  17326. return true;
  17327. }
  17328. /**
  17329. * A specialized version of `_.filter` for arrays without support for
  17330. * iteratee shorthands.
  17331. *
  17332. * @private
  17333. * @param {Array} [array] The array to iterate over.
  17334. * @param {Function} predicate The function invoked per iteration.
  17335. * @returns {Array} Returns the new filtered array.
  17336. */
  17337. function arrayFilter(array, predicate) {
  17338. var index = -1,
  17339. length = array == null ? 0 : array.length,
  17340. resIndex = 0,
  17341. result = [];
  17342. while (++index < length) {
  17343. var value = array[index];
  17344. if (predicate(value, index, array)) {
  17345. result[resIndex++] = value;
  17346. }
  17347. }
  17348. return result;
  17349. }
  17350. /**
  17351. * A specialized version of `_.includes` for arrays without support for
  17352. * specifying an index to search from.
  17353. *
  17354. * @private
  17355. * @param {Array} [array] The array to inspect.
  17356. * @param {*} target The value to search for.
  17357. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17358. */
  17359. function arrayIncludes(array, value) {
  17360. var length = array == null ? 0 : array.length;
  17361. return !!length && baseIndexOf(array, value, 0) > -1;
  17362. }
  17363. /**
  17364. * This function is like `arrayIncludes` except that it accepts a comparator.
  17365. *
  17366. * @private
  17367. * @param {Array} [array] The array to inspect.
  17368. * @param {*} target The value to search for.
  17369. * @param {Function} comparator The comparator invoked per element.
  17370. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17371. */
  17372. function arrayIncludesWith(array, value, comparator) {
  17373. var index = -1,
  17374. length = array == null ? 0 : array.length;
  17375. while (++index < length) {
  17376. if (comparator(value, array[index])) {
  17377. return true;
  17378. }
  17379. }
  17380. return false;
  17381. }
  17382. /**
  17383. * A specialized version of `_.map` for arrays without support for iteratee
  17384. * shorthands.
  17385. *
  17386. * @private
  17387. * @param {Array} [array] The array to iterate over.
  17388. * @param {Function} iteratee The function invoked per iteration.
  17389. * @returns {Array} Returns the new mapped array.
  17390. */
  17391. function arrayMap(array, iteratee) {
  17392. var index = -1,
  17393. length = array == null ? 0 : array.length,
  17394. result = Array(length);
  17395. while (++index < length) {
  17396. result[index] = iteratee(array[index], index, array);
  17397. }
  17398. return result;
  17399. }
  17400. /**
  17401. * Appends the elements of `values` to `array`.
  17402. *
  17403. * @private
  17404. * @param {Array} array The array to modify.
  17405. * @param {Array} values The values to append.
  17406. * @returns {Array} Returns `array`.
  17407. */
  17408. function arrayPush(array, values) {
  17409. var index = -1,
  17410. length = values.length,
  17411. offset = array.length;
  17412. while (++index < length) {
  17413. array[offset + index] = values[index];
  17414. }
  17415. return array;
  17416. }
  17417. /**
  17418. * A specialized version of `_.reduce` for arrays without support for
  17419. * iteratee shorthands.
  17420. *
  17421. * @private
  17422. * @param {Array} [array] The array to iterate over.
  17423. * @param {Function} iteratee The function invoked per iteration.
  17424. * @param {*} [accumulator] The initial value.
  17425. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17426. * the initial value.
  17427. * @returns {*} Returns the accumulated value.
  17428. */
  17429. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17430. var index = -1,
  17431. length = array == null ? 0 : array.length;
  17432. if (initAccum && length) {
  17433. accumulator = array[++index];
  17434. }
  17435. while (++index < length) {
  17436. accumulator = iteratee(accumulator, array[index], index, array);
  17437. }
  17438. return accumulator;
  17439. }
  17440. /**
  17441. * A specialized version of `_.reduceRight` for arrays without support for
  17442. * iteratee shorthands.
  17443. *
  17444. * @private
  17445. * @param {Array} [array] The array to iterate over.
  17446. * @param {Function} iteratee The function invoked per iteration.
  17447. * @param {*} [accumulator] The initial value.
  17448. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17449. * the initial value.
  17450. * @returns {*} Returns the accumulated value.
  17451. */
  17452. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17453. var length = array == null ? 0 : array.length;
  17454. if (initAccum && length) {
  17455. accumulator = array[--length];
  17456. }
  17457. while (length--) {
  17458. accumulator = iteratee(accumulator, array[length], length, array);
  17459. }
  17460. return accumulator;
  17461. }
  17462. /**
  17463. * A specialized version of `_.some` for arrays without support for iteratee
  17464. * shorthands.
  17465. *
  17466. * @private
  17467. * @param {Array} [array] The array to iterate over.
  17468. * @param {Function} predicate The function invoked per iteration.
  17469. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17470. * else `false`.
  17471. */
  17472. function arraySome(array, predicate) {
  17473. var index = -1,
  17474. length = array == null ? 0 : array.length;
  17475. while (++index < length) {
  17476. if (predicate(array[index], index, array)) {
  17477. return true;
  17478. }
  17479. }
  17480. return false;
  17481. }
  17482. /**
  17483. * Gets the size of an ASCII `string`.
  17484. *
  17485. * @private
  17486. * @param {string} string The string inspect.
  17487. * @returns {number} Returns the string size.
  17488. */
  17489. var asciiSize = baseProperty('length');
  17490. /**
  17491. * Converts an ASCII `string` to an array.
  17492. *
  17493. * @private
  17494. * @param {string} string The string to convert.
  17495. * @returns {Array} Returns the converted array.
  17496. */
  17497. function asciiToArray(string) {
  17498. return string.split('');
  17499. }
  17500. /**
  17501. * Splits an ASCII `string` into an array of its words.
  17502. *
  17503. * @private
  17504. * @param {string} The string to inspect.
  17505. * @returns {Array} Returns the words of `string`.
  17506. */
  17507. function asciiWords(string) {
  17508. return string.match(reAsciiWord) || [];
  17509. }
  17510. /**
  17511. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17512. * without support for iteratee shorthands, which iterates over `collection`
  17513. * using `eachFunc`.
  17514. *
  17515. * @private
  17516. * @param {Array|Object} collection The collection to inspect.
  17517. * @param {Function} predicate The function invoked per iteration.
  17518. * @param {Function} eachFunc The function to iterate over `collection`.
  17519. * @returns {*} Returns the found element or its key, else `undefined`.
  17520. */
  17521. function baseFindKey(collection, predicate, eachFunc) {
  17522. var result;
  17523. eachFunc(collection, function(value, key, collection) {
  17524. if (predicate(value, key, collection)) {
  17525. result = key;
  17526. return false;
  17527. }
  17528. });
  17529. return result;
  17530. }
  17531. /**
  17532. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17533. * support for iteratee shorthands.
  17534. *
  17535. * @private
  17536. * @param {Array} array The array to inspect.
  17537. * @param {Function} predicate The function invoked per iteration.
  17538. * @param {number} fromIndex The index to search from.
  17539. * @param {boolean} [fromRight] Specify iterating from right to left.
  17540. * @returns {number} Returns the index of the matched value, else `-1`.
  17541. */
  17542. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17543. var length = array.length,
  17544. index = fromIndex + (fromRight ? 1 : -1);
  17545. while ((fromRight ? index-- : ++index < length)) {
  17546. if (predicate(array[index], index, array)) {
  17547. return index;
  17548. }
  17549. }
  17550. return -1;
  17551. }
  17552. /**
  17553. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17554. *
  17555. * @private
  17556. * @param {Array} array The array to inspect.
  17557. * @param {*} value The value to search for.
  17558. * @param {number} fromIndex The index to search from.
  17559. * @returns {number} Returns the index of the matched value, else `-1`.
  17560. */
  17561. function baseIndexOf(array, value, fromIndex) {
  17562. return value === value
  17563. ? strictIndexOf(array, value, fromIndex)
  17564. : baseFindIndex(array, baseIsNaN, fromIndex);
  17565. }
  17566. /**
  17567. * This function is like `baseIndexOf` except that it accepts a comparator.
  17568. *
  17569. * @private
  17570. * @param {Array} array The array to inspect.
  17571. * @param {*} value The value to search for.
  17572. * @param {number} fromIndex The index to search from.
  17573. * @param {Function} comparator The comparator invoked per element.
  17574. * @returns {number} Returns the index of the matched value, else `-1`.
  17575. */
  17576. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17577. var index = fromIndex - 1,
  17578. length = array.length;
  17579. while (++index < length) {
  17580. if (comparator(array[index], value)) {
  17581. return index;
  17582. }
  17583. }
  17584. return -1;
  17585. }
  17586. /**
  17587. * The base implementation of `_.isNaN` without support for number objects.
  17588. *
  17589. * @private
  17590. * @param {*} value The value to check.
  17591. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17592. */
  17593. function baseIsNaN(value) {
  17594. return value !== value;
  17595. }
  17596. /**
  17597. * The base implementation of `_.mean` and `_.meanBy` without support for
  17598. * iteratee shorthands.
  17599. *
  17600. * @private
  17601. * @param {Array} array The array to iterate over.
  17602. * @param {Function} iteratee The function invoked per iteration.
  17603. * @returns {number} Returns the mean.
  17604. */
  17605. function baseMean(array, iteratee) {
  17606. var length = array == null ? 0 : array.length;
  17607. return length ? (baseSum(array, iteratee) / length) : NAN;
  17608. }
  17609. /**
  17610. * The base implementation of `_.property` without support for deep paths.
  17611. *
  17612. * @private
  17613. * @param {string} key The key of the property to get.
  17614. * @returns {Function} Returns the new accessor function.
  17615. */
  17616. function baseProperty(key) {
  17617. return function(object) {
  17618. return object == null ? undefined : object[key];
  17619. };
  17620. }
  17621. /**
  17622. * The base implementation of `_.propertyOf` without support for deep paths.
  17623. *
  17624. * @private
  17625. * @param {Object} object The object to query.
  17626. * @returns {Function} Returns the new accessor function.
  17627. */
  17628. function basePropertyOf(object) {
  17629. return function(key) {
  17630. return object == null ? undefined : object[key];
  17631. };
  17632. }
  17633. /**
  17634. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17635. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17636. *
  17637. * @private
  17638. * @param {Array|Object} collection The collection to iterate over.
  17639. * @param {Function} iteratee The function invoked per iteration.
  17640. * @param {*} accumulator The initial value.
  17641. * @param {boolean} initAccum Specify using the first or last element of
  17642. * `collection` as the initial value.
  17643. * @param {Function} eachFunc The function to iterate over `collection`.
  17644. * @returns {*} Returns the accumulated value.
  17645. */
  17646. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17647. eachFunc(collection, function(value, index, collection) {
  17648. accumulator = initAccum
  17649. ? (initAccum = false, value)
  17650. : iteratee(accumulator, value, index, collection);
  17651. });
  17652. return accumulator;
  17653. }
  17654. /**
  17655. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17656. * sort order of `array` and replaces criteria objects with their corresponding
  17657. * values.
  17658. *
  17659. * @private
  17660. * @param {Array} array The array to sort.
  17661. * @param {Function} comparer The function to define sort order.
  17662. * @returns {Array} Returns `array`.
  17663. */
  17664. function baseSortBy(array, comparer) {
  17665. var length = array.length;
  17666. array.sort(comparer);
  17667. while (length--) {
  17668. array[length] = array[length].value;
  17669. }
  17670. return array;
  17671. }
  17672. /**
  17673. * The base implementation of `_.sum` and `_.sumBy` without support for
  17674. * iteratee shorthands.
  17675. *
  17676. * @private
  17677. * @param {Array} array The array to iterate over.
  17678. * @param {Function} iteratee The function invoked per iteration.
  17679. * @returns {number} Returns the sum.
  17680. */
  17681. function baseSum(array, iteratee) {
  17682. var result,
  17683. index = -1,
  17684. length = array.length;
  17685. while (++index < length) {
  17686. var current = iteratee(array[index]);
  17687. if (current !== undefined) {
  17688. result = result === undefined ? current : (result + current);
  17689. }
  17690. }
  17691. return result;
  17692. }
  17693. /**
  17694. * The base implementation of `_.times` without support for iteratee shorthands
  17695. * or max array length checks.
  17696. *
  17697. * @private
  17698. * @param {number} n The number of times to invoke `iteratee`.
  17699. * @param {Function} iteratee The function invoked per iteration.
  17700. * @returns {Array} Returns the array of results.
  17701. */
  17702. function baseTimes(n, iteratee) {
  17703. var index = -1,
  17704. result = Array(n);
  17705. while (++index < n) {
  17706. result[index] = iteratee(index);
  17707. }
  17708. return result;
  17709. }
  17710. /**
  17711. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17712. * of key-value pairs for `object` corresponding to the property names of `props`.
  17713. *
  17714. * @private
  17715. * @param {Object} object The object to query.
  17716. * @param {Array} props The property names to get values for.
  17717. * @returns {Object} Returns the key-value pairs.
  17718. */
  17719. function baseToPairs(object, props) {
  17720. return arrayMap(props, function(key) {
  17721. return [key, object[key]];
  17722. });
  17723. }
  17724. /**
  17725. * The base implementation of `_.unary` without support for storing metadata.
  17726. *
  17727. * @private
  17728. * @param {Function} func The function to cap arguments for.
  17729. * @returns {Function} Returns the new capped function.
  17730. */
  17731. function baseUnary(func) {
  17732. return function(value) {
  17733. return func(value);
  17734. };
  17735. }
  17736. /**
  17737. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17738. * array of `object` property values corresponding to the property names
  17739. * of `props`.
  17740. *
  17741. * @private
  17742. * @param {Object} object The object to query.
  17743. * @param {Array} props The property names to get values for.
  17744. * @returns {Object} Returns the array of property values.
  17745. */
  17746. function baseValues(object, props) {
  17747. return arrayMap(props, function(key) {
  17748. return object[key];
  17749. });
  17750. }
  17751. /**
  17752. * Checks if a `cache` value for `key` exists.
  17753. *
  17754. * @private
  17755. * @param {Object} cache The cache to query.
  17756. * @param {string} key The key of the entry to check.
  17757. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17758. */
  17759. function cacheHas(cache, key) {
  17760. return cache.has(key);
  17761. }
  17762. /**
  17763. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17764. * that is not found in the character symbols.
  17765. *
  17766. * @private
  17767. * @param {Array} strSymbols The string symbols to inspect.
  17768. * @param {Array} chrSymbols The character symbols to find.
  17769. * @returns {number} Returns the index of the first unmatched string symbol.
  17770. */
  17771. function charsStartIndex(strSymbols, chrSymbols) {
  17772. var index = -1,
  17773. length = strSymbols.length;
  17774. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17775. return index;
  17776. }
  17777. /**
  17778. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17779. * that is not found in the character symbols.
  17780. *
  17781. * @private
  17782. * @param {Array} strSymbols The string symbols to inspect.
  17783. * @param {Array} chrSymbols The character symbols to find.
  17784. * @returns {number} Returns the index of the last unmatched string symbol.
  17785. */
  17786. function charsEndIndex(strSymbols, chrSymbols) {
  17787. var index = strSymbols.length;
  17788. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17789. return index;
  17790. }
  17791. /**
  17792. * Gets the number of `placeholder` occurrences in `array`.
  17793. *
  17794. * @private
  17795. * @param {Array} array The array to inspect.
  17796. * @param {*} placeholder The placeholder to search for.
  17797. * @returns {number} Returns the placeholder count.
  17798. */
  17799. function countHolders(array, placeholder) {
  17800. var length = array.length,
  17801. result = 0;
  17802. while (length--) {
  17803. if (array[length] === placeholder) {
  17804. ++result;
  17805. }
  17806. }
  17807. return result;
  17808. }
  17809. /**
  17810. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17811. * letters to basic Latin letters.
  17812. *
  17813. * @private
  17814. * @param {string} letter The matched letter to deburr.
  17815. * @returns {string} Returns the deburred letter.
  17816. */
  17817. var deburrLetter = basePropertyOf(deburredLetters);
  17818. /**
  17819. * Used by `_.escape` to convert characters to HTML entities.
  17820. *
  17821. * @private
  17822. * @param {string} chr The matched character to escape.
  17823. * @returns {string} Returns the escaped character.
  17824. */
  17825. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17826. /**
  17827. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17828. *
  17829. * @private
  17830. * @param {string} chr The matched character to escape.
  17831. * @returns {string} Returns the escaped character.
  17832. */
  17833. function escapeStringChar(chr) {
  17834. return '\\' + stringEscapes[chr];
  17835. }
  17836. /**
  17837. * Gets the value at `key` of `object`.
  17838. *
  17839. * @private
  17840. * @param {Object} [object] The object to query.
  17841. * @param {string} key The key of the property to get.
  17842. * @returns {*} Returns the property value.
  17843. */
  17844. function getValue(object, key) {
  17845. return object == null ? undefined : object[key];
  17846. }
  17847. /**
  17848. * Checks if `string` contains Unicode symbols.
  17849. *
  17850. * @private
  17851. * @param {string} string The string to inspect.
  17852. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17853. */
  17854. function hasUnicode(string) {
  17855. return reHasUnicode.test(string);
  17856. }
  17857. /**
  17858. * Checks if `string` contains a word composed of Unicode symbols.
  17859. *
  17860. * @private
  17861. * @param {string} string The string to inspect.
  17862. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17863. */
  17864. function hasUnicodeWord(string) {
  17865. return reHasUnicodeWord.test(string);
  17866. }
  17867. /**
  17868. * Converts `iterator` to an array.
  17869. *
  17870. * @private
  17871. * @param {Object} iterator The iterator to convert.
  17872. * @returns {Array} Returns the converted array.
  17873. */
  17874. function iteratorToArray(iterator) {
  17875. var data,
  17876. result = [];
  17877. while (!(data = iterator.next()).done) {
  17878. result.push(data.value);
  17879. }
  17880. return result;
  17881. }
  17882. /**
  17883. * Converts `map` to its key-value pairs.
  17884. *
  17885. * @private
  17886. * @param {Object} map The map to convert.
  17887. * @returns {Array} Returns the key-value pairs.
  17888. */
  17889. function mapToArray(map) {
  17890. var index = -1,
  17891. result = Array(map.size);
  17892. map.forEach(function(value, key) {
  17893. result[++index] = [key, value];
  17894. });
  17895. return result;
  17896. }
  17897. /**
  17898. * Creates a unary function that invokes `func` with its argument transformed.
  17899. *
  17900. * @private
  17901. * @param {Function} func The function to wrap.
  17902. * @param {Function} transform The argument transform.
  17903. * @returns {Function} Returns the new function.
  17904. */
  17905. function overArg(func, transform) {
  17906. return function(arg) {
  17907. return func(transform(arg));
  17908. };
  17909. }
  17910. /**
  17911. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17912. * and returns an array of their indexes.
  17913. *
  17914. * @private
  17915. * @param {Array} array The array to modify.
  17916. * @param {*} placeholder The placeholder to replace.
  17917. * @returns {Array} Returns the new array of placeholder indexes.
  17918. */
  17919. function replaceHolders(array, placeholder) {
  17920. var index = -1,
  17921. length = array.length,
  17922. resIndex = 0,
  17923. result = [];
  17924. while (++index < length) {
  17925. var value = array[index];
  17926. if (value === placeholder || value === PLACEHOLDER) {
  17927. array[index] = PLACEHOLDER;
  17928. result[resIndex++] = index;
  17929. }
  17930. }
  17931. return result;
  17932. }
  17933. /**
  17934. * Converts `set` to an array of its values.
  17935. *
  17936. * @private
  17937. * @param {Object} set The set to convert.
  17938. * @returns {Array} Returns the values.
  17939. */
  17940. function setToArray(set) {
  17941. var index = -1,
  17942. result = Array(set.size);
  17943. set.forEach(function(value) {
  17944. result[++index] = value;
  17945. });
  17946. return result;
  17947. }
  17948. /**
  17949. * Converts `set` to its value-value pairs.
  17950. *
  17951. * @private
  17952. * @param {Object} set The set to convert.
  17953. * @returns {Array} Returns the value-value pairs.
  17954. */
  17955. function setToPairs(set) {
  17956. var index = -1,
  17957. result = Array(set.size);
  17958. set.forEach(function(value) {
  17959. result[++index] = [value, value];
  17960. });
  17961. return result;
  17962. }
  17963. /**
  17964. * A specialized version of `_.indexOf` which performs strict equality
  17965. * comparisons of values, i.e. `===`.
  17966. *
  17967. * @private
  17968. * @param {Array} array The array to inspect.
  17969. * @param {*} value The value to search for.
  17970. * @param {number} fromIndex The index to search from.
  17971. * @returns {number} Returns the index of the matched value, else `-1`.
  17972. */
  17973. function strictIndexOf(array, value, fromIndex) {
  17974. var index = fromIndex - 1,
  17975. length = array.length;
  17976. while (++index < length) {
  17977. if (array[index] === value) {
  17978. return index;
  17979. }
  17980. }
  17981. return -1;
  17982. }
  17983. /**
  17984. * A specialized version of `_.lastIndexOf` which performs strict equality
  17985. * comparisons of values, i.e. `===`.
  17986. *
  17987. * @private
  17988. * @param {Array} array The array to inspect.
  17989. * @param {*} value The value to search for.
  17990. * @param {number} fromIndex The index to search from.
  17991. * @returns {number} Returns the index of the matched value, else `-1`.
  17992. */
  17993. function strictLastIndexOf(array, value, fromIndex) {
  17994. var index = fromIndex + 1;
  17995. while (index--) {
  17996. if (array[index] === value) {
  17997. return index;
  17998. }
  17999. }
  18000. return index;
  18001. }
  18002. /**
  18003. * Gets the number of symbols in `string`.
  18004. *
  18005. * @private
  18006. * @param {string} string The string to inspect.
  18007. * @returns {number} Returns the string size.
  18008. */
  18009. function stringSize(string) {
  18010. return hasUnicode(string)
  18011. ? unicodeSize(string)
  18012. : asciiSize(string);
  18013. }
  18014. /**
  18015. * Converts `string` to an array.
  18016. *
  18017. * @private
  18018. * @param {string} string The string to convert.
  18019. * @returns {Array} Returns the converted array.
  18020. */
  18021. function stringToArray(string) {
  18022. return hasUnicode(string)
  18023. ? unicodeToArray(string)
  18024. : asciiToArray(string);
  18025. }
  18026. /**
  18027. * Used by `_.unescape` to convert HTML entities to characters.
  18028. *
  18029. * @private
  18030. * @param {string} chr The matched character to unescape.
  18031. * @returns {string} Returns the unescaped character.
  18032. */
  18033. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18034. /**
  18035. * Gets the size of a Unicode `string`.
  18036. *
  18037. * @private
  18038. * @param {string} string The string inspect.
  18039. * @returns {number} Returns the string size.
  18040. */
  18041. function unicodeSize(string) {
  18042. var result = reUnicode.lastIndex = 0;
  18043. while (reUnicode.test(string)) {
  18044. ++result;
  18045. }
  18046. return result;
  18047. }
  18048. /**
  18049. * Converts a Unicode `string` to an array.
  18050. *
  18051. * @private
  18052. * @param {string} string The string to convert.
  18053. * @returns {Array} Returns the converted array.
  18054. */
  18055. function unicodeToArray(string) {
  18056. return string.match(reUnicode) || [];
  18057. }
  18058. /**
  18059. * Splits a Unicode `string` into an array of its words.
  18060. *
  18061. * @private
  18062. * @param {string} The string to inspect.
  18063. * @returns {Array} Returns the words of `string`.
  18064. */
  18065. function unicodeWords(string) {
  18066. return string.match(reUnicodeWord) || [];
  18067. }
  18068. /*--------------------------------------------------------------------------*/
  18069. /**
  18070. * Create a new pristine `lodash` function using the `context` object.
  18071. *
  18072. * @static
  18073. * @memberOf _
  18074. * @since 1.1.0
  18075. * @category Util
  18076. * @param {Object} [context=root] The context object.
  18077. * @returns {Function} Returns a new `lodash` function.
  18078. * @example
  18079. *
  18080. * _.mixin({ 'foo': _.constant('foo') });
  18081. *
  18082. * var lodash = _.runInContext();
  18083. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18084. *
  18085. * _.isFunction(_.foo);
  18086. * // => true
  18087. * _.isFunction(_.bar);
  18088. * // => false
  18089. *
  18090. * lodash.isFunction(lodash.foo);
  18091. * // => false
  18092. * lodash.isFunction(lodash.bar);
  18093. * // => true
  18094. *
  18095. * // Create a suped-up `defer` in Node.js.
  18096. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18097. */
  18098. var runInContext = (function runInContext(context) {
  18099. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18100. /** Built-in constructor references. */
  18101. var Array = context.Array,
  18102. Date = context.Date,
  18103. Error = context.Error,
  18104. Function = context.Function,
  18105. Math = context.Math,
  18106. Object = context.Object,
  18107. RegExp = context.RegExp,
  18108. String = context.String,
  18109. TypeError = context.TypeError;
  18110. /** Used for built-in method references. */
  18111. var arrayProto = Array.prototype,
  18112. funcProto = Function.prototype,
  18113. objectProto = Object.prototype;
  18114. /** Used to detect overreaching core-js shims. */
  18115. var coreJsData = context['__core-js_shared__'];
  18116. /** Used to resolve the decompiled source of functions. */
  18117. var funcToString = funcProto.toString;
  18118. /** Used to check objects for own properties. */
  18119. var hasOwnProperty = objectProto.hasOwnProperty;
  18120. /** Used to generate unique IDs. */
  18121. var idCounter = 0;
  18122. /** Used to detect methods masquerading as native. */
  18123. var maskSrcKey = (function() {
  18124. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18125. return uid ? ('Symbol(src)_1.' + uid) : '';
  18126. }());
  18127. /**
  18128. * Used to resolve the
  18129. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18130. * of values.
  18131. */
  18132. var nativeObjectToString = objectProto.toString;
  18133. /** Used to infer the `Object` constructor. */
  18134. var objectCtorString = funcToString.call(Object);
  18135. /** Used to restore the original `_` reference in `_.noConflict`. */
  18136. var oldDash = root._;
  18137. /** Used to detect if a method is native. */
  18138. var reIsNative = RegExp('^' +
  18139. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18140. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18141. );
  18142. /** Built-in value references. */
  18143. var Buffer = moduleExports ? context.Buffer : undefined,
  18144. Symbol = context.Symbol,
  18145. Uint8Array = context.Uint8Array,
  18146. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18147. getPrototype = overArg(Object.getPrototypeOf, Object),
  18148. objectCreate = Object.create,
  18149. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18150. splice = arrayProto.splice,
  18151. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18152. symIterator = Symbol ? Symbol.iterator : undefined,
  18153. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18154. var defineProperty = (function() {
  18155. try {
  18156. var func = getNative(Object, 'defineProperty');
  18157. func({}, '', {});
  18158. return func;
  18159. } catch (e) {}
  18160. }());
  18161. /** Mocked built-ins. */
  18162. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18163. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18164. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18165. /* Built-in method references for those with the same name as other `lodash` methods. */
  18166. var nativeCeil = Math.ceil,
  18167. nativeFloor = Math.floor,
  18168. nativeGetSymbols = Object.getOwnPropertySymbols,
  18169. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18170. nativeIsFinite = context.isFinite,
  18171. nativeJoin = arrayProto.join,
  18172. nativeKeys = overArg(Object.keys, Object),
  18173. nativeMax = Math.max,
  18174. nativeMin = Math.min,
  18175. nativeNow = Date.now,
  18176. nativeParseInt = context.parseInt,
  18177. nativeRandom = Math.random,
  18178. nativeReverse = arrayProto.reverse;
  18179. /* Built-in method references that are verified to be native. */
  18180. var DataView = getNative(context, 'DataView'),
  18181. Map = getNative(context, 'Map'),
  18182. Promise = getNative(context, 'Promise'),
  18183. Set = getNative(context, 'Set'),
  18184. WeakMap = getNative(context, 'WeakMap'),
  18185. nativeCreate = getNative(Object, 'create');
  18186. /** Used to store function metadata. */
  18187. var metaMap = WeakMap && new WeakMap;
  18188. /** Used to lookup unminified function names. */
  18189. var realNames = {};
  18190. /** Used to detect maps, sets, and weakmaps. */
  18191. var dataViewCtorString = toSource(DataView),
  18192. mapCtorString = toSource(Map),
  18193. promiseCtorString = toSource(Promise),
  18194. setCtorString = toSource(Set),
  18195. weakMapCtorString = toSource(WeakMap);
  18196. /** Used to convert symbols to primitives and strings. */
  18197. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18198. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18199. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18200. /*------------------------------------------------------------------------*/
  18201. /**
  18202. * Creates a `lodash` object which wraps `value` to enable implicit method
  18203. * chain sequences. Methods that operate on and return arrays, collections,
  18204. * and functions can be chained together. Methods that retrieve a single value
  18205. * or may return a primitive value will automatically end the chain sequence
  18206. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18207. * with `_#value`.
  18208. *
  18209. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18210. * enabled using `_.chain`.
  18211. *
  18212. * The execution of chained methods is lazy, that is, it's deferred until
  18213. * `_#value` is implicitly or explicitly called.
  18214. *
  18215. * Lazy evaluation allows several methods to support shortcut fusion.
  18216. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18217. * the creation of intermediate arrays and can greatly reduce the number of
  18218. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18219. * fusion if the section is applied to an array and iteratees accept only
  18220. * one argument. The heuristic for whether a section qualifies for shortcut
  18221. * fusion is subject to change.
  18222. *
  18223. * Chaining is supported in custom builds as long as the `_#value` method is
  18224. * directly or indirectly included in the build.
  18225. *
  18226. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18227. *
  18228. * The wrapper `Array` methods are:
  18229. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18230. *
  18231. * The wrapper `String` methods are:
  18232. * `replace` and `split`
  18233. *
  18234. * The wrapper methods that support shortcut fusion are:
  18235. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18236. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18237. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18238. *
  18239. * The chainable wrapper methods are:
  18240. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18241. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18242. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18243. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18244. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18245. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18246. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18247. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18248. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18249. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18250. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18251. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18252. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18253. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18254. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18255. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18256. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18257. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18258. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18259. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18260. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18261. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18262. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18263. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18264. *
  18265. * The wrapper methods that are **not** chainable by default are:
  18266. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18267. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18268. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18269. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18270. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18271. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18272. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18273. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18274. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18275. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18276. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18277. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18278. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18279. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18280. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18281. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18282. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18283. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18284. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18285. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18286. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18287. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18288. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18289. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18290. * `upperFirst`, `value`, and `words`
  18291. *
  18292. * @name _
  18293. * @constructor
  18294. * @category Seq
  18295. * @param {*} value The value to wrap in a `lodash` instance.
  18296. * @returns {Object} Returns the new `lodash` wrapper instance.
  18297. * @example
  18298. *
  18299. * function square(n) {
  18300. * return n * n;
  18301. * }
  18302. *
  18303. * var wrapped = _([1, 2, 3]);
  18304. *
  18305. * // Returns an unwrapped value.
  18306. * wrapped.reduce(_.add);
  18307. * // => 6
  18308. *
  18309. * // Returns a wrapped value.
  18310. * var squares = wrapped.map(square);
  18311. *
  18312. * _.isArray(squares);
  18313. * // => false
  18314. *
  18315. * _.isArray(squares.value());
  18316. * // => true
  18317. */
  18318. function lodash(value) {
  18319. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18320. if (value instanceof LodashWrapper) {
  18321. return value;
  18322. }
  18323. if (hasOwnProperty.call(value, '__wrapped__')) {
  18324. return wrapperClone(value);
  18325. }
  18326. }
  18327. return new LodashWrapper(value);
  18328. }
  18329. /**
  18330. * The base implementation of `_.create` without support for assigning
  18331. * properties to the created object.
  18332. *
  18333. * @private
  18334. * @param {Object} proto The object to inherit from.
  18335. * @returns {Object} Returns the new object.
  18336. */
  18337. var baseCreate = (function() {
  18338. function object() {}
  18339. return function(proto) {
  18340. if (!isObject(proto)) {
  18341. return {};
  18342. }
  18343. if (objectCreate) {
  18344. return objectCreate(proto);
  18345. }
  18346. object.prototype = proto;
  18347. var result = new object;
  18348. object.prototype = undefined;
  18349. return result;
  18350. };
  18351. }());
  18352. /**
  18353. * The function whose prototype chain sequence wrappers inherit from.
  18354. *
  18355. * @private
  18356. */
  18357. function baseLodash() {
  18358. // No operation performed.
  18359. }
  18360. /**
  18361. * The base constructor for creating `lodash` wrapper objects.
  18362. *
  18363. * @private
  18364. * @param {*} value The value to wrap.
  18365. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18366. */
  18367. function LodashWrapper(value, chainAll) {
  18368. this.__wrapped__ = value;
  18369. this.__actions__ = [];
  18370. this.__chain__ = !!chainAll;
  18371. this.__index__ = 0;
  18372. this.__values__ = undefined;
  18373. }
  18374. /**
  18375. * By default, the template delimiters used by lodash are like those in
  18376. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18377. * following template settings to use alternative delimiters.
  18378. *
  18379. * @static
  18380. * @memberOf _
  18381. * @type {Object}
  18382. */
  18383. lodash.templateSettings = {
  18384. /**
  18385. * Used to detect `data` property values to be HTML-escaped.
  18386. *
  18387. * @memberOf _.templateSettings
  18388. * @type {RegExp}
  18389. */
  18390. 'escape': reEscape,
  18391. /**
  18392. * Used to detect code to be evaluated.
  18393. *
  18394. * @memberOf _.templateSettings
  18395. * @type {RegExp}
  18396. */
  18397. 'evaluate': reEvaluate,
  18398. /**
  18399. * Used to detect `data` property values to inject.
  18400. *
  18401. * @memberOf _.templateSettings
  18402. * @type {RegExp}
  18403. */
  18404. 'interpolate': reInterpolate,
  18405. /**
  18406. * Used to reference the data object in the template text.
  18407. *
  18408. * @memberOf _.templateSettings
  18409. * @type {string}
  18410. */
  18411. 'variable': '',
  18412. /**
  18413. * Used to import variables into the compiled template.
  18414. *
  18415. * @memberOf _.templateSettings
  18416. * @type {Object}
  18417. */
  18418. 'imports': {
  18419. /**
  18420. * A reference to the `lodash` function.
  18421. *
  18422. * @memberOf _.templateSettings.imports
  18423. * @type {Function}
  18424. */
  18425. '_': lodash
  18426. }
  18427. };
  18428. // Ensure wrappers are instances of `baseLodash`.
  18429. lodash.prototype = baseLodash.prototype;
  18430. lodash.prototype.constructor = lodash;
  18431. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18432. LodashWrapper.prototype.constructor = LodashWrapper;
  18433. /*------------------------------------------------------------------------*/
  18434. /**
  18435. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18436. *
  18437. * @private
  18438. * @constructor
  18439. * @param {*} value The value to wrap.
  18440. */
  18441. function LazyWrapper(value) {
  18442. this.__wrapped__ = value;
  18443. this.__actions__ = [];
  18444. this.__dir__ = 1;
  18445. this.__filtered__ = false;
  18446. this.__iteratees__ = [];
  18447. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18448. this.__views__ = [];
  18449. }
  18450. /**
  18451. * Creates a clone of the lazy wrapper object.
  18452. *
  18453. * @private
  18454. * @name clone
  18455. * @memberOf LazyWrapper
  18456. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18457. */
  18458. function lazyClone() {
  18459. var result = new LazyWrapper(this.__wrapped__);
  18460. result.__actions__ = copyArray(this.__actions__);
  18461. result.__dir__ = this.__dir__;
  18462. result.__filtered__ = this.__filtered__;
  18463. result.__iteratees__ = copyArray(this.__iteratees__);
  18464. result.__takeCount__ = this.__takeCount__;
  18465. result.__views__ = copyArray(this.__views__);
  18466. return result;
  18467. }
  18468. /**
  18469. * Reverses the direction of lazy iteration.
  18470. *
  18471. * @private
  18472. * @name reverse
  18473. * @memberOf LazyWrapper
  18474. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18475. */
  18476. function lazyReverse() {
  18477. if (this.__filtered__) {
  18478. var result = new LazyWrapper(this);
  18479. result.__dir__ = -1;
  18480. result.__filtered__ = true;
  18481. } else {
  18482. result = this.clone();
  18483. result.__dir__ *= -1;
  18484. }
  18485. return result;
  18486. }
  18487. /**
  18488. * Extracts the unwrapped value from its lazy wrapper.
  18489. *
  18490. * @private
  18491. * @name value
  18492. * @memberOf LazyWrapper
  18493. * @returns {*} Returns the unwrapped value.
  18494. */
  18495. function lazyValue() {
  18496. var array = this.__wrapped__.value(),
  18497. dir = this.__dir__,
  18498. isArr = isArray(array),
  18499. isRight = dir < 0,
  18500. arrLength = isArr ? array.length : 0,
  18501. view = getView(0, arrLength, this.__views__),
  18502. start = view.start,
  18503. end = view.end,
  18504. length = end - start,
  18505. index = isRight ? end : (start - 1),
  18506. iteratees = this.__iteratees__,
  18507. iterLength = iteratees.length,
  18508. resIndex = 0,
  18509. takeCount = nativeMin(length, this.__takeCount__);
  18510. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18511. return baseWrapperValue(array, this.__actions__);
  18512. }
  18513. var result = [];
  18514. outer:
  18515. while (length-- && resIndex < takeCount) {
  18516. index += dir;
  18517. var iterIndex = -1,
  18518. value = array[index];
  18519. while (++iterIndex < iterLength) {
  18520. var data = iteratees[iterIndex],
  18521. iteratee = data.iteratee,
  18522. type = data.type,
  18523. computed = iteratee(value);
  18524. if (type == LAZY_MAP_FLAG) {
  18525. value = computed;
  18526. } else if (!computed) {
  18527. if (type == LAZY_FILTER_FLAG) {
  18528. continue outer;
  18529. } else {
  18530. break outer;
  18531. }
  18532. }
  18533. }
  18534. result[resIndex++] = value;
  18535. }
  18536. return result;
  18537. }
  18538. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18539. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18540. LazyWrapper.prototype.constructor = LazyWrapper;
  18541. /*------------------------------------------------------------------------*/
  18542. /**
  18543. * Creates a hash object.
  18544. *
  18545. * @private
  18546. * @constructor
  18547. * @param {Array} [entries] The key-value pairs to cache.
  18548. */
  18549. function Hash(entries) {
  18550. var index = -1,
  18551. length = entries == null ? 0 : entries.length;
  18552. this.clear();
  18553. while (++index < length) {
  18554. var entry = entries[index];
  18555. this.set(entry[0], entry[1]);
  18556. }
  18557. }
  18558. /**
  18559. * Removes all key-value entries from the hash.
  18560. *
  18561. * @private
  18562. * @name clear
  18563. * @memberOf Hash
  18564. */
  18565. function hashClear() {
  18566. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18567. this.size = 0;
  18568. }
  18569. /**
  18570. * Removes `key` and its value from the hash.
  18571. *
  18572. * @private
  18573. * @name delete
  18574. * @memberOf Hash
  18575. * @param {Object} hash The hash to modify.
  18576. * @param {string} key The key of the value to remove.
  18577. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18578. */
  18579. function hashDelete(key) {
  18580. var result = this.has(key) && delete this.__data__[key];
  18581. this.size -= result ? 1 : 0;
  18582. return result;
  18583. }
  18584. /**
  18585. * Gets the hash value for `key`.
  18586. *
  18587. * @private
  18588. * @name get
  18589. * @memberOf Hash
  18590. * @param {string} key The key of the value to get.
  18591. * @returns {*} Returns the entry value.
  18592. */
  18593. function hashGet(key) {
  18594. var data = this.__data__;
  18595. if (nativeCreate) {
  18596. var result = data[key];
  18597. return result === HASH_UNDEFINED ? undefined : result;
  18598. }
  18599. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18600. }
  18601. /**
  18602. * Checks if a hash value for `key` exists.
  18603. *
  18604. * @private
  18605. * @name has
  18606. * @memberOf Hash
  18607. * @param {string} key The key of the entry to check.
  18608. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18609. */
  18610. function hashHas(key) {
  18611. var data = this.__data__;
  18612. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18613. }
  18614. /**
  18615. * Sets the hash `key` to `value`.
  18616. *
  18617. * @private
  18618. * @name set
  18619. * @memberOf Hash
  18620. * @param {string} key The key of the value to set.
  18621. * @param {*} value The value to set.
  18622. * @returns {Object} Returns the hash instance.
  18623. */
  18624. function hashSet(key, value) {
  18625. var data = this.__data__;
  18626. this.size += this.has(key) ? 0 : 1;
  18627. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18628. return this;
  18629. }
  18630. // Add methods to `Hash`.
  18631. Hash.prototype.clear = hashClear;
  18632. Hash.prototype['delete'] = hashDelete;
  18633. Hash.prototype.get = hashGet;
  18634. Hash.prototype.has = hashHas;
  18635. Hash.prototype.set = hashSet;
  18636. /*------------------------------------------------------------------------*/
  18637. /**
  18638. * Creates an list cache object.
  18639. *
  18640. * @private
  18641. * @constructor
  18642. * @param {Array} [entries] The key-value pairs to cache.
  18643. */
  18644. function ListCache(entries) {
  18645. var index = -1,
  18646. length = entries == null ? 0 : entries.length;
  18647. this.clear();
  18648. while (++index < length) {
  18649. var entry = entries[index];
  18650. this.set(entry[0], entry[1]);
  18651. }
  18652. }
  18653. /**
  18654. * Removes all key-value entries from the list cache.
  18655. *
  18656. * @private
  18657. * @name clear
  18658. * @memberOf ListCache
  18659. */
  18660. function listCacheClear() {
  18661. this.__data__ = [];
  18662. this.size = 0;
  18663. }
  18664. /**
  18665. * Removes `key` and its value from the list cache.
  18666. *
  18667. * @private
  18668. * @name delete
  18669. * @memberOf ListCache
  18670. * @param {string} key The key of the value to remove.
  18671. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18672. */
  18673. function listCacheDelete(key) {
  18674. var data = this.__data__,
  18675. index = assocIndexOf(data, key);
  18676. if (index < 0) {
  18677. return false;
  18678. }
  18679. var lastIndex = data.length - 1;
  18680. if (index == lastIndex) {
  18681. data.pop();
  18682. } else {
  18683. splice.call(data, index, 1);
  18684. }
  18685. --this.size;
  18686. return true;
  18687. }
  18688. /**
  18689. * Gets the list cache value for `key`.
  18690. *
  18691. * @private
  18692. * @name get
  18693. * @memberOf ListCache
  18694. * @param {string} key The key of the value to get.
  18695. * @returns {*} Returns the entry value.
  18696. */
  18697. function listCacheGet(key) {
  18698. var data = this.__data__,
  18699. index = assocIndexOf(data, key);
  18700. return index < 0 ? undefined : data[index][1];
  18701. }
  18702. /**
  18703. * Checks if a list cache value for `key` exists.
  18704. *
  18705. * @private
  18706. * @name has
  18707. * @memberOf ListCache
  18708. * @param {string} key The key of the entry to check.
  18709. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18710. */
  18711. function listCacheHas(key) {
  18712. return assocIndexOf(this.__data__, key) > -1;
  18713. }
  18714. /**
  18715. * Sets the list cache `key` to `value`.
  18716. *
  18717. * @private
  18718. * @name set
  18719. * @memberOf ListCache
  18720. * @param {string} key The key of the value to set.
  18721. * @param {*} value The value to set.
  18722. * @returns {Object} Returns the list cache instance.
  18723. */
  18724. function listCacheSet(key, value) {
  18725. var data = this.__data__,
  18726. index = assocIndexOf(data, key);
  18727. if (index < 0) {
  18728. ++this.size;
  18729. data.push([key, value]);
  18730. } else {
  18731. data[index][1] = value;
  18732. }
  18733. return this;
  18734. }
  18735. // Add methods to `ListCache`.
  18736. ListCache.prototype.clear = listCacheClear;
  18737. ListCache.prototype['delete'] = listCacheDelete;
  18738. ListCache.prototype.get = listCacheGet;
  18739. ListCache.prototype.has = listCacheHas;
  18740. ListCache.prototype.set = listCacheSet;
  18741. /*------------------------------------------------------------------------*/
  18742. /**
  18743. * Creates a map cache object to store key-value pairs.
  18744. *
  18745. * @private
  18746. * @constructor
  18747. * @param {Array} [entries] The key-value pairs to cache.
  18748. */
  18749. function MapCache(entries) {
  18750. var index = -1,
  18751. length = entries == null ? 0 : entries.length;
  18752. this.clear();
  18753. while (++index < length) {
  18754. var entry = entries[index];
  18755. this.set(entry[0], entry[1]);
  18756. }
  18757. }
  18758. /**
  18759. * Removes all key-value entries from the map.
  18760. *
  18761. * @private
  18762. * @name clear
  18763. * @memberOf MapCache
  18764. */
  18765. function mapCacheClear() {
  18766. this.size = 0;
  18767. this.__data__ = {
  18768. 'hash': new Hash,
  18769. 'map': new (Map || ListCache),
  18770. 'string': new Hash
  18771. };
  18772. }
  18773. /**
  18774. * Removes `key` and its value from the map.
  18775. *
  18776. * @private
  18777. * @name delete
  18778. * @memberOf MapCache
  18779. * @param {string} key The key of the value to remove.
  18780. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18781. */
  18782. function mapCacheDelete(key) {
  18783. var result = getMapData(this, key)['delete'](key);
  18784. this.size -= result ? 1 : 0;
  18785. return result;
  18786. }
  18787. /**
  18788. * Gets the map value for `key`.
  18789. *
  18790. * @private
  18791. * @name get
  18792. * @memberOf MapCache
  18793. * @param {string} key The key of the value to get.
  18794. * @returns {*} Returns the entry value.
  18795. */
  18796. function mapCacheGet(key) {
  18797. return getMapData(this, key).get(key);
  18798. }
  18799. /**
  18800. * Checks if a map value for `key` exists.
  18801. *
  18802. * @private
  18803. * @name has
  18804. * @memberOf MapCache
  18805. * @param {string} key The key of the entry to check.
  18806. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18807. */
  18808. function mapCacheHas(key) {
  18809. return getMapData(this, key).has(key);
  18810. }
  18811. /**
  18812. * Sets the map `key` to `value`.
  18813. *
  18814. * @private
  18815. * @name set
  18816. * @memberOf MapCache
  18817. * @param {string} key The key of the value to set.
  18818. * @param {*} value The value to set.
  18819. * @returns {Object} Returns the map cache instance.
  18820. */
  18821. function mapCacheSet(key, value) {
  18822. var data = getMapData(this, key),
  18823. size = data.size;
  18824. data.set(key, value);
  18825. this.size += data.size == size ? 0 : 1;
  18826. return this;
  18827. }
  18828. // Add methods to `MapCache`.
  18829. MapCache.prototype.clear = mapCacheClear;
  18830. MapCache.prototype['delete'] = mapCacheDelete;
  18831. MapCache.prototype.get = mapCacheGet;
  18832. MapCache.prototype.has = mapCacheHas;
  18833. MapCache.prototype.set = mapCacheSet;
  18834. /*------------------------------------------------------------------------*/
  18835. /**
  18836. *
  18837. * Creates an array cache object to store unique values.
  18838. *
  18839. * @private
  18840. * @constructor
  18841. * @param {Array} [values] The values to cache.
  18842. */
  18843. function SetCache(values) {
  18844. var index = -1,
  18845. length = values == null ? 0 : values.length;
  18846. this.__data__ = new MapCache;
  18847. while (++index < length) {
  18848. this.add(values[index]);
  18849. }
  18850. }
  18851. /**
  18852. * Adds `value` to the array cache.
  18853. *
  18854. * @private
  18855. * @name add
  18856. * @memberOf SetCache
  18857. * @alias push
  18858. * @param {*} value The value to cache.
  18859. * @returns {Object} Returns the cache instance.
  18860. */
  18861. function setCacheAdd(value) {
  18862. this.__data__.set(value, HASH_UNDEFINED);
  18863. return this;
  18864. }
  18865. /**
  18866. * Checks if `value` is in the array cache.
  18867. *
  18868. * @private
  18869. * @name has
  18870. * @memberOf SetCache
  18871. * @param {*} value The value to search for.
  18872. * @returns {number} Returns `true` if `value` is found, else `false`.
  18873. */
  18874. function setCacheHas(value) {
  18875. return this.__data__.has(value);
  18876. }
  18877. // Add methods to `SetCache`.
  18878. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18879. SetCache.prototype.has = setCacheHas;
  18880. /*------------------------------------------------------------------------*/
  18881. /**
  18882. * Creates a stack cache object to store key-value pairs.
  18883. *
  18884. * @private
  18885. * @constructor
  18886. * @param {Array} [entries] The key-value pairs to cache.
  18887. */
  18888. function Stack(entries) {
  18889. var data = this.__data__ = new ListCache(entries);
  18890. this.size = data.size;
  18891. }
  18892. /**
  18893. * Removes all key-value entries from the stack.
  18894. *
  18895. * @private
  18896. * @name clear
  18897. * @memberOf Stack
  18898. */
  18899. function stackClear() {
  18900. this.__data__ = new ListCache;
  18901. this.size = 0;
  18902. }
  18903. /**
  18904. * Removes `key` and its value from the stack.
  18905. *
  18906. * @private
  18907. * @name delete
  18908. * @memberOf Stack
  18909. * @param {string} key The key of the value to remove.
  18910. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18911. */
  18912. function stackDelete(key) {
  18913. var data = this.__data__,
  18914. result = data['delete'](key);
  18915. this.size = data.size;
  18916. return result;
  18917. }
  18918. /**
  18919. * Gets the stack value for `key`.
  18920. *
  18921. * @private
  18922. * @name get
  18923. * @memberOf Stack
  18924. * @param {string} key The key of the value to get.
  18925. * @returns {*} Returns the entry value.
  18926. */
  18927. function stackGet(key) {
  18928. return this.__data__.get(key);
  18929. }
  18930. /**
  18931. * Checks if a stack value for `key` exists.
  18932. *
  18933. * @private
  18934. * @name has
  18935. * @memberOf Stack
  18936. * @param {string} key The key of the entry to check.
  18937. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18938. */
  18939. function stackHas(key) {
  18940. return this.__data__.has(key);
  18941. }
  18942. /**
  18943. * Sets the stack `key` to `value`.
  18944. *
  18945. * @private
  18946. * @name set
  18947. * @memberOf Stack
  18948. * @param {string} key The key of the value to set.
  18949. * @param {*} value The value to set.
  18950. * @returns {Object} Returns the stack cache instance.
  18951. */
  18952. function stackSet(key, value) {
  18953. var data = this.__data__;
  18954. if (data instanceof ListCache) {
  18955. var pairs = data.__data__;
  18956. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  18957. pairs.push([key, value]);
  18958. this.size = ++data.size;
  18959. return this;
  18960. }
  18961. data = this.__data__ = new MapCache(pairs);
  18962. }
  18963. data.set(key, value);
  18964. this.size = data.size;
  18965. return this;
  18966. }
  18967. // Add methods to `Stack`.
  18968. Stack.prototype.clear = stackClear;
  18969. Stack.prototype['delete'] = stackDelete;
  18970. Stack.prototype.get = stackGet;
  18971. Stack.prototype.has = stackHas;
  18972. Stack.prototype.set = stackSet;
  18973. /*------------------------------------------------------------------------*/
  18974. /**
  18975. * Creates an array of the enumerable property names of the array-like `value`.
  18976. *
  18977. * @private
  18978. * @param {*} value The value to query.
  18979. * @param {boolean} inherited Specify returning inherited property names.
  18980. * @returns {Array} Returns the array of property names.
  18981. */
  18982. function arrayLikeKeys(value, inherited) {
  18983. var isArr = isArray(value),
  18984. isArg = !isArr && isArguments(value),
  18985. isBuff = !isArr && !isArg && isBuffer(value),
  18986. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  18987. skipIndexes = isArr || isArg || isBuff || isType,
  18988. result = skipIndexes ? baseTimes(value.length, String) : [],
  18989. length = result.length;
  18990. for (var key in value) {
  18991. if ((inherited || hasOwnProperty.call(value, key)) &&
  18992. !(skipIndexes && (
  18993. // Safari 9 has enumerable `arguments.length` in strict mode.
  18994. key == 'length' ||
  18995. // Node.js 0.10 has enumerable non-index properties on buffers.
  18996. (isBuff && (key == 'offset' || key == 'parent')) ||
  18997. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  18998. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  18999. // Skip index properties.
  19000. isIndex(key, length)
  19001. ))) {
  19002. result.push(key);
  19003. }
  19004. }
  19005. return result;
  19006. }
  19007. /**
  19008. * A specialized version of `_.sample` for arrays.
  19009. *
  19010. * @private
  19011. * @param {Array} array The array to sample.
  19012. * @returns {*} Returns the random element.
  19013. */
  19014. function arraySample(array) {
  19015. var length = array.length;
  19016. return length ? array[baseRandom(0, length - 1)] : undefined;
  19017. }
  19018. /**
  19019. * A specialized version of `_.sampleSize` for arrays.
  19020. *
  19021. * @private
  19022. * @param {Array} array The array to sample.
  19023. * @param {number} n The number of elements to sample.
  19024. * @returns {Array} Returns the random elements.
  19025. */
  19026. function arraySampleSize(array, n) {
  19027. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19028. }
  19029. /**
  19030. * A specialized version of `_.shuffle` for arrays.
  19031. *
  19032. * @private
  19033. * @param {Array} array The array to shuffle.
  19034. * @returns {Array} Returns the new shuffled array.
  19035. */
  19036. function arrayShuffle(array) {
  19037. return shuffleSelf(copyArray(array));
  19038. }
  19039. /**
  19040. * This function is like `assignValue` except that it doesn't assign
  19041. * `undefined` values.
  19042. *
  19043. * @private
  19044. * @param {Object} object The object to modify.
  19045. * @param {string} key The key of the property to assign.
  19046. * @param {*} value The value to assign.
  19047. */
  19048. function assignMergeValue(object, key, value) {
  19049. if ((value !== undefined && !eq(object[key], value)) ||
  19050. (value === undefined && !(key in object))) {
  19051. baseAssignValue(object, key, value);
  19052. }
  19053. }
  19054. /**
  19055. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19056. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19057. * for equality comparisons.
  19058. *
  19059. * @private
  19060. * @param {Object} object The object to modify.
  19061. * @param {string} key The key of the property to assign.
  19062. * @param {*} value The value to assign.
  19063. */
  19064. function assignValue(object, key, value) {
  19065. var objValue = object[key];
  19066. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19067. (value === undefined && !(key in object))) {
  19068. baseAssignValue(object, key, value);
  19069. }
  19070. }
  19071. /**
  19072. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19073. *
  19074. * @private
  19075. * @param {Array} array The array to inspect.
  19076. * @param {*} key The key to search for.
  19077. * @returns {number} Returns the index of the matched value, else `-1`.
  19078. */
  19079. function assocIndexOf(array, key) {
  19080. var length = array.length;
  19081. while (length--) {
  19082. if (eq(array[length][0], key)) {
  19083. return length;
  19084. }
  19085. }
  19086. return -1;
  19087. }
  19088. /**
  19089. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19090. * by `iteratee` and values set by `setter`.
  19091. *
  19092. * @private
  19093. * @param {Array|Object} collection The collection to iterate over.
  19094. * @param {Function} setter The function to set `accumulator` values.
  19095. * @param {Function} iteratee The iteratee to transform keys.
  19096. * @param {Object} accumulator The initial aggregated object.
  19097. * @returns {Function} Returns `accumulator`.
  19098. */
  19099. function baseAggregator(collection, setter, iteratee, accumulator) {
  19100. baseEach(collection, function(value, key, collection) {
  19101. setter(accumulator, value, iteratee(value), collection);
  19102. });
  19103. return accumulator;
  19104. }
  19105. /**
  19106. * The base implementation of `_.assign` without support for multiple sources
  19107. * or `customizer` functions.
  19108. *
  19109. * @private
  19110. * @param {Object} object The destination object.
  19111. * @param {Object} source The source object.
  19112. * @returns {Object} Returns `object`.
  19113. */
  19114. function baseAssign(object, source) {
  19115. return object && copyObject(source, keys(source), object);
  19116. }
  19117. /**
  19118. * The base implementation of `_.assignIn` without support for multiple sources
  19119. * or `customizer` functions.
  19120. *
  19121. * @private
  19122. * @param {Object} object The destination object.
  19123. * @param {Object} source The source object.
  19124. * @returns {Object} Returns `object`.
  19125. */
  19126. function baseAssignIn(object, source) {
  19127. return object && copyObject(source, keysIn(source), object);
  19128. }
  19129. /**
  19130. * The base implementation of `assignValue` and `assignMergeValue` without
  19131. * value checks.
  19132. *
  19133. * @private
  19134. * @param {Object} object The object to modify.
  19135. * @param {string} key The key of the property to assign.
  19136. * @param {*} value The value to assign.
  19137. */
  19138. function baseAssignValue(object, key, value) {
  19139. if (key == '__proto__' && defineProperty) {
  19140. defineProperty(object, key, {
  19141. 'configurable': true,
  19142. 'enumerable': true,
  19143. 'value': value,
  19144. 'writable': true
  19145. });
  19146. } else {
  19147. object[key] = value;
  19148. }
  19149. }
  19150. /**
  19151. * The base implementation of `_.at` without support for individual paths.
  19152. *
  19153. * @private
  19154. * @param {Object} object The object to iterate over.
  19155. * @param {string[]} paths The property paths to pick.
  19156. * @returns {Array} Returns the picked elements.
  19157. */
  19158. function baseAt(object, paths) {
  19159. var index = -1,
  19160. length = paths.length,
  19161. result = Array(length),
  19162. skip = object == null;
  19163. while (++index < length) {
  19164. result[index] = skip ? undefined : get(object, paths[index]);
  19165. }
  19166. return result;
  19167. }
  19168. /**
  19169. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19170. *
  19171. * @private
  19172. * @param {number} number The number to clamp.
  19173. * @param {number} [lower] The lower bound.
  19174. * @param {number} upper The upper bound.
  19175. * @returns {number} Returns the clamped number.
  19176. */
  19177. function baseClamp(number, lower, upper) {
  19178. if (number === number) {
  19179. if (upper !== undefined) {
  19180. number = number <= upper ? number : upper;
  19181. }
  19182. if (lower !== undefined) {
  19183. number = number >= lower ? number : lower;
  19184. }
  19185. }
  19186. return number;
  19187. }
  19188. /**
  19189. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19190. * traversed objects.
  19191. *
  19192. * @private
  19193. * @param {*} value The value to clone.
  19194. * @param {boolean} bitmask The bitmask flags.
  19195. * 1 - Deep clone
  19196. * 2 - Flatten inherited properties
  19197. * 4 - Clone symbols
  19198. * @param {Function} [customizer] The function to customize cloning.
  19199. * @param {string} [key] The key of `value`.
  19200. * @param {Object} [object] The parent object of `value`.
  19201. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19202. * @returns {*} Returns the cloned value.
  19203. */
  19204. function baseClone(value, bitmask, customizer, key, object, stack) {
  19205. var result,
  19206. isDeep = bitmask & CLONE_DEEP_FLAG,
  19207. isFlat = bitmask & CLONE_FLAT_FLAG,
  19208. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19209. if (customizer) {
  19210. result = object ? customizer(value, key, object, stack) : customizer(value);
  19211. }
  19212. if (result !== undefined) {
  19213. return result;
  19214. }
  19215. if (!isObject(value)) {
  19216. return value;
  19217. }
  19218. var isArr = isArray(value);
  19219. if (isArr) {
  19220. result = initCloneArray(value);
  19221. if (!isDeep) {
  19222. return copyArray(value, result);
  19223. }
  19224. } else {
  19225. var tag = getTag(value),
  19226. isFunc = tag == funcTag || tag == genTag;
  19227. if (isBuffer(value)) {
  19228. return cloneBuffer(value, isDeep);
  19229. }
  19230. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19231. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19232. if (!isDeep) {
  19233. return isFlat
  19234. ? copySymbolsIn(value, baseAssignIn(result, value))
  19235. : copySymbols(value, baseAssign(result, value));
  19236. }
  19237. } else {
  19238. if (!cloneableTags[tag]) {
  19239. return object ? value : {};
  19240. }
  19241. result = initCloneByTag(value, tag, isDeep);
  19242. }
  19243. }
  19244. // Check for circular references and return its corresponding clone.
  19245. stack || (stack = new Stack);
  19246. var stacked = stack.get(value);
  19247. if (stacked) {
  19248. return stacked;
  19249. }
  19250. stack.set(value, result);
  19251. if (isSet(value)) {
  19252. value.forEach(function(subValue) {
  19253. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19254. });
  19255. } else if (isMap(value)) {
  19256. value.forEach(function(subValue, key) {
  19257. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19258. });
  19259. }
  19260. var keysFunc = isFull
  19261. ? (isFlat ? getAllKeysIn : getAllKeys)
  19262. : (isFlat ? keysIn : keys);
  19263. var props = isArr ? undefined : keysFunc(value);
  19264. arrayEach(props || value, function(subValue, key) {
  19265. if (props) {
  19266. key = subValue;
  19267. subValue = value[key];
  19268. }
  19269. // Recursively populate clone (susceptible to call stack limits).
  19270. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19271. });
  19272. return result;
  19273. }
  19274. /**
  19275. * The base implementation of `_.conforms` which doesn't clone `source`.
  19276. *
  19277. * @private
  19278. * @param {Object} source The object of property predicates to conform to.
  19279. * @returns {Function} Returns the new spec function.
  19280. */
  19281. function baseConforms(source) {
  19282. var props = keys(source);
  19283. return function(object) {
  19284. return baseConformsTo(object, source, props);
  19285. };
  19286. }
  19287. /**
  19288. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19289. *
  19290. * @private
  19291. * @param {Object} object The object to inspect.
  19292. * @param {Object} source The object of property predicates to conform to.
  19293. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19294. */
  19295. function baseConformsTo(object, source, props) {
  19296. var length = props.length;
  19297. if (object == null) {
  19298. return !length;
  19299. }
  19300. object = Object(object);
  19301. while (length--) {
  19302. var key = props[length],
  19303. predicate = source[key],
  19304. value = object[key];
  19305. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19306. return false;
  19307. }
  19308. }
  19309. return true;
  19310. }
  19311. /**
  19312. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19313. * to provide to `func`.
  19314. *
  19315. * @private
  19316. * @param {Function} func The function to delay.
  19317. * @param {number} wait The number of milliseconds to delay invocation.
  19318. * @param {Array} args The arguments to provide to `func`.
  19319. * @returns {number|Object} Returns the timer id or timeout object.
  19320. */
  19321. function baseDelay(func, wait, args) {
  19322. if (typeof func != 'function') {
  19323. throw new TypeError(FUNC_ERROR_TEXT);
  19324. }
  19325. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19326. }
  19327. /**
  19328. * The base implementation of methods like `_.difference` without support
  19329. * for excluding multiple arrays or iteratee shorthands.
  19330. *
  19331. * @private
  19332. * @param {Array} array The array to inspect.
  19333. * @param {Array} values The values to exclude.
  19334. * @param {Function} [iteratee] The iteratee invoked per element.
  19335. * @param {Function} [comparator] The comparator invoked per element.
  19336. * @returns {Array} Returns the new array of filtered values.
  19337. */
  19338. function baseDifference(array, values, iteratee, comparator) {
  19339. var index = -1,
  19340. includes = arrayIncludes,
  19341. isCommon = true,
  19342. length = array.length,
  19343. result = [],
  19344. valuesLength = values.length;
  19345. if (!length) {
  19346. return result;
  19347. }
  19348. if (iteratee) {
  19349. values = arrayMap(values, baseUnary(iteratee));
  19350. }
  19351. if (comparator) {
  19352. includes = arrayIncludesWith;
  19353. isCommon = false;
  19354. }
  19355. else if (values.length >= LARGE_ARRAY_SIZE) {
  19356. includes = cacheHas;
  19357. isCommon = false;
  19358. values = new SetCache(values);
  19359. }
  19360. outer:
  19361. while (++index < length) {
  19362. var value = array[index],
  19363. computed = iteratee == null ? value : iteratee(value);
  19364. value = (comparator || value !== 0) ? value : 0;
  19365. if (isCommon && computed === computed) {
  19366. var valuesIndex = valuesLength;
  19367. while (valuesIndex--) {
  19368. if (values[valuesIndex] === computed) {
  19369. continue outer;
  19370. }
  19371. }
  19372. result.push(value);
  19373. }
  19374. else if (!includes(values, computed, comparator)) {
  19375. result.push(value);
  19376. }
  19377. }
  19378. return result;
  19379. }
  19380. /**
  19381. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19382. *
  19383. * @private
  19384. * @param {Array|Object} collection The collection to iterate over.
  19385. * @param {Function} iteratee The function invoked per iteration.
  19386. * @returns {Array|Object} Returns `collection`.
  19387. */
  19388. var baseEach = createBaseEach(baseForOwn);
  19389. /**
  19390. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19391. *
  19392. * @private
  19393. * @param {Array|Object} collection The collection to iterate over.
  19394. * @param {Function} iteratee The function invoked per iteration.
  19395. * @returns {Array|Object} Returns `collection`.
  19396. */
  19397. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19398. /**
  19399. * The base implementation of `_.every` without support for iteratee shorthands.
  19400. *
  19401. * @private
  19402. * @param {Array|Object} collection The collection to iterate over.
  19403. * @param {Function} predicate The function invoked per iteration.
  19404. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19405. * else `false`
  19406. */
  19407. function baseEvery(collection, predicate) {
  19408. var result = true;
  19409. baseEach(collection, function(value, index, collection) {
  19410. result = !!predicate(value, index, collection);
  19411. return result;
  19412. });
  19413. return result;
  19414. }
  19415. /**
  19416. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19417. * `comparator` to determine the extremum value.
  19418. *
  19419. * @private
  19420. * @param {Array} array The array to iterate over.
  19421. * @param {Function} iteratee The iteratee invoked per iteration.
  19422. * @param {Function} comparator The comparator used to compare values.
  19423. * @returns {*} Returns the extremum value.
  19424. */
  19425. function baseExtremum(array, iteratee, comparator) {
  19426. var index = -1,
  19427. length = array.length;
  19428. while (++index < length) {
  19429. var value = array[index],
  19430. current = iteratee(value);
  19431. if (current != null && (computed === undefined
  19432. ? (current === current && !isSymbol(current))
  19433. : comparator(current, computed)
  19434. )) {
  19435. var computed = current,
  19436. result = value;
  19437. }
  19438. }
  19439. return result;
  19440. }
  19441. /**
  19442. * The base implementation of `_.fill` without an iteratee call guard.
  19443. *
  19444. * @private
  19445. * @param {Array} array The array to fill.
  19446. * @param {*} value The value to fill `array` with.
  19447. * @param {number} [start=0] The start position.
  19448. * @param {number} [end=array.length] The end position.
  19449. * @returns {Array} Returns `array`.
  19450. */
  19451. function baseFill(array, value, start, end) {
  19452. var length = array.length;
  19453. start = toInteger(start);
  19454. if (start < 0) {
  19455. start = -start > length ? 0 : (length + start);
  19456. }
  19457. end = (end === undefined || end > length) ? length : toInteger(end);
  19458. if (end < 0) {
  19459. end += length;
  19460. }
  19461. end = start > end ? 0 : toLength(end);
  19462. while (start < end) {
  19463. array[start++] = value;
  19464. }
  19465. return array;
  19466. }
  19467. /**
  19468. * The base implementation of `_.filter` without support for iteratee shorthands.
  19469. *
  19470. * @private
  19471. * @param {Array|Object} collection The collection to iterate over.
  19472. * @param {Function} predicate The function invoked per iteration.
  19473. * @returns {Array} Returns the new filtered array.
  19474. */
  19475. function baseFilter(collection, predicate) {
  19476. var result = [];
  19477. baseEach(collection, function(value, index, collection) {
  19478. if (predicate(value, index, collection)) {
  19479. result.push(value);
  19480. }
  19481. });
  19482. return result;
  19483. }
  19484. /**
  19485. * The base implementation of `_.flatten` with support for restricting flattening.
  19486. *
  19487. * @private
  19488. * @param {Array} array The array to flatten.
  19489. * @param {number} depth The maximum recursion depth.
  19490. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19491. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19492. * @param {Array} [result=[]] The initial result value.
  19493. * @returns {Array} Returns the new flattened array.
  19494. */
  19495. function baseFlatten(array, depth, predicate, isStrict, result) {
  19496. var index = -1,
  19497. length = array.length;
  19498. predicate || (predicate = isFlattenable);
  19499. result || (result = []);
  19500. while (++index < length) {
  19501. var value = array[index];
  19502. if (depth > 0 && predicate(value)) {
  19503. if (depth > 1) {
  19504. // Recursively flatten arrays (susceptible to call stack limits).
  19505. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19506. } else {
  19507. arrayPush(result, value);
  19508. }
  19509. } else if (!isStrict) {
  19510. result[result.length] = value;
  19511. }
  19512. }
  19513. return result;
  19514. }
  19515. /**
  19516. * The base implementation of `baseForOwn` which iterates over `object`
  19517. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19518. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19519. *
  19520. * @private
  19521. * @param {Object} object The object to iterate over.
  19522. * @param {Function} iteratee The function invoked per iteration.
  19523. * @param {Function} keysFunc The function to get the keys of `object`.
  19524. * @returns {Object} Returns `object`.
  19525. */
  19526. var baseFor = createBaseFor();
  19527. /**
  19528. * This function is like `baseFor` except that it iterates over properties
  19529. * in the opposite order.
  19530. *
  19531. * @private
  19532. * @param {Object} object The object to iterate over.
  19533. * @param {Function} iteratee The function invoked per iteration.
  19534. * @param {Function} keysFunc The function to get the keys of `object`.
  19535. * @returns {Object} Returns `object`.
  19536. */
  19537. var baseForRight = createBaseFor(true);
  19538. /**
  19539. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19540. *
  19541. * @private
  19542. * @param {Object} object The object to iterate over.
  19543. * @param {Function} iteratee The function invoked per iteration.
  19544. * @returns {Object} Returns `object`.
  19545. */
  19546. function baseForOwn(object, iteratee) {
  19547. return object && baseFor(object, iteratee, keys);
  19548. }
  19549. /**
  19550. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19551. *
  19552. * @private
  19553. * @param {Object} object The object to iterate over.
  19554. * @param {Function} iteratee The function invoked per iteration.
  19555. * @returns {Object} Returns `object`.
  19556. */
  19557. function baseForOwnRight(object, iteratee) {
  19558. return object && baseForRight(object, iteratee, keys);
  19559. }
  19560. /**
  19561. * The base implementation of `_.functions` which creates an array of
  19562. * `object` function property names filtered from `props`.
  19563. *
  19564. * @private
  19565. * @param {Object} object The object to inspect.
  19566. * @param {Array} props The property names to filter.
  19567. * @returns {Array} Returns the function names.
  19568. */
  19569. function baseFunctions(object, props) {
  19570. return arrayFilter(props, function(key) {
  19571. return isFunction(object[key]);
  19572. });
  19573. }
  19574. /**
  19575. * The base implementation of `_.get` without support for default values.
  19576. *
  19577. * @private
  19578. * @param {Object} object The object to query.
  19579. * @param {Array|string} path The path of the property to get.
  19580. * @returns {*} Returns the resolved value.
  19581. */
  19582. function baseGet(object, path) {
  19583. path = castPath(path, object);
  19584. var index = 0,
  19585. length = path.length;
  19586. while (object != null && index < length) {
  19587. object = object[toKey(path[index++])];
  19588. }
  19589. return (index && index == length) ? object : undefined;
  19590. }
  19591. /**
  19592. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19593. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19594. * symbols of `object`.
  19595. *
  19596. * @private
  19597. * @param {Object} object The object to query.
  19598. * @param {Function} keysFunc The function to get the keys of `object`.
  19599. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19600. * @returns {Array} Returns the array of property names and symbols.
  19601. */
  19602. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19603. var result = keysFunc(object);
  19604. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19605. }
  19606. /**
  19607. * The base implementation of `getTag` without fallbacks for buggy environments.
  19608. *
  19609. * @private
  19610. * @param {*} value The value to query.
  19611. * @returns {string} Returns the `toStringTag`.
  19612. */
  19613. function baseGetTag(value) {
  19614. if (value == null) {
  19615. return value === undefined ? undefinedTag : nullTag;
  19616. }
  19617. return (symToStringTag && symToStringTag in Object(value))
  19618. ? getRawTag(value)
  19619. : objectToString(value);
  19620. }
  19621. /**
  19622. * The base implementation of `_.gt` which doesn't coerce arguments.
  19623. *
  19624. * @private
  19625. * @param {*} value The value to compare.
  19626. * @param {*} other The other value to compare.
  19627. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19628. * else `false`.
  19629. */
  19630. function baseGt(value, other) {
  19631. return value > other;
  19632. }
  19633. /**
  19634. * The base implementation of `_.has` without support for deep paths.
  19635. *
  19636. * @private
  19637. * @param {Object} [object] The object to query.
  19638. * @param {Array|string} key The key to check.
  19639. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19640. */
  19641. function baseHas(object, key) {
  19642. return object != null && hasOwnProperty.call(object, key);
  19643. }
  19644. /**
  19645. * The base implementation of `_.hasIn` without support for deep paths.
  19646. *
  19647. * @private
  19648. * @param {Object} [object] The object to query.
  19649. * @param {Array|string} key The key to check.
  19650. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19651. */
  19652. function baseHasIn(object, key) {
  19653. return object != null && key in Object(object);
  19654. }
  19655. /**
  19656. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19657. *
  19658. * @private
  19659. * @param {number} number The number to check.
  19660. * @param {number} start The start of the range.
  19661. * @param {number} end The end of the range.
  19662. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19663. */
  19664. function baseInRange(number, start, end) {
  19665. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19666. }
  19667. /**
  19668. * The base implementation of methods like `_.intersection`, without support
  19669. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19670. *
  19671. * @private
  19672. * @param {Array} arrays The arrays to inspect.
  19673. * @param {Function} [iteratee] The iteratee invoked per element.
  19674. * @param {Function} [comparator] The comparator invoked per element.
  19675. * @returns {Array} Returns the new array of shared values.
  19676. */
  19677. function baseIntersection(arrays, iteratee, comparator) {
  19678. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19679. length = arrays[0].length,
  19680. othLength = arrays.length,
  19681. othIndex = othLength,
  19682. caches = Array(othLength),
  19683. maxLength = Infinity,
  19684. result = [];
  19685. while (othIndex--) {
  19686. var array = arrays[othIndex];
  19687. if (othIndex && iteratee) {
  19688. array = arrayMap(array, baseUnary(iteratee));
  19689. }
  19690. maxLength = nativeMin(array.length, maxLength);
  19691. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19692. ? new SetCache(othIndex && array)
  19693. : undefined;
  19694. }
  19695. array = arrays[0];
  19696. var index = -1,
  19697. seen = caches[0];
  19698. outer:
  19699. while (++index < length && result.length < maxLength) {
  19700. var value = array[index],
  19701. computed = iteratee ? iteratee(value) : value;
  19702. value = (comparator || value !== 0) ? value : 0;
  19703. if (!(seen
  19704. ? cacheHas(seen, computed)
  19705. : includes(result, computed, comparator)
  19706. )) {
  19707. othIndex = othLength;
  19708. while (--othIndex) {
  19709. var cache = caches[othIndex];
  19710. if (!(cache
  19711. ? cacheHas(cache, computed)
  19712. : includes(arrays[othIndex], computed, comparator))
  19713. ) {
  19714. continue outer;
  19715. }
  19716. }
  19717. if (seen) {
  19718. seen.push(computed);
  19719. }
  19720. result.push(value);
  19721. }
  19722. }
  19723. return result;
  19724. }
  19725. /**
  19726. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19727. * `object` with values transformed by `iteratee` and set by `setter`.
  19728. *
  19729. * @private
  19730. * @param {Object} object The object to iterate over.
  19731. * @param {Function} setter The function to set `accumulator` values.
  19732. * @param {Function} iteratee The iteratee to transform values.
  19733. * @param {Object} accumulator The initial inverted object.
  19734. * @returns {Function} Returns `accumulator`.
  19735. */
  19736. function baseInverter(object, setter, iteratee, accumulator) {
  19737. baseForOwn(object, function(value, key, object) {
  19738. setter(accumulator, iteratee(value), key, object);
  19739. });
  19740. return accumulator;
  19741. }
  19742. /**
  19743. * The base implementation of `_.invoke` without support for individual
  19744. * method arguments.
  19745. *
  19746. * @private
  19747. * @param {Object} object The object to query.
  19748. * @param {Array|string} path The path of the method to invoke.
  19749. * @param {Array} args The arguments to invoke the method with.
  19750. * @returns {*} Returns the result of the invoked method.
  19751. */
  19752. function baseInvoke(object, path, args) {
  19753. path = castPath(path, object);
  19754. object = parent(object, path);
  19755. var func = object == null ? object : object[toKey(last(path))];
  19756. return func == null ? undefined : apply(func, object, args);
  19757. }
  19758. /**
  19759. * The base implementation of `_.isArguments`.
  19760. *
  19761. * @private
  19762. * @param {*} value The value to check.
  19763. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19764. */
  19765. function baseIsArguments(value) {
  19766. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19767. }
  19768. /**
  19769. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19770. *
  19771. * @private
  19772. * @param {*} value The value to check.
  19773. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19774. */
  19775. function baseIsArrayBuffer(value) {
  19776. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19777. }
  19778. /**
  19779. * The base implementation of `_.isDate` without Node.js optimizations.
  19780. *
  19781. * @private
  19782. * @param {*} value The value to check.
  19783. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19784. */
  19785. function baseIsDate(value) {
  19786. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19787. }
  19788. /**
  19789. * The base implementation of `_.isEqual` which supports partial comparisons
  19790. * and tracks traversed objects.
  19791. *
  19792. * @private
  19793. * @param {*} value The value to compare.
  19794. * @param {*} other The other value to compare.
  19795. * @param {boolean} bitmask The bitmask flags.
  19796. * 1 - Unordered comparison
  19797. * 2 - Partial comparison
  19798. * @param {Function} [customizer] The function to customize comparisons.
  19799. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19800. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19801. */
  19802. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19803. if (value === other) {
  19804. return true;
  19805. }
  19806. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19807. return value !== value && other !== other;
  19808. }
  19809. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19810. }
  19811. /**
  19812. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19813. * deep comparisons and tracks traversed objects enabling objects with circular
  19814. * references to be compared.
  19815. *
  19816. * @private
  19817. * @param {Object} object The object to compare.
  19818. * @param {Object} other The other object to compare.
  19819. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19820. * @param {Function} customizer The function to customize comparisons.
  19821. * @param {Function} equalFunc The function to determine equivalents of values.
  19822. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19823. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19824. */
  19825. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19826. var objIsArr = isArray(object),
  19827. othIsArr = isArray(other),
  19828. objTag = objIsArr ? arrayTag : getTag(object),
  19829. othTag = othIsArr ? arrayTag : getTag(other);
  19830. objTag = objTag == argsTag ? objectTag : objTag;
  19831. othTag = othTag == argsTag ? objectTag : othTag;
  19832. var objIsObj = objTag == objectTag,
  19833. othIsObj = othTag == objectTag,
  19834. isSameTag = objTag == othTag;
  19835. if (isSameTag && isBuffer(object)) {
  19836. if (!isBuffer(other)) {
  19837. return false;
  19838. }
  19839. objIsArr = true;
  19840. objIsObj = false;
  19841. }
  19842. if (isSameTag && !objIsObj) {
  19843. stack || (stack = new Stack);
  19844. return (objIsArr || isTypedArray(object))
  19845. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19846. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19847. }
  19848. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19849. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19850. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19851. if (objIsWrapped || othIsWrapped) {
  19852. var objUnwrapped = objIsWrapped ? object.value() : object,
  19853. othUnwrapped = othIsWrapped ? other.value() : other;
  19854. stack || (stack = new Stack);
  19855. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19856. }
  19857. }
  19858. if (!isSameTag) {
  19859. return false;
  19860. }
  19861. stack || (stack = new Stack);
  19862. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19863. }
  19864. /**
  19865. * The base implementation of `_.isMap` without Node.js optimizations.
  19866. *
  19867. * @private
  19868. * @param {*} value The value to check.
  19869. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19870. */
  19871. function baseIsMap(value) {
  19872. return isObjectLike(value) && getTag(value) == mapTag;
  19873. }
  19874. /**
  19875. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19876. *
  19877. * @private
  19878. * @param {Object} object The object to inspect.
  19879. * @param {Object} source The object of property values to match.
  19880. * @param {Array} matchData The property names, values, and compare flags to match.
  19881. * @param {Function} [customizer] The function to customize comparisons.
  19882. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19883. */
  19884. function baseIsMatch(object, source, matchData, customizer) {
  19885. var index = matchData.length,
  19886. length = index,
  19887. noCustomizer = !customizer;
  19888. if (object == null) {
  19889. return !length;
  19890. }
  19891. object = Object(object);
  19892. while (index--) {
  19893. var data = matchData[index];
  19894. if ((noCustomizer && data[2])
  19895. ? data[1] !== object[data[0]]
  19896. : !(data[0] in object)
  19897. ) {
  19898. return false;
  19899. }
  19900. }
  19901. while (++index < length) {
  19902. data = matchData[index];
  19903. var key = data[0],
  19904. objValue = object[key],
  19905. srcValue = data[1];
  19906. if (noCustomizer && data[2]) {
  19907. if (objValue === undefined && !(key in object)) {
  19908. return false;
  19909. }
  19910. } else {
  19911. var stack = new Stack;
  19912. if (customizer) {
  19913. var result = customizer(objValue, srcValue, key, object, source, stack);
  19914. }
  19915. if (!(result === undefined
  19916. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19917. : result
  19918. )) {
  19919. return false;
  19920. }
  19921. }
  19922. }
  19923. return true;
  19924. }
  19925. /**
  19926. * The base implementation of `_.isNative` without bad shim checks.
  19927. *
  19928. * @private
  19929. * @param {*} value The value to check.
  19930. * @returns {boolean} Returns `true` if `value` is a native function,
  19931. * else `false`.
  19932. */
  19933. function baseIsNative(value) {
  19934. if (!isObject(value) || isMasked(value)) {
  19935. return false;
  19936. }
  19937. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19938. return pattern.test(toSource(value));
  19939. }
  19940. /**
  19941. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19942. *
  19943. * @private
  19944. * @param {*} value The value to check.
  19945. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19946. */
  19947. function baseIsRegExp(value) {
  19948. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19949. }
  19950. /**
  19951. * The base implementation of `_.isSet` without Node.js optimizations.
  19952. *
  19953. * @private
  19954. * @param {*} value The value to check.
  19955. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  19956. */
  19957. function baseIsSet(value) {
  19958. return isObjectLike(value) && getTag(value) == setTag;
  19959. }
  19960. /**
  19961. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  19962. *
  19963. * @private
  19964. * @param {*} value The value to check.
  19965. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  19966. */
  19967. function baseIsTypedArray(value) {
  19968. return isObjectLike(value) &&
  19969. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  19970. }
  19971. /**
  19972. * The base implementation of `_.iteratee`.
  19973. *
  19974. * @private
  19975. * @param {*} [value=_.identity] The value to convert to an iteratee.
  19976. * @returns {Function} Returns the iteratee.
  19977. */
  19978. function baseIteratee(value) {
  19979. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  19980. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  19981. if (typeof value == 'function') {
  19982. return value;
  19983. }
  19984. if (value == null) {
  19985. return identity;
  19986. }
  19987. if (typeof value == 'object') {
  19988. return isArray(value)
  19989. ? baseMatchesProperty(value[0], value[1])
  19990. : baseMatches(value);
  19991. }
  19992. return property(value);
  19993. }
  19994. /**
  19995. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  19996. *
  19997. * @private
  19998. * @param {Object} object The object to query.
  19999. * @returns {Array} Returns the array of property names.
  20000. */
  20001. function baseKeys(object) {
  20002. if (!isPrototype(object)) {
  20003. return nativeKeys(object);
  20004. }
  20005. var result = [];
  20006. for (var key in Object(object)) {
  20007. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20008. result.push(key);
  20009. }
  20010. }
  20011. return result;
  20012. }
  20013. /**
  20014. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20015. *
  20016. * @private
  20017. * @param {Object} object The object to query.
  20018. * @returns {Array} Returns the array of property names.
  20019. */
  20020. function baseKeysIn(object) {
  20021. if (!isObject(object)) {
  20022. return nativeKeysIn(object);
  20023. }
  20024. var isProto = isPrototype(object),
  20025. result = [];
  20026. for (var key in object) {
  20027. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20028. result.push(key);
  20029. }
  20030. }
  20031. return result;
  20032. }
  20033. /**
  20034. * The base implementation of `_.lt` which doesn't coerce arguments.
  20035. *
  20036. * @private
  20037. * @param {*} value The value to compare.
  20038. * @param {*} other The other value to compare.
  20039. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20040. * else `false`.
  20041. */
  20042. function baseLt(value, other) {
  20043. return value < other;
  20044. }
  20045. /**
  20046. * The base implementation of `_.map` without support for iteratee shorthands.
  20047. *
  20048. * @private
  20049. * @param {Array|Object} collection The collection to iterate over.
  20050. * @param {Function} iteratee The function invoked per iteration.
  20051. * @returns {Array} Returns the new mapped array.
  20052. */
  20053. function baseMap(collection, iteratee) {
  20054. var index = -1,
  20055. result = isArrayLike(collection) ? Array(collection.length) : [];
  20056. baseEach(collection, function(value, key, collection) {
  20057. result[++index] = iteratee(value, key, collection);
  20058. });
  20059. return result;
  20060. }
  20061. /**
  20062. * The base implementation of `_.matches` which doesn't clone `source`.
  20063. *
  20064. * @private
  20065. * @param {Object} source The object of property values to match.
  20066. * @returns {Function} Returns the new spec function.
  20067. */
  20068. function baseMatches(source) {
  20069. var matchData = getMatchData(source);
  20070. if (matchData.length == 1 && matchData[0][2]) {
  20071. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20072. }
  20073. return function(object) {
  20074. return object === source || baseIsMatch(object, source, matchData);
  20075. };
  20076. }
  20077. /**
  20078. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20079. *
  20080. * @private
  20081. * @param {string} path The path of the property to get.
  20082. * @param {*} srcValue The value to match.
  20083. * @returns {Function} Returns the new spec function.
  20084. */
  20085. function baseMatchesProperty(path, srcValue) {
  20086. if (isKey(path) && isStrictComparable(srcValue)) {
  20087. return matchesStrictComparable(toKey(path), srcValue);
  20088. }
  20089. return function(object) {
  20090. var objValue = get(object, path);
  20091. return (objValue === undefined && objValue === srcValue)
  20092. ? hasIn(object, path)
  20093. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20094. };
  20095. }
  20096. /**
  20097. * The base implementation of `_.merge` without support for multiple sources.
  20098. *
  20099. * @private
  20100. * @param {Object} object The destination object.
  20101. * @param {Object} source The source object.
  20102. * @param {number} srcIndex The index of `source`.
  20103. * @param {Function} [customizer] The function to customize merged values.
  20104. * @param {Object} [stack] Tracks traversed source values and their merged
  20105. * counterparts.
  20106. */
  20107. function baseMerge(object, source, srcIndex, customizer, stack) {
  20108. if (object === source) {
  20109. return;
  20110. }
  20111. baseFor(source, function(srcValue, key) {
  20112. stack || (stack = new Stack);
  20113. if (isObject(srcValue)) {
  20114. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20115. }
  20116. else {
  20117. var newValue = customizer
  20118. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20119. : undefined;
  20120. if (newValue === undefined) {
  20121. newValue = srcValue;
  20122. }
  20123. assignMergeValue(object, key, newValue);
  20124. }
  20125. }, keysIn);
  20126. }
  20127. /**
  20128. * A specialized version of `baseMerge` for arrays and objects which performs
  20129. * deep merges and tracks traversed objects enabling objects with circular
  20130. * references to be merged.
  20131. *
  20132. * @private
  20133. * @param {Object} object The destination object.
  20134. * @param {Object} source The source object.
  20135. * @param {string} key The key of the value to merge.
  20136. * @param {number} srcIndex The index of `source`.
  20137. * @param {Function} mergeFunc The function to merge values.
  20138. * @param {Function} [customizer] The function to customize assigned values.
  20139. * @param {Object} [stack] Tracks traversed source values and their merged
  20140. * counterparts.
  20141. */
  20142. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20143. var objValue = safeGet(object, key),
  20144. srcValue = safeGet(source, key),
  20145. stacked = stack.get(srcValue);
  20146. if (stacked) {
  20147. assignMergeValue(object, key, stacked);
  20148. return;
  20149. }
  20150. var newValue = customizer
  20151. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20152. : undefined;
  20153. var isCommon = newValue === undefined;
  20154. if (isCommon) {
  20155. var isArr = isArray(srcValue),
  20156. isBuff = !isArr && isBuffer(srcValue),
  20157. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20158. newValue = srcValue;
  20159. if (isArr || isBuff || isTyped) {
  20160. if (isArray(objValue)) {
  20161. newValue = objValue;
  20162. }
  20163. else if (isArrayLikeObject(objValue)) {
  20164. newValue = copyArray(objValue);
  20165. }
  20166. else if (isBuff) {
  20167. isCommon = false;
  20168. newValue = cloneBuffer(srcValue, true);
  20169. }
  20170. else if (isTyped) {
  20171. isCommon = false;
  20172. newValue = cloneTypedArray(srcValue, true);
  20173. }
  20174. else {
  20175. newValue = [];
  20176. }
  20177. }
  20178. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20179. newValue = objValue;
  20180. if (isArguments(objValue)) {
  20181. newValue = toPlainObject(objValue);
  20182. }
  20183. else if (!isObject(objValue) || isFunction(objValue)) {
  20184. newValue = initCloneObject(srcValue);
  20185. }
  20186. }
  20187. else {
  20188. isCommon = false;
  20189. }
  20190. }
  20191. if (isCommon) {
  20192. // Recursively merge objects and arrays (susceptible to call stack limits).
  20193. stack.set(srcValue, newValue);
  20194. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20195. stack['delete'](srcValue);
  20196. }
  20197. assignMergeValue(object, key, newValue);
  20198. }
  20199. /**
  20200. * The base implementation of `_.nth` which doesn't coerce arguments.
  20201. *
  20202. * @private
  20203. * @param {Array} array The array to query.
  20204. * @param {number} n The index of the element to return.
  20205. * @returns {*} Returns the nth element of `array`.
  20206. */
  20207. function baseNth(array, n) {
  20208. var length = array.length;
  20209. if (!length) {
  20210. return;
  20211. }
  20212. n += n < 0 ? length : 0;
  20213. return isIndex(n, length) ? array[n] : undefined;
  20214. }
  20215. /**
  20216. * The base implementation of `_.orderBy` without param guards.
  20217. *
  20218. * @private
  20219. * @param {Array|Object} collection The collection to iterate over.
  20220. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20221. * @param {string[]} orders The sort orders of `iteratees`.
  20222. * @returns {Array} Returns the new sorted array.
  20223. */
  20224. function baseOrderBy(collection, iteratees, orders) {
  20225. var index = -1;
  20226. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20227. var result = baseMap(collection, function(value, key, collection) {
  20228. var criteria = arrayMap(iteratees, function(iteratee) {
  20229. return iteratee(value);
  20230. });
  20231. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20232. });
  20233. return baseSortBy(result, function(object, other) {
  20234. return compareMultiple(object, other, orders);
  20235. });
  20236. }
  20237. /**
  20238. * The base implementation of `_.pick` without support for individual
  20239. * property identifiers.
  20240. *
  20241. * @private
  20242. * @param {Object} object The source object.
  20243. * @param {string[]} paths The property paths to pick.
  20244. * @returns {Object} Returns the new object.
  20245. */
  20246. function basePick(object, paths) {
  20247. return basePickBy(object, paths, function(value, path) {
  20248. return hasIn(object, path);
  20249. });
  20250. }
  20251. /**
  20252. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20253. *
  20254. * @private
  20255. * @param {Object} object The source object.
  20256. * @param {string[]} paths The property paths to pick.
  20257. * @param {Function} predicate The function invoked per property.
  20258. * @returns {Object} Returns the new object.
  20259. */
  20260. function basePickBy(object, paths, predicate) {
  20261. var index = -1,
  20262. length = paths.length,
  20263. result = {};
  20264. while (++index < length) {
  20265. var path = paths[index],
  20266. value = baseGet(object, path);
  20267. if (predicate(value, path)) {
  20268. baseSet(result, castPath(path, object), value);
  20269. }
  20270. }
  20271. return result;
  20272. }
  20273. /**
  20274. * A specialized version of `baseProperty` which supports deep paths.
  20275. *
  20276. * @private
  20277. * @param {Array|string} path The path of the property to get.
  20278. * @returns {Function} Returns the new accessor function.
  20279. */
  20280. function basePropertyDeep(path) {
  20281. return function(object) {
  20282. return baseGet(object, path);
  20283. };
  20284. }
  20285. /**
  20286. * The base implementation of `_.pullAllBy` without support for iteratee
  20287. * shorthands.
  20288. *
  20289. * @private
  20290. * @param {Array} array The array to modify.
  20291. * @param {Array} values The values to remove.
  20292. * @param {Function} [iteratee] The iteratee invoked per element.
  20293. * @param {Function} [comparator] The comparator invoked per element.
  20294. * @returns {Array} Returns `array`.
  20295. */
  20296. function basePullAll(array, values, iteratee, comparator) {
  20297. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20298. index = -1,
  20299. length = values.length,
  20300. seen = array;
  20301. if (array === values) {
  20302. values = copyArray(values);
  20303. }
  20304. if (iteratee) {
  20305. seen = arrayMap(array, baseUnary(iteratee));
  20306. }
  20307. while (++index < length) {
  20308. var fromIndex = 0,
  20309. value = values[index],
  20310. computed = iteratee ? iteratee(value) : value;
  20311. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20312. if (seen !== array) {
  20313. splice.call(seen, fromIndex, 1);
  20314. }
  20315. splice.call(array, fromIndex, 1);
  20316. }
  20317. }
  20318. return array;
  20319. }
  20320. /**
  20321. * The base implementation of `_.pullAt` without support for individual
  20322. * indexes or capturing the removed elements.
  20323. *
  20324. * @private
  20325. * @param {Array} array The array to modify.
  20326. * @param {number[]} indexes The indexes of elements to remove.
  20327. * @returns {Array} Returns `array`.
  20328. */
  20329. function basePullAt(array, indexes) {
  20330. var length = array ? indexes.length : 0,
  20331. lastIndex = length - 1;
  20332. while (length--) {
  20333. var index = indexes[length];
  20334. if (length == lastIndex || index !== previous) {
  20335. var previous = index;
  20336. if (isIndex(index)) {
  20337. splice.call(array, index, 1);
  20338. } else {
  20339. baseUnset(array, index);
  20340. }
  20341. }
  20342. }
  20343. return array;
  20344. }
  20345. /**
  20346. * The base implementation of `_.random` without support for returning
  20347. * floating-point numbers.
  20348. *
  20349. * @private
  20350. * @param {number} lower The lower bound.
  20351. * @param {number} upper The upper bound.
  20352. * @returns {number} Returns the random number.
  20353. */
  20354. function baseRandom(lower, upper) {
  20355. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20356. }
  20357. /**
  20358. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20359. * coerce arguments.
  20360. *
  20361. * @private
  20362. * @param {number} start The start of the range.
  20363. * @param {number} end The end of the range.
  20364. * @param {number} step The value to increment or decrement by.
  20365. * @param {boolean} [fromRight] Specify iterating from right to left.
  20366. * @returns {Array} Returns the range of numbers.
  20367. */
  20368. function baseRange(start, end, step, fromRight) {
  20369. var index = -1,
  20370. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20371. result = Array(length);
  20372. while (length--) {
  20373. result[fromRight ? length : ++index] = start;
  20374. start += step;
  20375. }
  20376. return result;
  20377. }
  20378. /**
  20379. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20380. *
  20381. * @private
  20382. * @param {string} string The string to repeat.
  20383. * @param {number} n The number of times to repeat the string.
  20384. * @returns {string} Returns the repeated string.
  20385. */
  20386. function baseRepeat(string, n) {
  20387. var result = '';
  20388. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20389. return result;
  20390. }
  20391. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20392. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20393. do {
  20394. if (n % 2) {
  20395. result += string;
  20396. }
  20397. n = nativeFloor(n / 2);
  20398. if (n) {
  20399. string += string;
  20400. }
  20401. } while (n);
  20402. return result;
  20403. }
  20404. /**
  20405. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20406. *
  20407. * @private
  20408. * @param {Function} func The function to apply a rest parameter to.
  20409. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20410. * @returns {Function} Returns the new function.
  20411. */
  20412. function baseRest(func, start) {
  20413. return setToString(overRest(func, start, identity), func + '');
  20414. }
  20415. /**
  20416. * The base implementation of `_.sample`.
  20417. *
  20418. * @private
  20419. * @param {Array|Object} collection The collection to sample.
  20420. * @returns {*} Returns the random element.
  20421. */
  20422. function baseSample(collection) {
  20423. return arraySample(values(collection));
  20424. }
  20425. /**
  20426. * The base implementation of `_.sampleSize` without param guards.
  20427. *
  20428. * @private
  20429. * @param {Array|Object} collection The collection to sample.
  20430. * @param {number} n The number of elements to sample.
  20431. * @returns {Array} Returns the random elements.
  20432. */
  20433. function baseSampleSize(collection, n) {
  20434. var array = values(collection);
  20435. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20436. }
  20437. /**
  20438. * The base implementation of `_.set`.
  20439. *
  20440. * @private
  20441. * @param {Object} object The object to modify.
  20442. * @param {Array|string} path The path of the property to set.
  20443. * @param {*} value The value to set.
  20444. * @param {Function} [customizer] The function to customize path creation.
  20445. * @returns {Object} Returns `object`.
  20446. */
  20447. function baseSet(object, path, value, customizer) {
  20448. if (!isObject(object)) {
  20449. return object;
  20450. }
  20451. path = castPath(path, object);
  20452. var index = -1,
  20453. length = path.length,
  20454. lastIndex = length - 1,
  20455. nested = object;
  20456. while (nested != null && ++index < length) {
  20457. var key = toKey(path[index]),
  20458. newValue = value;
  20459. if (index != lastIndex) {
  20460. var objValue = nested[key];
  20461. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20462. if (newValue === undefined) {
  20463. newValue = isObject(objValue)
  20464. ? objValue
  20465. : (isIndex(path[index + 1]) ? [] : {});
  20466. }
  20467. }
  20468. assignValue(nested, key, newValue);
  20469. nested = nested[key];
  20470. }
  20471. return object;
  20472. }
  20473. /**
  20474. * The base implementation of `setData` without support for hot loop shorting.
  20475. *
  20476. * @private
  20477. * @param {Function} func The function to associate metadata with.
  20478. * @param {*} data The metadata.
  20479. * @returns {Function} Returns `func`.
  20480. */
  20481. var baseSetData = !metaMap ? identity : function(func, data) {
  20482. metaMap.set(func, data);
  20483. return func;
  20484. };
  20485. /**
  20486. * The base implementation of `setToString` without support for hot loop shorting.
  20487. *
  20488. * @private
  20489. * @param {Function} func The function to modify.
  20490. * @param {Function} string The `toString` result.
  20491. * @returns {Function} Returns `func`.
  20492. */
  20493. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20494. return defineProperty(func, 'toString', {
  20495. 'configurable': true,
  20496. 'enumerable': false,
  20497. 'value': constant(string),
  20498. 'writable': true
  20499. });
  20500. };
  20501. /**
  20502. * The base implementation of `_.shuffle`.
  20503. *
  20504. * @private
  20505. * @param {Array|Object} collection The collection to shuffle.
  20506. * @returns {Array} Returns the new shuffled array.
  20507. */
  20508. function baseShuffle(collection) {
  20509. return shuffleSelf(values(collection));
  20510. }
  20511. /**
  20512. * The base implementation of `_.slice` without an iteratee call guard.
  20513. *
  20514. * @private
  20515. * @param {Array} array The array to slice.
  20516. * @param {number} [start=0] The start position.
  20517. * @param {number} [end=array.length] The end position.
  20518. * @returns {Array} Returns the slice of `array`.
  20519. */
  20520. function baseSlice(array, start, end) {
  20521. var index = -1,
  20522. length = array.length;
  20523. if (start < 0) {
  20524. start = -start > length ? 0 : (length + start);
  20525. }
  20526. end = end > length ? length : end;
  20527. if (end < 0) {
  20528. end += length;
  20529. }
  20530. length = start > end ? 0 : ((end - start) >>> 0);
  20531. start >>>= 0;
  20532. var result = Array(length);
  20533. while (++index < length) {
  20534. result[index] = array[index + start];
  20535. }
  20536. return result;
  20537. }
  20538. /**
  20539. * The base implementation of `_.some` without support for iteratee shorthands.
  20540. *
  20541. * @private
  20542. * @param {Array|Object} collection The collection to iterate over.
  20543. * @param {Function} predicate The function invoked per iteration.
  20544. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20545. * else `false`.
  20546. */
  20547. function baseSome(collection, predicate) {
  20548. var result;
  20549. baseEach(collection, function(value, index, collection) {
  20550. result = predicate(value, index, collection);
  20551. return !result;
  20552. });
  20553. return !!result;
  20554. }
  20555. /**
  20556. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20557. * performs a binary search of `array` to determine the index at which `value`
  20558. * should be inserted into `array` in order to maintain its sort order.
  20559. *
  20560. * @private
  20561. * @param {Array} array The sorted array to inspect.
  20562. * @param {*} value The value to evaluate.
  20563. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20564. * @returns {number} Returns the index at which `value` should be inserted
  20565. * into `array`.
  20566. */
  20567. function baseSortedIndex(array, value, retHighest) {
  20568. var low = 0,
  20569. high = array == null ? low : array.length;
  20570. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20571. while (low < high) {
  20572. var mid = (low + high) >>> 1,
  20573. computed = array[mid];
  20574. if (computed !== null && !isSymbol(computed) &&
  20575. (retHighest ? (computed <= value) : (computed < value))) {
  20576. low = mid + 1;
  20577. } else {
  20578. high = mid;
  20579. }
  20580. }
  20581. return high;
  20582. }
  20583. return baseSortedIndexBy(array, value, identity, retHighest);
  20584. }
  20585. /**
  20586. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20587. * which invokes `iteratee` for `value` and each element of `array` to compute
  20588. * their sort ranking. The iteratee is invoked with one argument; (value).
  20589. *
  20590. * @private
  20591. * @param {Array} array The sorted array to inspect.
  20592. * @param {*} value The value to evaluate.
  20593. * @param {Function} iteratee The iteratee invoked per element.
  20594. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20595. * @returns {number} Returns the index at which `value` should be inserted
  20596. * into `array`.
  20597. */
  20598. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20599. value = iteratee(value);
  20600. var low = 0,
  20601. high = array == null ? 0 : array.length,
  20602. valIsNaN = value !== value,
  20603. valIsNull = value === null,
  20604. valIsSymbol = isSymbol(value),
  20605. valIsUndefined = value === undefined;
  20606. while (low < high) {
  20607. var mid = nativeFloor((low + high) / 2),
  20608. computed = iteratee(array[mid]),
  20609. othIsDefined = computed !== undefined,
  20610. othIsNull = computed === null,
  20611. othIsReflexive = computed === computed,
  20612. othIsSymbol = isSymbol(computed);
  20613. if (valIsNaN) {
  20614. var setLow = retHighest || othIsReflexive;
  20615. } else if (valIsUndefined) {
  20616. setLow = othIsReflexive && (retHighest || othIsDefined);
  20617. } else if (valIsNull) {
  20618. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20619. } else if (valIsSymbol) {
  20620. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20621. } else if (othIsNull || othIsSymbol) {
  20622. setLow = false;
  20623. } else {
  20624. setLow = retHighest ? (computed <= value) : (computed < value);
  20625. }
  20626. if (setLow) {
  20627. low = mid + 1;
  20628. } else {
  20629. high = mid;
  20630. }
  20631. }
  20632. return nativeMin(high, MAX_ARRAY_INDEX);
  20633. }
  20634. /**
  20635. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20636. * support for iteratee shorthands.
  20637. *
  20638. * @private
  20639. * @param {Array} array The array to inspect.
  20640. * @param {Function} [iteratee] The iteratee invoked per element.
  20641. * @returns {Array} Returns the new duplicate free array.
  20642. */
  20643. function baseSortedUniq(array, iteratee) {
  20644. var index = -1,
  20645. length = array.length,
  20646. resIndex = 0,
  20647. result = [];
  20648. while (++index < length) {
  20649. var value = array[index],
  20650. computed = iteratee ? iteratee(value) : value;
  20651. if (!index || !eq(computed, seen)) {
  20652. var seen = computed;
  20653. result[resIndex++] = value === 0 ? 0 : value;
  20654. }
  20655. }
  20656. return result;
  20657. }
  20658. /**
  20659. * The base implementation of `_.toNumber` which doesn't ensure correct
  20660. * conversions of binary, hexadecimal, or octal string values.
  20661. *
  20662. * @private
  20663. * @param {*} value The value to process.
  20664. * @returns {number} Returns the number.
  20665. */
  20666. function baseToNumber(value) {
  20667. if (typeof value == 'number') {
  20668. return value;
  20669. }
  20670. if (isSymbol(value)) {
  20671. return NAN;
  20672. }
  20673. return +value;
  20674. }
  20675. /**
  20676. * The base implementation of `_.toString` which doesn't convert nullish
  20677. * values to empty strings.
  20678. *
  20679. * @private
  20680. * @param {*} value The value to process.
  20681. * @returns {string} Returns the string.
  20682. */
  20683. function baseToString(value) {
  20684. // Exit early for strings to avoid a performance hit in some environments.
  20685. if (typeof value == 'string') {
  20686. return value;
  20687. }
  20688. if (isArray(value)) {
  20689. // Recursively convert values (susceptible to call stack limits).
  20690. return arrayMap(value, baseToString) + '';
  20691. }
  20692. if (isSymbol(value)) {
  20693. return symbolToString ? symbolToString.call(value) : '';
  20694. }
  20695. var result = (value + '');
  20696. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20697. }
  20698. /**
  20699. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20700. *
  20701. * @private
  20702. * @param {Array} array The array to inspect.
  20703. * @param {Function} [iteratee] The iteratee invoked per element.
  20704. * @param {Function} [comparator] The comparator invoked per element.
  20705. * @returns {Array} Returns the new duplicate free array.
  20706. */
  20707. function baseUniq(array, iteratee, comparator) {
  20708. var index = -1,
  20709. includes = arrayIncludes,
  20710. length = array.length,
  20711. isCommon = true,
  20712. result = [],
  20713. seen = result;
  20714. if (comparator) {
  20715. isCommon = false;
  20716. includes = arrayIncludesWith;
  20717. }
  20718. else if (length >= LARGE_ARRAY_SIZE) {
  20719. var set = iteratee ? null : createSet(array);
  20720. if (set) {
  20721. return setToArray(set);
  20722. }
  20723. isCommon = false;
  20724. includes = cacheHas;
  20725. seen = new SetCache;
  20726. }
  20727. else {
  20728. seen = iteratee ? [] : result;
  20729. }
  20730. outer:
  20731. while (++index < length) {
  20732. var value = array[index],
  20733. computed = iteratee ? iteratee(value) : value;
  20734. value = (comparator || value !== 0) ? value : 0;
  20735. if (isCommon && computed === computed) {
  20736. var seenIndex = seen.length;
  20737. while (seenIndex--) {
  20738. if (seen[seenIndex] === computed) {
  20739. continue outer;
  20740. }
  20741. }
  20742. if (iteratee) {
  20743. seen.push(computed);
  20744. }
  20745. result.push(value);
  20746. }
  20747. else if (!includes(seen, computed, comparator)) {
  20748. if (seen !== result) {
  20749. seen.push(computed);
  20750. }
  20751. result.push(value);
  20752. }
  20753. }
  20754. return result;
  20755. }
  20756. /**
  20757. * The base implementation of `_.unset`.
  20758. *
  20759. * @private
  20760. * @param {Object} object The object to modify.
  20761. * @param {Array|string} path The property path to unset.
  20762. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20763. */
  20764. function baseUnset(object, path) {
  20765. path = castPath(path, object);
  20766. object = parent(object, path);
  20767. return object == null || delete object[toKey(last(path))];
  20768. }
  20769. /**
  20770. * The base implementation of `_.update`.
  20771. *
  20772. * @private
  20773. * @param {Object} object The object to modify.
  20774. * @param {Array|string} path The path of the property to update.
  20775. * @param {Function} updater The function to produce the updated value.
  20776. * @param {Function} [customizer] The function to customize path creation.
  20777. * @returns {Object} Returns `object`.
  20778. */
  20779. function baseUpdate(object, path, updater, customizer) {
  20780. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20781. }
  20782. /**
  20783. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20784. * without support for iteratee shorthands.
  20785. *
  20786. * @private
  20787. * @param {Array} array The array to query.
  20788. * @param {Function} predicate The function invoked per iteration.
  20789. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20790. * @param {boolean} [fromRight] Specify iterating from right to left.
  20791. * @returns {Array} Returns the slice of `array`.
  20792. */
  20793. function baseWhile(array, predicate, isDrop, fromRight) {
  20794. var length = array.length,
  20795. index = fromRight ? length : -1;
  20796. while ((fromRight ? index-- : ++index < length) &&
  20797. predicate(array[index], index, array)) {}
  20798. return isDrop
  20799. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20800. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20801. }
  20802. /**
  20803. * The base implementation of `wrapperValue` which returns the result of
  20804. * performing a sequence of actions on the unwrapped `value`, where each
  20805. * successive action is supplied the return value of the previous.
  20806. *
  20807. * @private
  20808. * @param {*} value The unwrapped value.
  20809. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20810. * @returns {*} Returns the resolved value.
  20811. */
  20812. function baseWrapperValue(value, actions) {
  20813. var result = value;
  20814. if (result instanceof LazyWrapper) {
  20815. result = result.value();
  20816. }
  20817. return arrayReduce(actions, function(result, action) {
  20818. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20819. }, result);
  20820. }
  20821. /**
  20822. * The base implementation of methods like `_.xor`, without support for
  20823. * iteratee shorthands, that accepts an array of arrays to inspect.
  20824. *
  20825. * @private
  20826. * @param {Array} arrays The arrays to inspect.
  20827. * @param {Function} [iteratee] The iteratee invoked per element.
  20828. * @param {Function} [comparator] The comparator invoked per element.
  20829. * @returns {Array} Returns the new array of values.
  20830. */
  20831. function baseXor(arrays, iteratee, comparator) {
  20832. var length = arrays.length;
  20833. if (length < 2) {
  20834. return length ? baseUniq(arrays[0]) : [];
  20835. }
  20836. var index = -1,
  20837. result = Array(length);
  20838. while (++index < length) {
  20839. var array = arrays[index],
  20840. othIndex = -1;
  20841. while (++othIndex < length) {
  20842. if (othIndex != index) {
  20843. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20844. }
  20845. }
  20846. }
  20847. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20848. }
  20849. /**
  20850. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20851. *
  20852. * @private
  20853. * @param {Array} props The property identifiers.
  20854. * @param {Array} values The property values.
  20855. * @param {Function} assignFunc The function to assign values.
  20856. * @returns {Object} Returns the new object.
  20857. */
  20858. function baseZipObject(props, values, assignFunc) {
  20859. var index = -1,
  20860. length = props.length,
  20861. valsLength = values.length,
  20862. result = {};
  20863. while (++index < length) {
  20864. var value = index < valsLength ? values[index] : undefined;
  20865. assignFunc(result, props[index], value);
  20866. }
  20867. return result;
  20868. }
  20869. /**
  20870. * Casts `value` to an empty array if it's not an array like object.
  20871. *
  20872. * @private
  20873. * @param {*} value The value to inspect.
  20874. * @returns {Array|Object} Returns the cast array-like object.
  20875. */
  20876. function castArrayLikeObject(value) {
  20877. return isArrayLikeObject(value) ? value : [];
  20878. }
  20879. /**
  20880. * Casts `value` to `identity` if it's not a function.
  20881. *
  20882. * @private
  20883. * @param {*} value The value to inspect.
  20884. * @returns {Function} Returns cast function.
  20885. */
  20886. function castFunction(value) {
  20887. return typeof value == 'function' ? value : identity;
  20888. }
  20889. /**
  20890. * Casts `value` to a path array if it's not one.
  20891. *
  20892. * @private
  20893. * @param {*} value The value to inspect.
  20894. * @param {Object} [object] The object to query keys on.
  20895. * @returns {Array} Returns the cast property path array.
  20896. */
  20897. function castPath(value, object) {
  20898. if (isArray(value)) {
  20899. return value;
  20900. }
  20901. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20902. }
  20903. /**
  20904. * A `baseRest` alias which can be replaced with `identity` by module
  20905. * replacement plugins.
  20906. *
  20907. * @private
  20908. * @type {Function}
  20909. * @param {Function} func The function to apply a rest parameter to.
  20910. * @returns {Function} Returns the new function.
  20911. */
  20912. var castRest = baseRest;
  20913. /**
  20914. * Casts `array` to a slice if it's needed.
  20915. *
  20916. * @private
  20917. * @param {Array} array The array to inspect.
  20918. * @param {number} start The start position.
  20919. * @param {number} [end=array.length] The end position.
  20920. * @returns {Array} Returns the cast slice.
  20921. */
  20922. function castSlice(array, start, end) {
  20923. var length = array.length;
  20924. end = end === undefined ? length : end;
  20925. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20926. }
  20927. /**
  20928. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20929. *
  20930. * @private
  20931. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20932. */
  20933. var clearTimeout = ctxClearTimeout || function(id) {
  20934. return root.clearTimeout(id);
  20935. };
  20936. /**
  20937. * Creates a clone of `buffer`.
  20938. *
  20939. * @private
  20940. * @param {Buffer} buffer The buffer to clone.
  20941. * @param {boolean} [isDeep] Specify a deep clone.
  20942. * @returns {Buffer} Returns the cloned buffer.
  20943. */
  20944. function cloneBuffer(buffer, isDeep) {
  20945. if (isDeep) {
  20946. return buffer.slice();
  20947. }
  20948. var length = buffer.length,
  20949. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20950. buffer.copy(result);
  20951. return result;
  20952. }
  20953. /**
  20954. * Creates a clone of `arrayBuffer`.
  20955. *
  20956. * @private
  20957. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  20958. * @returns {ArrayBuffer} Returns the cloned array buffer.
  20959. */
  20960. function cloneArrayBuffer(arrayBuffer) {
  20961. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  20962. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  20963. return result;
  20964. }
  20965. /**
  20966. * Creates a clone of `dataView`.
  20967. *
  20968. * @private
  20969. * @param {Object} dataView The data view to clone.
  20970. * @param {boolean} [isDeep] Specify a deep clone.
  20971. * @returns {Object} Returns the cloned data view.
  20972. */
  20973. function cloneDataView(dataView, isDeep) {
  20974. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  20975. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  20976. }
  20977. /**
  20978. * Creates a clone of `regexp`.
  20979. *
  20980. * @private
  20981. * @param {Object} regexp The regexp to clone.
  20982. * @returns {Object} Returns the cloned regexp.
  20983. */
  20984. function cloneRegExp(regexp) {
  20985. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  20986. result.lastIndex = regexp.lastIndex;
  20987. return result;
  20988. }
  20989. /**
  20990. * Creates a clone of the `symbol` object.
  20991. *
  20992. * @private
  20993. * @param {Object} symbol The symbol object to clone.
  20994. * @returns {Object} Returns the cloned symbol object.
  20995. */
  20996. function cloneSymbol(symbol) {
  20997. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  20998. }
  20999. /**
  21000. * Creates a clone of `typedArray`.
  21001. *
  21002. * @private
  21003. * @param {Object} typedArray The typed array to clone.
  21004. * @param {boolean} [isDeep] Specify a deep clone.
  21005. * @returns {Object} Returns the cloned typed array.
  21006. */
  21007. function cloneTypedArray(typedArray, isDeep) {
  21008. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21009. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21010. }
  21011. /**
  21012. * Compares values to sort them in ascending order.
  21013. *
  21014. * @private
  21015. * @param {*} value The value to compare.
  21016. * @param {*} other The other value to compare.
  21017. * @returns {number} Returns the sort order indicator for `value`.
  21018. */
  21019. function compareAscending(value, other) {
  21020. if (value !== other) {
  21021. var valIsDefined = value !== undefined,
  21022. valIsNull = value === null,
  21023. valIsReflexive = value === value,
  21024. valIsSymbol = isSymbol(value);
  21025. var othIsDefined = other !== undefined,
  21026. othIsNull = other === null,
  21027. othIsReflexive = other === other,
  21028. othIsSymbol = isSymbol(other);
  21029. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21030. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21031. (valIsNull && othIsDefined && othIsReflexive) ||
  21032. (!valIsDefined && othIsReflexive) ||
  21033. !valIsReflexive) {
  21034. return 1;
  21035. }
  21036. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21037. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21038. (othIsNull && valIsDefined && valIsReflexive) ||
  21039. (!othIsDefined && valIsReflexive) ||
  21040. !othIsReflexive) {
  21041. return -1;
  21042. }
  21043. }
  21044. return 0;
  21045. }
  21046. /**
  21047. * Used by `_.orderBy` to compare multiple properties of a value to another
  21048. * and stable sort them.
  21049. *
  21050. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21051. * specify an order of "desc" for descending or "asc" for ascending sort order
  21052. * of corresponding values.
  21053. *
  21054. * @private
  21055. * @param {Object} object The object to compare.
  21056. * @param {Object} other The other object to compare.
  21057. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21058. * @returns {number} Returns the sort order indicator for `object`.
  21059. */
  21060. function compareMultiple(object, other, orders) {
  21061. var index = -1,
  21062. objCriteria = object.criteria,
  21063. othCriteria = other.criteria,
  21064. length = objCriteria.length,
  21065. ordersLength = orders.length;
  21066. while (++index < length) {
  21067. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21068. if (result) {
  21069. if (index >= ordersLength) {
  21070. return result;
  21071. }
  21072. var order = orders[index];
  21073. return result * (order == 'desc' ? -1 : 1);
  21074. }
  21075. }
  21076. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21077. // that causes it, under certain circumstances, to provide the same value for
  21078. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21079. // for more details.
  21080. //
  21081. // This also ensures a stable sort in V8 and other engines.
  21082. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21083. return object.index - other.index;
  21084. }
  21085. /**
  21086. * Creates an array that is the composition of partially applied arguments,
  21087. * placeholders, and provided arguments into a single array of arguments.
  21088. *
  21089. * @private
  21090. * @param {Array} args The provided arguments.
  21091. * @param {Array} partials The arguments to prepend to those provided.
  21092. * @param {Array} holders The `partials` placeholder indexes.
  21093. * @params {boolean} [isCurried] Specify composing for a curried function.
  21094. * @returns {Array} Returns the new array of composed arguments.
  21095. */
  21096. function composeArgs(args, partials, holders, isCurried) {
  21097. var argsIndex = -1,
  21098. argsLength = args.length,
  21099. holdersLength = holders.length,
  21100. leftIndex = -1,
  21101. leftLength = partials.length,
  21102. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21103. result = Array(leftLength + rangeLength),
  21104. isUncurried = !isCurried;
  21105. while (++leftIndex < leftLength) {
  21106. result[leftIndex] = partials[leftIndex];
  21107. }
  21108. while (++argsIndex < holdersLength) {
  21109. if (isUncurried || argsIndex < argsLength) {
  21110. result[holders[argsIndex]] = args[argsIndex];
  21111. }
  21112. }
  21113. while (rangeLength--) {
  21114. result[leftIndex++] = args[argsIndex++];
  21115. }
  21116. return result;
  21117. }
  21118. /**
  21119. * This function is like `composeArgs` except that the arguments composition
  21120. * is tailored for `_.partialRight`.
  21121. *
  21122. * @private
  21123. * @param {Array} args The provided arguments.
  21124. * @param {Array} partials The arguments to append to those provided.
  21125. * @param {Array} holders The `partials` placeholder indexes.
  21126. * @params {boolean} [isCurried] Specify composing for a curried function.
  21127. * @returns {Array} Returns the new array of composed arguments.
  21128. */
  21129. function composeArgsRight(args, partials, holders, isCurried) {
  21130. var argsIndex = -1,
  21131. argsLength = args.length,
  21132. holdersIndex = -1,
  21133. holdersLength = holders.length,
  21134. rightIndex = -1,
  21135. rightLength = partials.length,
  21136. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21137. result = Array(rangeLength + rightLength),
  21138. isUncurried = !isCurried;
  21139. while (++argsIndex < rangeLength) {
  21140. result[argsIndex] = args[argsIndex];
  21141. }
  21142. var offset = argsIndex;
  21143. while (++rightIndex < rightLength) {
  21144. result[offset + rightIndex] = partials[rightIndex];
  21145. }
  21146. while (++holdersIndex < holdersLength) {
  21147. if (isUncurried || argsIndex < argsLength) {
  21148. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21149. }
  21150. }
  21151. return result;
  21152. }
  21153. /**
  21154. * Copies the values of `source` to `array`.
  21155. *
  21156. * @private
  21157. * @param {Array} source The array to copy values from.
  21158. * @param {Array} [array=[]] The array to copy values to.
  21159. * @returns {Array} Returns `array`.
  21160. */
  21161. function copyArray(source, array) {
  21162. var index = -1,
  21163. length = source.length;
  21164. array || (array = Array(length));
  21165. while (++index < length) {
  21166. array[index] = source[index];
  21167. }
  21168. return array;
  21169. }
  21170. /**
  21171. * Copies properties of `source` to `object`.
  21172. *
  21173. * @private
  21174. * @param {Object} source The object to copy properties from.
  21175. * @param {Array} props The property identifiers to copy.
  21176. * @param {Object} [object={}] The object to copy properties to.
  21177. * @param {Function} [customizer] The function to customize copied values.
  21178. * @returns {Object} Returns `object`.
  21179. */
  21180. function copyObject(source, props, object, customizer) {
  21181. var isNew = !object;
  21182. object || (object = {});
  21183. var index = -1,
  21184. length = props.length;
  21185. while (++index < length) {
  21186. var key = props[index];
  21187. var newValue = customizer
  21188. ? customizer(object[key], source[key], key, object, source)
  21189. : undefined;
  21190. if (newValue === undefined) {
  21191. newValue = source[key];
  21192. }
  21193. if (isNew) {
  21194. baseAssignValue(object, key, newValue);
  21195. } else {
  21196. assignValue(object, key, newValue);
  21197. }
  21198. }
  21199. return object;
  21200. }
  21201. /**
  21202. * Copies own symbols of `source` to `object`.
  21203. *
  21204. * @private
  21205. * @param {Object} source The object to copy symbols from.
  21206. * @param {Object} [object={}] The object to copy symbols to.
  21207. * @returns {Object} Returns `object`.
  21208. */
  21209. function copySymbols(source, object) {
  21210. return copyObject(source, getSymbols(source), object);
  21211. }
  21212. /**
  21213. * Copies own and inherited symbols of `source` to `object`.
  21214. *
  21215. * @private
  21216. * @param {Object} source The object to copy symbols from.
  21217. * @param {Object} [object={}] The object to copy symbols to.
  21218. * @returns {Object} Returns `object`.
  21219. */
  21220. function copySymbolsIn(source, object) {
  21221. return copyObject(source, getSymbolsIn(source), object);
  21222. }
  21223. /**
  21224. * Creates a function like `_.groupBy`.
  21225. *
  21226. * @private
  21227. * @param {Function} setter The function to set accumulator values.
  21228. * @param {Function} [initializer] The accumulator object initializer.
  21229. * @returns {Function} Returns the new aggregator function.
  21230. */
  21231. function createAggregator(setter, initializer) {
  21232. return function(collection, iteratee) {
  21233. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21234. accumulator = initializer ? initializer() : {};
  21235. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21236. };
  21237. }
  21238. /**
  21239. * Creates a function like `_.assign`.
  21240. *
  21241. * @private
  21242. * @param {Function} assigner The function to assign values.
  21243. * @returns {Function} Returns the new assigner function.
  21244. */
  21245. function createAssigner(assigner) {
  21246. return baseRest(function(object, sources) {
  21247. var index = -1,
  21248. length = sources.length,
  21249. customizer = length > 1 ? sources[length - 1] : undefined,
  21250. guard = length > 2 ? sources[2] : undefined;
  21251. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21252. ? (length--, customizer)
  21253. : undefined;
  21254. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21255. customizer = length < 3 ? undefined : customizer;
  21256. length = 1;
  21257. }
  21258. object = Object(object);
  21259. while (++index < length) {
  21260. var source = sources[index];
  21261. if (source) {
  21262. assigner(object, source, index, customizer);
  21263. }
  21264. }
  21265. return object;
  21266. });
  21267. }
  21268. /**
  21269. * Creates a `baseEach` or `baseEachRight` function.
  21270. *
  21271. * @private
  21272. * @param {Function} eachFunc The function to iterate over a collection.
  21273. * @param {boolean} [fromRight] Specify iterating from right to left.
  21274. * @returns {Function} Returns the new base function.
  21275. */
  21276. function createBaseEach(eachFunc, fromRight) {
  21277. return function(collection, iteratee) {
  21278. if (collection == null) {
  21279. return collection;
  21280. }
  21281. if (!isArrayLike(collection)) {
  21282. return eachFunc(collection, iteratee);
  21283. }
  21284. var length = collection.length,
  21285. index = fromRight ? length : -1,
  21286. iterable = Object(collection);
  21287. while ((fromRight ? index-- : ++index < length)) {
  21288. if (iteratee(iterable[index], index, iterable) === false) {
  21289. break;
  21290. }
  21291. }
  21292. return collection;
  21293. };
  21294. }
  21295. /**
  21296. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21297. *
  21298. * @private
  21299. * @param {boolean} [fromRight] Specify iterating from right to left.
  21300. * @returns {Function} Returns the new base function.
  21301. */
  21302. function createBaseFor(fromRight) {
  21303. return function(object, iteratee, keysFunc) {
  21304. var index = -1,
  21305. iterable = Object(object),
  21306. props = keysFunc(object),
  21307. length = props.length;
  21308. while (length--) {
  21309. var key = props[fromRight ? length : ++index];
  21310. if (iteratee(iterable[key], key, iterable) === false) {
  21311. break;
  21312. }
  21313. }
  21314. return object;
  21315. };
  21316. }
  21317. /**
  21318. * Creates a function that wraps `func` to invoke it with the optional `this`
  21319. * binding of `thisArg`.
  21320. *
  21321. * @private
  21322. * @param {Function} func The function to wrap.
  21323. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21324. * @param {*} [thisArg] The `this` binding of `func`.
  21325. * @returns {Function} Returns the new wrapped function.
  21326. */
  21327. function createBind(func, bitmask, thisArg) {
  21328. var isBind = bitmask & WRAP_BIND_FLAG,
  21329. Ctor = createCtor(func);
  21330. function wrapper() {
  21331. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21332. return fn.apply(isBind ? thisArg : this, arguments);
  21333. }
  21334. return wrapper;
  21335. }
  21336. /**
  21337. * Creates a function like `_.lowerFirst`.
  21338. *
  21339. * @private
  21340. * @param {string} methodName The name of the `String` case method to use.
  21341. * @returns {Function} Returns the new case function.
  21342. */
  21343. function createCaseFirst(methodName) {
  21344. return function(string) {
  21345. string = toString(string);
  21346. var strSymbols = hasUnicode(string)
  21347. ? stringToArray(string)
  21348. : undefined;
  21349. var chr = strSymbols
  21350. ? strSymbols[0]
  21351. : string.charAt(0);
  21352. var trailing = strSymbols
  21353. ? castSlice(strSymbols, 1).join('')
  21354. : string.slice(1);
  21355. return chr[methodName]() + trailing;
  21356. };
  21357. }
  21358. /**
  21359. * Creates a function like `_.camelCase`.
  21360. *
  21361. * @private
  21362. * @param {Function} callback The function to combine each word.
  21363. * @returns {Function} Returns the new compounder function.
  21364. */
  21365. function createCompounder(callback) {
  21366. return function(string) {
  21367. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21368. };
  21369. }
  21370. /**
  21371. * Creates a function that produces an instance of `Ctor` regardless of
  21372. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21373. *
  21374. * @private
  21375. * @param {Function} Ctor The constructor to wrap.
  21376. * @returns {Function} Returns the new wrapped function.
  21377. */
  21378. function createCtor(Ctor) {
  21379. return function() {
  21380. // Use a `switch` statement to work with class constructors. See
  21381. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21382. // for more details.
  21383. var args = arguments;
  21384. switch (args.length) {
  21385. case 0: return new Ctor;
  21386. case 1: return new Ctor(args[0]);
  21387. case 2: return new Ctor(args[0], args[1]);
  21388. case 3: return new Ctor(args[0], args[1], args[2]);
  21389. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21390. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21391. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21392. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21393. }
  21394. var thisBinding = baseCreate(Ctor.prototype),
  21395. result = Ctor.apply(thisBinding, args);
  21396. // Mimic the constructor's `return` behavior.
  21397. // See https://es5.github.io/#x13.2.2 for more details.
  21398. return isObject(result) ? result : thisBinding;
  21399. };
  21400. }
  21401. /**
  21402. * Creates a function that wraps `func` to enable currying.
  21403. *
  21404. * @private
  21405. * @param {Function} func The function to wrap.
  21406. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21407. * @param {number} arity The arity of `func`.
  21408. * @returns {Function} Returns the new wrapped function.
  21409. */
  21410. function createCurry(func, bitmask, arity) {
  21411. var Ctor = createCtor(func);
  21412. function wrapper() {
  21413. var length = arguments.length,
  21414. args = Array(length),
  21415. index = length,
  21416. placeholder = getHolder(wrapper);
  21417. while (index--) {
  21418. args[index] = arguments[index];
  21419. }
  21420. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21421. ? []
  21422. : replaceHolders(args, placeholder);
  21423. length -= holders.length;
  21424. if (length < arity) {
  21425. return createRecurry(
  21426. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21427. args, holders, undefined, undefined, arity - length);
  21428. }
  21429. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21430. return apply(fn, this, args);
  21431. }
  21432. return wrapper;
  21433. }
  21434. /**
  21435. * Creates a `_.find` or `_.findLast` function.
  21436. *
  21437. * @private
  21438. * @param {Function} findIndexFunc The function to find the collection index.
  21439. * @returns {Function} Returns the new find function.
  21440. */
  21441. function createFind(findIndexFunc) {
  21442. return function(collection, predicate, fromIndex) {
  21443. var iterable = Object(collection);
  21444. if (!isArrayLike(collection)) {
  21445. var iteratee = getIteratee(predicate, 3);
  21446. collection = keys(collection);
  21447. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21448. }
  21449. var index = findIndexFunc(collection, predicate, fromIndex);
  21450. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21451. };
  21452. }
  21453. /**
  21454. * Creates a `_.flow` or `_.flowRight` function.
  21455. *
  21456. * @private
  21457. * @param {boolean} [fromRight] Specify iterating from right to left.
  21458. * @returns {Function} Returns the new flow function.
  21459. */
  21460. function createFlow(fromRight) {
  21461. return flatRest(function(funcs) {
  21462. var length = funcs.length,
  21463. index = length,
  21464. prereq = LodashWrapper.prototype.thru;
  21465. if (fromRight) {
  21466. funcs.reverse();
  21467. }
  21468. while (index--) {
  21469. var func = funcs[index];
  21470. if (typeof func != 'function') {
  21471. throw new TypeError(FUNC_ERROR_TEXT);
  21472. }
  21473. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21474. var wrapper = new LodashWrapper([], true);
  21475. }
  21476. }
  21477. index = wrapper ? index : length;
  21478. while (++index < length) {
  21479. func = funcs[index];
  21480. var funcName = getFuncName(func),
  21481. data = funcName == 'wrapper' ? getData(func) : undefined;
  21482. if (data && isLaziable(data[0]) &&
  21483. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21484. !data[4].length && data[9] == 1
  21485. ) {
  21486. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21487. } else {
  21488. wrapper = (func.length == 1 && isLaziable(func))
  21489. ? wrapper[funcName]()
  21490. : wrapper.thru(func);
  21491. }
  21492. }
  21493. return function() {
  21494. var args = arguments,
  21495. value = args[0];
  21496. if (wrapper && args.length == 1 && isArray(value)) {
  21497. return wrapper.plant(value).value();
  21498. }
  21499. var index = 0,
  21500. result = length ? funcs[index].apply(this, args) : value;
  21501. while (++index < length) {
  21502. result = funcs[index].call(this, result);
  21503. }
  21504. return result;
  21505. };
  21506. });
  21507. }
  21508. /**
  21509. * Creates a function that wraps `func` to invoke it with optional `this`
  21510. * binding of `thisArg`, partial application, and currying.
  21511. *
  21512. * @private
  21513. * @param {Function|string} func The function or method name to wrap.
  21514. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21515. * @param {*} [thisArg] The `this` binding of `func`.
  21516. * @param {Array} [partials] The arguments to prepend to those provided to
  21517. * the new function.
  21518. * @param {Array} [holders] The `partials` placeholder indexes.
  21519. * @param {Array} [partialsRight] The arguments to append to those provided
  21520. * to the new function.
  21521. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21522. * @param {Array} [argPos] The argument positions of the new function.
  21523. * @param {number} [ary] The arity cap of `func`.
  21524. * @param {number} [arity] The arity of `func`.
  21525. * @returns {Function} Returns the new wrapped function.
  21526. */
  21527. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21528. var isAry = bitmask & WRAP_ARY_FLAG,
  21529. isBind = bitmask & WRAP_BIND_FLAG,
  21530. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21531. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21532. isFlip = bitmask & WRAP_FLIP_FLAG,
  21533. Ctor = isBindKey ? undefined : createCtor(func);
  21534. function wrapper() {
  21535. var length = arguments.length,
  21536. args = Array(length),
  21537. index = length;
  21538. while (index--) {
  21539. args[index] = arguments[index];
  21540. }
  21541. if (isCurried) {
  21542. var placeholder = getHolder(wrapper),
  21543. holdersCount = countHolders(args, placeholder);
  21544. }
  21545. if (partials) {
  21546. args = composeArgs(args, partials, holders, isCurried);
  21547. }
  21548. if (partialsRight) {
  21549. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21550. }
  21551. length -= holdersCount;
  21552. if (isCurried && length < arity) {
  21553. var newHolders = replaceHolders(args, placeholder);
  21554. return createRecurry(
  21555. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21556. args, newHolders, argPos, ary, arity - length
  21557. );
  21558. }
  21559. var thisBinding = isBind ? thisArg : this,
  21560. fn = isBindKey ? thisBinding[func] : func;
  21561. length = args.length;
  21562. if (argPos) {
  21563. args = reorder(args, argPos);
  21564. } else if (isFlip && length > 1) {
  21565. args.reverse();
  21566. }
  21567. if (isAry && ary < length) {
  21568. args.length = ary;
  21569. }
  21570. if (this && this !== root && this instanceof wrapper) {
  21571. fn = Ctor || createCtor(fn);
  21572. }
  21573. return fn.apply(thisBinding, args);
  21574. }
  21575. return wrapper;
  21576. }
  21577. /**
  21578. * Creates a function like `_.invertBy`.
  21579. *
  21580. * @private
  21581. * @param {Function} setter The function to set accumulator values.
  21582. * @param {Function} toIteratee The function to resolve iteratees.
  21583. * @returns {Function} Returns the new inverter function.
  21584. */
  21585. function createInverter(setter, toIteratee) {
  21586. return function(object, iteratee) {
  21587. return baseInverter(object, setter, toIteratee(iteratee), {});
  21588. };
  21589. }
  21590. /**
  21591. * Creates a function that performs a mathematical operation on two values.
  21592. *
  21593. * @private
  21594. * @param {Function} operator The function to perform the operation.
  21595. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21596. * @returns {Function} Returns the new mathematical operation function.
  21597. */
  21598. function createMathOperation(operator, defaultValue) {
  21599. return function(value, other) {
  21600. var result;
  21601. if (value === undefined && other === undefined) {
  21602. return defaultValue;
  21603. }
  21604. if (value !== undefined) {
  21605. result = value;
  21606. }
  21607. if (other !== undefined) {
  21608. if (result === undefined) {
  21609. return other;
  21610. }
  21611. if (typeof value == 'string' || typeof other == 'string') {
  21612. value = baseToString(value);
  21613. other = baseToString(other);
  21614. } else {
  21615. value = baseToNumber(value);
  21616. other = baseToNumber(other);
  21617. }
  21618. result = operator(value, other);
  21619. }
  21620. return result;
  21621. };
  21622. }
  21623. /**
  21624. * Creates a function like `_.over`.
  21625. *
  21626. * @private
  21627. * @param {Function} arrayFunc The function to iterate over iteratees.
  21628. * @returns {Function} Returns the new over function.
  21629. */
  21630. function createOver(arrayFunc) {
  21631. return flatRest(function(iteratees) {
  21632. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21633. return baseRest(function(args) {
  21634. var thisArg = this;
  21635. return arrayFunc(iteratees, function(iteratee) {
  21636. return apply(iteratee, thisArg, args);
  21637. });
  21638. });
  21639. });
  21640. }
  21641. /**
  21642. * Creates the padding for `string` based on `length`. The `chars` string
  21643. * is truncated if the number of characters exceeds `length`.
  21644. *
  21645. * @private
  21646. * @param {number} length The padding length.
  21647. * @param {string} [chars=' '] The string used as padding.
  21648. * @returns {string} Returns the padding for `string`.
  21649. */
  21650. function createPadding(length, chars) {
  21651. chars = chars === undefined ? ' ' : baseToString(chars);
  21652. var charsLength = chars.length;
  21653. if (charsLength < 2) {
  21654. return charsLength ? baseRepeat(chars, length) : chars;
  21655. }
  21656. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21657. return hasUnicode(chars)
  21658. ? castSlice(stringToArray(result), 0, length).join('')
  21659. : result.slice(0, length);
  21660. }
  21661. /**
  21662. * Creates a function that wraps `func` to invoke it with the `this` binding
  21663. * of `thisArg` and `partials` prepended to the arguments it receives.
  21664. *
  21665. * @private
  21666. * @param {Function} func The function to wrap.
  21667. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21668. * @param {*} thisArg The `this` binding of `func`.
  21669. * @param {Array} partials The arguments to prepend to those provided to
  21670. * the new function.
  21671. * @returns {Function} Returns the new wrapped function.
  21672. */
  21673. function createPartial(func, bitmask, thisArg, partials) {
  21674. var isBind = bitmask & WRAP_BIND_FLAG,
  21675. Ctor = createCtor(func);
  21676. function wrapper() {
  21677. var argsIndex = -1,
  21678. argsLength = arguments.length,
  21679. leftIndex = -1,
  21680. leftLength = partials.length,
  21681. args = Array(leftLength + argsLength),
  21682. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21683. while (++leftIndex < leftLength) {
  21684. args[leftIndex] = partials[leftIndex];
  21685. }
  21686. while (argsLength--) {
  21687. args[leftIndex++] = arguments[++argsIndex];
  21688. }
  21689. return apply(fn, isBind ? thisArg : this, args);
  21690. }
  21691. return wrapper;
  21692. }
  21693. /**
  21694. * Creates a `_.range` or `_.rangeRight` function.
  21695. *
  21696. * @private
  21697. * @param {boolean} [fromRight] Specify iterating from right to left.
  21698. * @returns {Function} Returns the new range function.
  21699. */
  21700. function createRange(fromRight) {
  21701. return function(start, end, step) {
  21702. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21703. end = step = undefined;
  21704. }
  21705. // Ensure the sign of `-0` is preserved.
  21706. start = toFinite(start);
  21707. if (end === undefined) {
  21708. end = start;
  21709. start = 0;
  21710. } else {
  21711. end = toFinite(end);
  21712. }
  21713. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21714. return baseRange(start, end, step, fromRight);
  21715. };
  21716. }
  21717. /**
  21718. * Creates a function that performs a relational operation on two values.
  21719. *
  21720. * @private
  21721. * @param {Function} operator The function to perform the operation.
  21722. * @returns {Function} Returns the new relational operation function.
  21723. */
  21724. function createRelationalOperation(operator) {
  21725. return function(value, other) {
  21726. if (!(typeof value == 'string' && typeof other == 'string')) {
  21727. value = toNumber(value);
  21728. other = toNumber(other);
  21729. }
  21730. return operator(value, other);
  21731. };
  21732. }
  21733. /**
  21734. * Creates a function that wraps `func` to continue currying.
  21735. *
  21736. * @private
  21737. * @param {Function} func The function to wrap.
  21738. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21739. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21740. * @param {*} placeholder The placeholder value.
  21741. * @param {*} [thisArg] The `this` binding of `func`.
  21742. * @param {Array} [partials] The arguments to prepend to those provided to
  21743. * the new function.
  21744. * @param {Array} [holders] The `partials` placeholder indexes.
  21745. * @param {Array} [argPos] The argument positions of the new function.
  21746. * @param {number} [ary] The arity cap of `func`.
  21747. * @param {number} [arity] The arity of `func`.
  21748. * @returns {Function} Returns the new wrapped function.
  21749. */
  21750. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21751. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21752. newHolders = isCurry ? holders : undefined,
  21753. newHoldersRight = isCurry ? undefined : holders,
  21754. newPartials = isCurry ? partials : undefined,
  21755. newPartialsRight = isCurry ? undefined : partials;
  21756. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21757. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21758. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21759. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21760. }
  21761. var newData = [
  21762. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21763. newHoldersRight, argPos, ary, arity
  21764. ];
  21765. var result = wrapFunc.apply(undefined, newData);
  21766. if (isLaziable(func)) {
  21767. setData(result, newData);
  21768. }
  21769. result.placeholder = placeholder;
  21770. return setWrapToString(result, func, bitmask);
  21771. }
  21772. /**
  21773. * Creates a function like `_.round`.
  21774. *
  21775. * @private
  21776. * @param {string} methodName The name of the `Math` method to use when rounding.
  21777. * @returns {Function} Returns the new round function.
  21778. */
  21779. function createRound(methodName) {
  21780. var func = Math[methodName];
  21781. return function(number, precision) {
  21782. number = toNumber(number);
  21783. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21784. if (precision && nativeIsFinite(number)) {
  21785. // Shift with exponential notation to avoid floating-point issues.
  21786. // See [MDN](https://mdn.io/round#Examples) for more details.
  21787. var pair = (toString(number) + 'e').split('e'),
  21788. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21789. pair = (toString(value) + 'e').split('e');
  21790. return +(pair[0] + 'e' + (+pair[1] - precision));
  21791. }
  21792. return func(number);
  21793. };
  21794. }
  21795. /**
  21796. * Creates a set object of `values`.
  21797. *
  21798. * @private
  21799. * @param {Array} values The values to add to the set.
  21800. * @returns {Object} Returns the new set.
  21801. */
  21802. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21803. return new Set(values);
  21804. };
  21805. /**
  21806. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21807. *
  21808. * @private
  21809. * @param {Function} keysFunc The function to get the keys of a given object.
  21810. * @returns {Function} Returns the new pairs function.
  21811. */
  21812. function createToPairs(keysFunc) {
  21813. return function(object) {
  21814. var tag = getTag(object);
  21815. if (tag == mapTag) {
  21816. return mapToArray(object);
  21817. }
  21818. if (tag == setTag) {
  21819. return setToPairs(object);
  21820. }
  21821. return baseToPairs(object, keysFunc(object));
  21822. };
  21823. }
  21824. /**
  21825. * Creates a function that either curries or invokes `func` with optional
  21826. * `this` binding and partially applied arguments.
  21827. *
  21828. * @private
  21829. * @param {Function|string} func The function or method name to wrap.
  21830. * @param {number} bitmask The bitmask flags.
  21831. * 1 - `_.bind`
  21832. * 2 - `_.bindKey`
  21833. * 4 - `_.curry` or `_.curryRight` of a bound function
  21834. * 8 - `_.curry`
  21835. * 16 - `_.curryRight`
  21836. * 32 - `_.partial`
  21837. * 64 - `_.partialRight`
  21838. * 128 - `_.rearg`
  21839. * 256 - `_.ary`
  21840. * 512 - `_.flip`
  21841. * @param {*} [thisArg] The `this` binding of `func`.
  21842. * @param {Array} [partials] The arguments to be partially applied.
  21843. * @param {Array} [holders] The `partials` placeholder indexes.
  21844. * @param {Array} [argPos] The argument positions of the new function.
  21845. * @param {number} [ary] The arity cap of `func`.
  21846. * @param {number} [arity] The arity of `func`.
  21847. * @returns {Function} Returns the new wrapped function.
  21848. */
  21849. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21850. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21851. if (!isBindKey && typeof func != 'function') {
  21852. throw new TypeError(FUNC_ERROR_TEXT);
  21853. }
  21854. var length = partials ? partials.length : 0;
  21855. if (!length) {
  21856. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21857. partials = holders = undefined;
  21858. }
  21859. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21860. arity = arity === undefined ? arity : toInteger(arity);
  21861. length -= holders ? holders.length : 0;
  21862. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21863. var partialsRight = partials,
  21864. holdersRight = holders;
  21865. partials = holders = undefined;
  21866. }
  21867. var data = isBindKey ? undefined : getData(func);
  21868. var newData = [
  21869. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21870. argPos, ary, arity
  21871. ];
  21872. if (data) {
  21873. mergeData(newData, data);
  21874. }
  21875. func = newData[0];
  21876. bitmask = newData[1];
  21877. thisArg = newData[2];
  21878. partials = newData[3];
  21879. holders = newData[4];
  21880. arity = newData[9] = newData[9] === undefined
  21881. ? (isBindKey ? 0 : func.length)
  21882. : nativeMax(newData[9] - length, 0);
  21883. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21884. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21885. }
  21886. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21887. var result = createBind(func, bitmask, thisArg);
  21888. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21889. result = createCurry(func, bitmask, arity);
  21890. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21891. result = createPartial(func, bitmask, thisArg, partials);
  21892. } else {
  21893. result = createHybrid.apply(undefined, newData);
  21894. }
  21895. var setter = data ? baseSetData : setData;
  21896. return setWrapToString(setter(result, newData), func, bitmask);
  21897. }
  21898. /**
  21899. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21900. * of source objects to the destination object for all destination properties
  21901. * that resolve to `undefined`.
  21902. *
  21903. * @private
  21904. * @param {*} objValue The destination value.
  21905. * @param {*} srcValue The source value.
  21906. * @param {string} key The key of the property to assign.
  21907. * @param {Object} object The parent object of `objValue`.
  21908. * @returns {*} Returns the value to assign.
  21909. */
  21910. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21911. if (objValue === undefined ||
  21912. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21913. return srcValue;
  21914. }
  21915. return objValue;
  21916. }
  21917. /**
  21918. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21919. * objects into destination objects that are passed thru.
  21920. *
  21921. * @private
  21922. * @param {*} objValue The destination value.
  21923. * @param {*} srcValue The source value.
  21924. * @param {string} key The key of the property to merge.
  21925. * @param {Object} object The parent object of `objValue`.
  21926. * @param {Object} source The parent object of `srcValue`.
  21927. * @param {Object} [stack] Tracks traversed source values and their merged
  21928. * counterparts.
  21929. * @returns {*} Returns the value to assign.
  21930. */
  21931. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21932. if (isObject(objValue) && isObject(srcValue)) {
  21933. // Recursively merge objects and arrays (susceptible to call stack limits).
  21934. stack.set(srcValue, objValue);
  21935. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21936. stack['delete'](srcValue);
  21937. }
  21938. return objValue;
  21939. }
  21940. /**
  21941. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21942. * objects.
  21943. *
  21944. * @private
  21945. * @param {*} value The value to inspect.
  21946. * @param {string} key The key of the property to inspect.
  21947. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21948. */
  21949. function customOmitClone(value) {
  21950. return isPlainObject(value) ? undefined : value;
  21951. }
  21952. /**
  21953. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21954. * partial deep comparisons.
  21955. *
  21956. * @private
  21957. * @param {Array} array The array to compare.
  21958. * @param {Array} other The other array to compare.
  21959. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21960. * @param {Function} customizer The function to customize comparisons.
  21961. * @param {Function} equalFunc The function to determine equivalents of values.
  21962. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21963. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21964. */
  21965. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21966. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  21967. arrLength = array.length,
  21968. othLength = other.length;
  21969. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21970. return false;
  21971. }
  21972. // Assume cyclic values are equal.
  21973. var stacked = stack.get(array);
  21974. if (stacked && stack.get(other)) {
  21975. return stacked == other;
  21976. }
  21977. var index = -1,
  21978. result = true,
  21979. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  21980. stack.set(array, other);
  21981. stack.set(other, array);
  21982. // Ignore non-index properties.
  21983. while (++index < arrLength) {
  21984. var arrValue = array[index],
  21985. othValue = other[index];
  21986. if (customizer) {
  21987. var compared = isPartial
  21988. ? customizer(othValue, arrValue, index, other, array, stack)
  21989. : customizer(arrValue, othValue, index, array, other, stack);
  21990. }
  21991. if (compared !== undefined) {
  21992. if (compared) {
  21993. continue;
  21994. }
  21995. result = false;
  21996. break;
  21997. }
  21998. // Recursively compare arrays (susceptible to call stack limits).
  21999. if (seen) {
  22000. if (!arraySome(other, function(othValue, othIndex) {
  22001. if (!cacheHas(seen, othIndex) &&
  22002. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22003. return seen.push(othIndex);
  22004. }
  22005. })) {
  22006. result = false;
  22007. break;
  22008. }
  22009. } else if (!(
  22010. arrValue === othValue ||
  22011. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22012. )) {
  22013. result = false;
  22014. break;
  22015. }
  22016. }
  22017. stack['delete'](array);
  22018. stack['delete'](other);
  22019. return result;
  22020. }
  22021. /**
  22022. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22023. * the same `toStringTag`.
  22024. *
  22025. * **Note:** This function only supports comparing values with tags of
  22026. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22027. *
  22028. * @private
  22029. * @param {Object} object The object to compare.
  22030. * @param {Object} other The other object to compare.
  22031. * @param {string} tag The `toStringTag` of the objects to compare.
  22032. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22033. * @param {Function} customizer The function to customize comparisons.
  22034. * @param {Function} equalFunc The function to determine equivalents of values.
  22035. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22036. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22037. */
  22038. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22039. switch (tag) {
  22040. case dataViewTag:
  22041. if ((object.byteLength != other.byteLength) ||
  22042. (object.byteOffset != other.byteOffset)) {
  22043. return false;
  22044. }
  22045. object = object.buffer;
  22046. other = other.buffer;
  22047. case arrayBufferTag:
  22048. if ((object.byteLength != other.byteLength) ||
  22049. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22050. return false;
  22051. }
  22052. return true;
  22053. case boolTag:
  22054. case dateTag:
  22055. case numberTag:
  22056. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22057. // Invalid dates are coerced to `NaN`.
  22058. return eq(+object, +other);
  22059. case errorTag:
  22060. return object.name == other.name && object.message == other.message;
  22061. case regexpTag:
  22062. case stringTag:
  22063. // Coerce regexes to strings and treat strings, primitives and objects,
  22064. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22065. // for more details.
  22066. return object == (other + '');
  22067. case mapTag:
  22068. var convert = mapToArray;
  22069. case setTag:
  22070. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22071. convert || (convert = setToArray);
  22072. if (object.size != other.size && !isPartial) {
  22073. return false;
  22074. }
  22075. // Assume cyclic values are equal.
  22076. var stacked = stack.get(object);
  22077. if (stacked) {
  22078. return stacked == other;
  22079. }
  22080. bitmask |= COMPARE_UNORDERED_FLAG;
  22081. // Recursively compare objects (susceptible to call stack limits).
  22082. stack.set(object, other);
  22083. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22084. stack['delete'](object);
  22085. return result;
  22086. case symbolTag:
  22087. if (symbolValueOf) {
  22088. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22089. }
  22090. }
  22091. return false;
  22092. }
  22093. /**
  22094. * A specialized version of `baseIsEqualDeep` for objects with support for
  22095. * partial deep comparisons.
  22096. *
  22097. * @private
  22098. * @param {Object} object The object to compare.
  22099. * @param {Object} other The other object to compare.
  22100. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22101. * @param {Function} customizer The function to customize comparisons.
  22102. * @param {Function} equalFunc The function to determine equivalents of values.
  22103. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22104. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22105. */
  22106. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22107. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22108. objProps = getAllKeys(object),
  22109. objLength = objProps.length,
  22110. othProps = getAllKeys(other),
  22111. othLength = othProps.length;
  22112. if (objLength != othLength && !isPartial) {
  22113. return false;
  22114. }
  22115. var index = objLength;
  22116. while (index--) {
  22117. var key = objProps[index];
  22118. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22119. return false;
  22120. }
  22121. }
  22122. // Assume cyclic values are equal.
  22123. var stacked = stack.get(object);
  22124. if (stacked && stack.get(other)) {
  22125. return stacked == other;
  22126. }
  22127. var result = true;
  22128. stack.set(object, other);
  22129. stack.set(other, object);
  22130. var skipCtor = isPartial;
  22131. while (++index < objLength) {
  22132. key = objProps[index];
  22133. var objValue = object[key],
  22134. othValue = other[key];
  22135. if (customizer) {
  22136. var compared = isPartial
  22137. ? customizer(othValue, objValue, key, other, object, stack)
  22138. : customizer(objValue, othValue, key, object, other, stack);
  22139. }
  22140. // Recursively compare objects (susceptible to call stack limits).
  22141. if (!(compared === undefined
  22142. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22143. : compared
  22144. )) {
  22145. result = false;
  22146. break;
  22147. }
  22148. skipCtor || (skipCtor = key == 'constructor');
  22149. }
  22150. if (result && !skipCtor) {
  22151. var objCtor = object.constructor,
  22152. othCtor = other.constructor;
  22153. // Non `Object` object instances with different constructors are not equal.
  22154. if (objCtor != othCtor &&
  22155. ('constructor' in object && 'constructor' in other) &&
  22156. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22157. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22158. result = false;
  22159. }
  22160. }
  22161. stack['delete'](object);
  22162. stack['delete'](other);
  22163. return result;
  22164. }
  22165. /**
  22166. * A specialized version of `baseRest` which flattens the rest array.
  22167. *
  22168. * @private
  22169. * @param {Function} func The function to apply a rest parameter to.
  22170. * @returns {Function} Returns the new function.
  22171. */
  22172. function flatRest(func) {
  22173. return setToString(overRest(func, undefined, flatten), func + '');
  22174. }
  22175. /**
  22176. * Creates an array of own enumerable property names and symbols of `object`.
  22177. *
  22178. * @private
  22179. * @param {Object} object The object to query.
  22180. * @returns {Array} Returns the array of property names and symbols.
  22181. */
  22182. function getAllKeys(object) {
  22183. return baseGetAllKeys(object, keys, getSymbols);
  22184. }
  22185. /**
  22186. * Creates an array of own and inherited enumerable property names and
  22187. * symbols of `object`.
  22188. *
  22189. * @private
  22190. * @param {Object} object The object to query.
  22191. * @returns {Array} Returns the array of property names and symbols.
  22192. */
  22193. function getAllKeysIn(object) {
  22194. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22195. }
  22196. /**
  22197. * Gets metadata for `func`.
  22198. *
  22199. * @private
  22200. * @param {Function} func The function to query.
  22201. * @returns {*} Returns the metadata for `func`.
  22202. */
  22203. var getData = !metaMap ? noop : function(func) {
  22204. return metaMap.get(func);
  22205. };
  22206. /**
  22207. * Gets the name of `func`.
  22208. *
  22209. * @private
  22210. * @param {Function} func The function to query.
  22211. * @returns {string} Returns the function name.
  22212. */
  22213. function getFuncName(func) {
  22214. var result = (func.name + ''),
  22215. array = realNames[result],
  22216. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22217. while (length--) {
  22218. var data = array[length],
  22219. otherFunc = data.func;
  22220. if (otherFunc == null || otherFunc == func) {
  22221. return data.name;
  22222. }
  22223. }
  22224. return result;
  22225. }
  22226. /**
  22227. * Gets the argument placeholder value for `func`.
  22228. *
  22229. * @private
  22230. * @param {Function} func The function to inspect.
  22231. * @returns {*} Returns the placeholder value.
  22232. */
  22233. function getHolder(func) {
  22234. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22235. return object.placeholder;
  22236. }
  22237. /**
  22238. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22239. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22240. * If arguments are provided, the chosen function is invoked with them and
  22241. * its result is returned.
  22242. *
  22243. * @private
  22244. * @param {*} [value] The value to convert to an iteratee.
  22245. * @param {number} [arity] The arity of the created iteratee.
  22246. * @returns {Function} Returns the chosen function or its result.
  22247. */
  22248. function getIteratee() {
  22249. var result = lodash.iteratee || iteratee;
  22250. result = result === iteratee ? baseIteratee : result;
  22251. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22252. }
  22253. /**
  22254. * Gets the data for `map`.
  22255. *
  22256. * @private
  22257. * @param {Object} map The map to query.
  22258. * @param {string} key The reference key.
  22259. * @returns {*} Returns the map data.
  22260. */
  22261. function getMapData(map, key) {
  22262. var data = map.__data__;
  22263. return isKeyable(key)
  22264. ? data[typeof key == 'string' ? 'string' : 'hash']
  22265. : data.map;
  22266. }
  22267. /**
  22268. * Gets the property names, values, and compare flags of `object`.
  22269. *
  22270. * @private
  22271. * @param {Object} object The object to query.
  22272. * @returns {Array} Returns the match data of `object`.
  22273. */
  22274. function getMatchData(object) {
  22275. var result = keys(object),
  22276. length = result.length;
  22277. while (length--) {
  22278. var key = result[length],
  22279. value = object[key];
  22280. result[length] = [key, value, isStrictComparable(value)];
  22281. }
  22282. return result;
  22283. }
  22284. /**
  22285. * Gets the native function at `key` of `object`.
  22286. *
  22287. * @private
  22288. * @param {Object} object The object to query.
  22289. * @param {string} key The key of the method to get.
  22290. * @returns {*} Returns the function if it's native, else `undefined`.
  22291. */
  22292. function getNative(object, key) {
  22293. var value = getValue(object, key);
  22294. return baseIsNative(value) ? value : undefined;
  22295. }
  22296. /**
  22297. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22298. *
  22299. * @private
  22300. * @param {*} value The value to query.
  22301. * @returns {string} Returns the raw `toStringTag`.
  22302. */
  22303. function getRawTag(value) {
  22304. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22305. tag = value[symToStringTag];
  22306. try {
  22307. value[symToStringTag] = undefined;
  22308. var unmasked = true;
  22309. } catch (e) {}
  22310. var result = nativeObjectToString.call(value);
  22311. if (unmasked) {
  22312. if (isOwn) {
  22313. value[symToStringTag] = tag;
  22314. } else {
  22315. delete value[symToStringTag];
  22316. }
  22317. }
  22318. return result;
  22319. }
  22320. /**
  22321. * Creates an array of the own enumerable symbols of `object`.
  22322. *
  22323. * @private
  22324. * @param {Object} object The object to query.
  22325. * @returns {Array} Returns the array of symbols.
  22326. */
  22327. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22328. if (object == null) {
  22329. return [];
  22330. }
  22331. object = Object(object);
  22332. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22333. return propertyIsEnumerable.call(object, symbol);
  22334. });
  22335. };
  22336. /**
  22337. * Creates an array of the own and inherited enumerable symbols of `object`.
  22338. *
  22339. * @private
  22340. * @param {Object} object The object to query.
  22341. * @returns {Array} Returns the array of symbols.
  22342. */
  22343. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22344. var result = [];
  22345. while (object) {
  22346. arrayPush(result, getSymbols(object));
  22347. object = getPrototype(object);
  22348. }
  22349. return result;
  22350. };
  22351. /**
  22352. * Gets the `toStringTag` of `value`.
  22353. *
  22354. * @private
  22355. * @param {*} value The value to query.
  22356. * @returns {string} Returns the `toStringTag`.
  22357. */
  22358. var getTag = baseGetTag;
  22359. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22360. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22361. (Map && getTag(new Map) != mapTag) ||
  22362. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22363. (Set && getTag(new Set) != setTag) ||
  22364. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22365. getTag = function(value) {
  22366. var result = baseGetTag(value),
  22367. Ctor = result == objectTag ? value.constructor : undefined,
  22368. ctorString = Ctor ? toSource(Ctor) : '';
  22369. if (ctorString) {
  22370. switch (ctorString) {
  22371. case dataViewCtorString: return dataViewTag;
  22372. case mapCtorString: return mapTag;
  22373. case promiseCtorString: return promiseTag;
  22374. case setCtorString: return setTag;
  22375. case weakMapCtorString: return weakMapTag;
  22376. }
  22377. }
  22378. return result;
  22379. };
  22380. }
  22381. /**
  22382. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22383. *
  22384. * @private
  22385. * @param {number} start The start of the view.
  22386. * @param {number} end The end of the view.
  22387. * @param {Array} transforms The transformations to apply to the view.
  22388. * @returns {Object} Returns an object containing the `start` and `end`
  22389. * positions of the view.
  22390. */
  22391. function getView(start, end, transforms) {
  22392. var index = -1,
  22393. length = transforms.length;
  22394. while (++index < length) {
  22395. var data = transforms[index],
  22396. size = data.size;
  22397. switch (data.type) {
  22398. case 'drop': start += size; break;
  22399. case 'dropRight': end -= size; break;
  22400. case 'take': end = nativeMin(end, start + size); break;
  22401. case 'takeRight': start = nativeMax(start, end - size); break;
  22402. }
  22403. }
  22404. return { 'start': start, 'end': end };
  22405. }
  22406. /**
  22407. * Extracts wrapper details from the `source` body comment.
  22408. *
  22409. * @private
  22410. * @param {string} source The source to inspect.
  22411. * @returns {Array} Returns the wrapper details.
  22412. */
  22413. function getWrapDetails(source) {
  22414. var match = source.match(reWrapDetails);
  22415. return match ? match[1].split(reSplitDetails) : [];
  22416. }
  22417. /**
  22418. * Checks if `path` exists on `object`.
  22419. *
  22420. * @private
  22421. * @param {Object} object The object to query.
  22422. * @param {Array|string} path The path to check.
  22423. * @param {Function} hasFunc The function to check properties.
  22424. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22425. */
  22426. function hasPath(object, path, hasFunc) {
  22427. path = castPath(path, object);
  22428. var index = -1,
  22429. length = path.length,
  22430. result = false;
  22431. while (++index < length) {
  22432. var key = toKey(path[index]);
  22433. if (!(result = object != null && hasFunc(object, key))) {
  22434. break;
  22435. }
  22436. object = object[key];
  22437. }
  22438. if (result || ++index != length) {
  22439. return result;
  22440. }
  22441. length = object == null ? 0 : object.length;
  22442. return !!length && isLength(length) && isIndex(key, length) &&
  22443. (isArray(object) || isArguments(object));
  22444. }
  22445. /**
  22446. * Initializes an array clone.
  22447. *
  22448. * @private
  22449. * @param {Array} array The array to clone.
  22450. * @returns {Array} Returns the initialized clone.
  22451. */
  22452. function initCloneArray(array) {
  22453. var length = array.length,
  22454. result = new array.constructor(length);
  22455. // Add properties assigned by `RegExp#exec`.
  22456. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22457. result.index = array.index;
  22458. result.input = array.input;
  22459. }
  22460. return result;
  22461. }
  22462. /**
  22463. * Initializes an object clone.
  22464. *
  22465. * @private
  22466. * @param {Object} object The object to clone.
  22467. * @returns {Object} Returns the initialized clone.
  22468. */
  22469. function initCloneObject(object) {
  22470. return (typeof object.constructor == 'function' && !isPrototype(object))
  22471. ? baseCreate(getPrototype(object))
  22472. : {};
  22473. }
  22474. /**
  22475. * Initializes an object clone based on its `toStringTag`.
  22476. *
  22477. * **Note:** This function only supports cloning values with tags of
  22478. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22479. *
  22480. * @private
  22481. * @param {Object} object The object to clone.
  22482. * @param {string} tag The `toStringTag` of the object to clone.
  22483. * @param {boolean} [isDeep] Specify a deep clone.
  22484. * @returns {Object} Returns the initialized clone.
  22485. */
  22486. function initCloneByTag(object, tag, isDeep) {
  22487. var Ctor = object.constructor;
  22488. switch (tag) {
  22489. case arrayBufferTag:
  22490. return cloneArrayBuffer(object);
  22491. case boolTag:
  22492. case dateTag:
  22493. return new Ctor(+object);
  22494. case dataViewTag:
  22495. return cloneDataView(object, isDeep);
  22496. case float32Tag: case float64Tag:
  22497. case int8Tag: case int16Tag: case int32Tag:
  22498. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22499. return cloneTypedArray(object, isDeep);
  22500. case mapTag:
  22501. return new Ctor;
  22502. case numberTag:
  22503. case stringTag:
  22504. return new Ctor(object);
  22505. case regexpTag:
  22506. return cloneRegExp(object);
  22507. case setTag:
  22508. return new Ctor;
  22509. case symbolTag:
  22510. return cloneSymbol(object);
  22511. }
  22512. }
  22513. /**
  22514. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22515. *
  22516. * @private
  22517. * @param {string} source The source to modify.
  22518. * @returns {Array} details The details to insert.
  22519. * @returns {string} Returns the modified source.
  22520. */
  22521. function insertWrapDetails(source, details) {
  22522. var length = details.length;
  22523. if (!length) {
  22524. return source;
  22525. }
  22526. var lastIndex = length - 1;
  22527. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22528. details = details.join(length > 2 ? ', ' : ' ');
  22529. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22530. }
  22531. /**
  22532. * Checks if `value` is a flattenable `arguments` object or array.
  22533. *
  22534. * @private
  22535. * @param {*} value The value to check.
  22536. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22537. */
  22538. function isFlattenable(value) {
  22539. return isArray(value) || isArguments(value) ||
  22540. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22541. }
  22542. /**
  22543. * Checks if `value` is a valid array-like index.
  22544. *
  22545. * @private
  22546. * @param {*} value The value to check.
  22547. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22548. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22549. */
  22550. function isIndex(value, length) {
  22551. var type = typeof value;
  22552. length = length == null ? MAX_SAFE_INTEGER : length;
  22553. return !!length &&
  22554. (type == 'number' ||
  22555. (type != 'symbol' && reIsUint.test(value))) &&
  22556. (value > -1 && value % 1 == 0 && value < length);
  22557. }
  22558. /**
  22559. * Checks if the given arguments are from an iteratee call.
  22560. *
  22561. * @private
  22562. * @param {*} value The potential iteratee value argument.
  22563. * @param {*} index The potential iteratee index or key argument.
  22564. * @param {*} object The potential iteratee object argument.
  22565. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22566. * else `false`.
  22567. */
  22568. function isIterateeCall(value, index, object) {
  22569. if (!isObject(object)) {
  22570. return false;
  22571. }
  22572. var type = typeof index;
  22573. if (type == 'number'
  22574. ? (isArrayLike(object) && isIndex(index, object.length))
  22575. : (type == 'string' && index in object)
  22576. ) {
  22577. return eq(object[index], value);
  22578. }
  22579. return false;
  22580. }
  22581. /**
  22582. * Checks if `value` is a property name and not a property path.
  22583. *
  22584. * @private
  22585. * @param {*} value The value to check.
  22586. * @param {Object} [object] The object to query keys on.
  22587. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22588. */
  22589. function isKey(value, object) {
  22590. if (isArray(value)) {
  22591. return false;
  22592. }
  22593. var type = typeof value;
  22594. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22595. value == null || isSymbol(value)) {
  22596. return true;
  22597. }
  22598. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22599. (object != null && value in Object(object));
  22600. }
  22601. /**
  22602. * Checks if `value` is suitable for use as unique object key.
  22603. *
  22604. * @private
  22605. * @param {*} value The value to check.
  22606. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22607. */
  22608. function isKeyable(value) {
  22609. var type = typeof value;
  22610. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22611. ? (value !== '__proto__')
  22612. : (value === null);
  22613. }
  22614. /**
  22615. * Checks if `func` has a lazy counterpart.
  22616. *
  22617. * @private
  22618. * @param {Function} func The function to check.
  22619. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22620. * else `false`.
  22621. */
  22622. function isLaziable(func) {
  22623. var funcName = getFuncName(func),
  22624. other = lodash[funcName];
  22625. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22626. return false;
  22627. }
  22628. if (func === other) {
  22629. return true;
  22630. }
  22631. var data = getData(other);
  22632. return !!data && func === data[0];
  22633. }
  22634. /**
  22635. * Checks if `func` has its source masked.
  22636. *
  22637. * @private
  22638. * @param {Function} func The function to check.
  22639. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22640. */
  22641. function isMasked(func) {
  22642. return !!maskSrcKey && (maskSrcKey in func);
  22643. }
  22644. /**
  22645. * Checks if `func` is capable of being masked.
  22646. *
  22647. * @private
  22648. * @param {*} value The value to check.
  22649. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22650. */
  22651. var isMaskable = coreJsData ? isFunction : stubFalse;
  22652. /**
  22653. * Checks if `value` is likely a prototype object.
  22654. *
  22655. * @private
  22656. * @param {*} value The value to check.
  22657. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22658. */
  22659. function isPrototype(value) {
  22660. var Ctor = value && value.constructor,
  22661. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22662. return value === proto;
  22663. }
  22664. /**
  22665. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22666. *
  22667. * @private
  22668. * @param {*} value The value to check.
  22669. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22670. * equality comparisons, else `false`.
  22671. */
  22672. function isStrictComparable(value) {
  22673. return value === value && !isObject(value);
  22674. }
  22675. /**
  22676. * A specialized version of `matchesProperty` for source values suitable
  22677. * for strict equality comparisons, i.e. `===`.
  22678. *
  22679. * @private
  22680. * @param {string} key The key of the property to get.
  22681. * @param {*} srcValue The value to match.
  22682. * @returns {Function} Returns the new spec function.
  22683. */
  22684. function matchesStrictComparable(key, srcValue) {
  22685. return function(object) {
  22686. if (object == null) {
  22687. return false;
  22688. }
  22689. return object[key] === srcValue &&
  22690. (srcValue !== undefined || (key in Object(object)));
  22691. };
  22692. }
  22693. /**
  22694. * A specialized version of `_.memoize` which clears the memoized function's
  22695. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22696. *
  22697. * @private
  22698. * @param {Function} func The function to have its output memoized.
  22699. * @returns {Function} Returns the new memoized function.
  22700. */
  22701. function memoizeCapped(func) {
  22702. var result = memoize(func, function(key) {
  22703. if (cache.size === MAX_MEMOIZE_SIZE) {
  22704. cache.clear();
  22705. }
  22706. return key;
  22707. });
  22708. var cache = result.cache;
  22709. return result;
  22710. }
  22711. /**
  22712. * Merges the function metadata of `source` into `data`.
  22713. *
  22714. * Merging metadata reduces the number of wrappers used to invoke a function.
  22715. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22716. * may be applied regardless of execution order. Methods like `_.ary` and
  22717. * `_.rearg` modify function arguments, making the order in which they are
  22718. * executed important, preventing the merging of metadata. However, we make
  22719. * an exception for a safe combined case where curried functions have `_.ary`
  22720. * and or `_.rearg` applied.
  22721. *
  22722. * @private
  22723. * @param {Array} data The destination metadata.
  22724. * @param {Array} source The source metadata.
  22725. * @returns {Array} Returns `data`.
  22726. */
  22727. function mergeData(data, source) {
  22728. var bitmask = data[1],
  22729. srcBitmask = source[1],
  22730. newBitmask = bitmask | srcBitmask,
  22731. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22732. var isCombo =
  22733. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22734. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22735. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22736. // Exit early if metadata can't be merged.
  22737. if (!(isCommon || isCombo)) {
  22738. return data;
  22739. }
  22740. // Use source `thisArg` if available.
  22741. if (srcBitmask & WRAP_BIND_FLAG) {
  22742. data[2] = source[2];
  22743. // Set when currying a bound function.
  22744. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22745. }
  22746. // Compose partial arguments.
  22747. var value = source[3];
  22748. if (value) {
  22749. var partials = data[3];
  22750. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22751. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22752. }
  22753. // Compose partial right arguments.
  22754. value = source[5];
  22755. if (value) {
  22756. partials = data[5];
  22757. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22758. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22759. }
  22760. // Use source `argPos` if available.
  22761. value = source[7];
  22762. if (value) {
  22763. data[7] = value;
  22764. }
  22765. // Use source `ary` if it's smaller.
  22766. if (srcBitmask & WRAP_ARY_FLAG) {
  22767. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22768. }
  22769. // Use source `arity` if one is not provided.
  22770. if (data[9] == null) {
  22771. data[9] = source[9];
  22772. }
  22773. // Use source `func` and merge bitmasks.
  22774. data[0] = source[0];
  22775. data[1] = newBitmask;
  22776. return data;
  22777. }
  22778. /**
  22779. * This function is like
  22780. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22781. * except that it includes inherited enumerable properties.
  22782. *
  22783. * @private
  22784. * @param {Object} object The object to query.
  22785. * @returns {Array} Returns the array of property names.
  22786. */
  22787. function nativeKeysIn(object) {
  22788. var result = [];
  22789. if (object != null) {
  22790. for (var key in Object(object)) {
  22791. result.push(key);
  22792. }
  22793. }
  22794. return result;
  22795. }
  22796. /**
  22797. * Converts `value` to a string using `Object.prototype.toString`.
  22798. *
  22799. * @private
  22800. * @param {*} value The value to convert.
  22801. * @returns {string} Returns the converted string.
  22802. */
  22803. function objectToString(value) {
  22804. return nativeObjectToString.call(value);
  22805. }
  22806. /**
  22807. * A specialized version of `baseRest` which transforms the rest array.
  22808. *
  22809. * @private
  22810. * @param {Function} func The function to apply a rest parameter to.
  22811. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22812. * @param {Function} transform The rest array transform.
  22813. * @returns {Function} Returns the new function.
  22814. */
  22815. function overRest(func, start, transform) {
  22816. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22817. return function() {
  22818. var args = arguments,
  22819. index = -1,
  22820. length = nativeMax(args.length - start, 0),
  22821. array = Array(length);
  22822. while (++index < length) {
  22823. array[index] = args[start + index];
  22824. }
  22825. index = -1;
  22826. var otherArgs = Array(start + 1);
  22827. while (++index < start) {
  22828. otherArgs[index] = args[index];
  22829. }
  22830. otherArgs[start] = transform(array);
  22831. return apply(func, this, otherArgs);
  22832. };
  22833. }
  22834. /**
  22835. * Gets the parent value at `path` of `object`.
  22836. *
  22837. * @private
  22838. * @param {Object} object The object to query.
  22839. * @param {Array} path The path to get the parent value of.
  22840. * @returns {*} Returns the parent value.
  22841. */
  22842. function parent(object, path) {
  22843. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22844. }
  22845. /**
  22846. * Reorder `array` according to the specified indexes where the element at
  22847. * the first index is assigned as the first element, the element at
  22848. * the second index is assigned as the second element, and so on.
  22849. *
  22850. * @private
  22851. * @param {Array} array The array to reorder.
  22852. * @param {Array} indexes The arranged array indexes.
  22853. * @returns {Array} Returns `array`.
  22854. */
  22855. function reorder(array, indexes) {
  22856. var arrLength = array.length,
  22857. length = nativeMin(indexes.length, arrLength),
  22858. oldArray = copyArray(array);
  22859. while (length--) {
  22860. var index = indexes[length];
  22861. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22862. }
  22863. return array;
  22864. }
  22865. /**
  22866. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22867. *
  22868. * @private
  22869. * @param {Object} object The object to query.
  22870. * @param {string} key The key of the property to get.
  22871. * @returns {*} Returns the property value.
  22872. */
  22873. function safeGet(object, key) {
  22874. if (key === 'constructor' && typeof object[key] === 'function') {
  22875. return;
  22876. }
  22877. if (key == '__proto__') {
  22878. return;
  22879. }
  22880. return object[key];
  22881. }
  22882. /**
  22883. * Sets metadata for `func`.
  22884. *
  22885. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22886. * period of time, it will trip its breaker and transition to an identity
  22887. * function to avoid garbage collection pauses in V8. See
  22888. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22889. * for more details.
  22890. *
  22891. * @private
  22892. * @param {Function} func The function to associate metadata with.
  22893. * @param {*} data The metadata.
  22894. * @returns {Function} Returns `func`.
  22895. */
  22896. var setData = shortOut(baseSetData);
  22897. /**
  22898. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22899. *
  22900. * @private
  22901. * @param {Function} func The function to delay.
  22902. * @param {number} wait The number of milliseconds to delay invocation.
  22903. * @returns {number|Object} Returns the timer id or timeout object.
  22904. */
  22905. var setTimeout = ctxSetTimeout || function(func, wait) {
  22906. return root.setTimeout(func, wait);
  22907. };
  22908. /**
  22909. * Sets the `toString` method of `func` to return `string`.
  22910. *
  22911. * @private
  22912. * @param {Function} func The function to modify.
  22913. * @param {Function} string The `toString` result.
  22914. * @returns {Function} Returns `func`.
  22915. */
  22916. var setToString = shortOut(baseSetToString);
  22917. /**
  22918. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22919. * with wrapper details in a comment at the top of the source body.
  22920. *
  22921. * @private
  22922. * @param {Function} wrapper The function to modify.
  22923. * @param {Function} reference The reference function.
  22924. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22925. * @returns {Function} Returns `wrapper`.
  22926. */
  22927. function setWrapToString(wrapper, reference, bitmask) {
  22928. var source = (reference + '');
  22929. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22930. }
  22931. /**
  22932. * Creates a function that'll short out and invoke `identity` instead
  22933. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22934. * milliseconds.
  22935. *
  22936. * @private
  22937. * @param {Function} func The function to restrict.
  22938. * @returns {Function} Returns the new shortable function.
  22939. */
  22940. function shortOut(func) {
  22941. var count = 0,
  22942. lastCalled = 0;
  22943. return function() {
  22944. var stamp = nativeNow(),
  22945. remaining = HOT_SPAN - (stamp - lastCalled);
  22946. lastCalled = stamp;
  22947. if (remaining > 0) {
  22948. if (++count >= HOT_COUNT) {
  22949. return arguments[0];
  22950. }
  22951. } else {
  22952. count = 0;
  22953. }
  22954. return func.apply(undefined, arguments);
  22955. };
  22956. }
  22957. /**
  22958. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  22959. *
  22960. * @private
  22961. * @param {Array} array The array to shuffle.
  22962. * @param {number} [size=array.length] The size of `array`.
  22963. * @returns {Array} Returns `array`.
  22964. */
  22965. function shuffleSelf(array, size) {
  22966. var index = -1,
  22967. length = array.length,
  22968. lastIndex = length - 1;
  22969. size = size === undefined ? length : size;
  22970. while (++index < size) {
  22971. var rand = baseRandom(index, lastIndex),
  22972. value = array[rand];
  22973. array[rand] = array[index];
  22974. array[index] = value;
  22975. }
  22976. array.length = size;
  22977. return array;
  22978. }
  22979. /**
  22980. * Converts `string` to a property path array.
  22981. *
  22982. * @private
  22983. * @param {string} string The string to convert.
  22984. * @returns {Array} Returns the property path array.
  22985. */
  22986. var stringToPath = memoizeCapped(function(string) {
  22987. var result = [];
  22988. if (string.charCodeAt(0) === 46 /* . */) {
  22989. result.push('');
  22990. }
  22991. string.replace(rePropName, function(match, number, quote, subString) {
  22992. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  22993. });
  22994. return result;
  22995. });
  22996. /**
  22997. * Converts `value` to a string key if it's not a string or symbol.
  22998. *
  22999. * @private
  23000. * @param {*} value The value to inspect.
  23001. * @returns {string|symbol} Returns the key.
  23002. */
  23003. function toKey(value) {
  23004. if (typeof value == 'string' || isSymbol(value)) {
  23005. return value;
  23006. }
  23007. var result = (value + '');
  23008. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23009. }
  23010. /**
  23011. * Converts `func` to its source code.
  23012. *
  23013. * @private
  23014. * @param {Function} func The function to convert.
  23015. * @returns {string} Returns the source code.
  23016. */
  23017. function toSource(func) {
  23018. if (func != null) {
  23019. try {
  23020. return funcToString.call(func);
  23021. } catch (e) {}
  23022. try {
  23023. return (func + '');
  23024. } catch (e) {}
  23025. }
  23026. return '';
  23027. }
  23028. /**
  23029. * Updates wrapper `details` based on `bitmask` flags.
  23030. *
  23031. * @private
  23032. * @returns {Array} details The details to modify.
  23033. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23034. * @returns {Array} Returns `details`.
  23035. */
  23036. function updateWrapDetails(details, bitmask) {
  23037. arrayEach(wrapFlags, function(pair) {
  23038. var value = '_.' + pair[0];
  23039. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23040. details.push(value);
  23041. }
  23042. });
  23043. return details.sort();
  23044. }
  23045. /**
  23046. * Creates a clone of `wrapper`.
  23047. *
  23048. * @private
  23049. * @param {Object} wrapper The wrapper to clone.
  23050. * @returns {Object} Returns the cloned wrapper.
  23051. */
  23052. function wrapperClone(wrapper) {
  23053. if (wrapper instanceof LazyWrapper) {
  23054. return wrapper.clone();
  23055. }
  23056. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23057. result.__actions__ = copyArray(wrapper.__actions__);
  23058. result.__index__ = wrapper.__index__;
  23059. result.__values__ = wrapper.__values__;
  23060. return result;
  23061. }
  23062. /*------------------------------------------------------------------------*/
  23063. /**
  23064. * Creates an array of elements split into groups the length of `size`.
  23065. * If `array` can't be split evenly, the final chunk will be the remaining
  23066. * elements.
  23067. *
  23068. * @static
  23069. * @memberOf _
  23070. * @since 3.0.0
  23071. * @category Array
  23072. * @param {Array} array The array to process.
  23073. * @param {number} [size=1] The length of each chunk
  23074. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23075. * @returns {Array} Returns the new array of chunks.
  23076. * @example
  23077. *
  23078. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23079. * // => [['a', 'b'], ['c', 'd']]
  23080. *
  23081. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23082. * // => [['a', 'b', 'c'], ['d']]
  23083. */
  23084. function chunk(array, size, guard) {
  23085. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23086. size = 1;
  23087. } else {
  23088. size = nativeMax(toInteger(size), 0);
  23089. }
  23090. var length = array == null ? 0 : array.length;
  23091. if (!length || size < 1) {
  23092. return [];
  23093. }
  23094. var index = 0,
  23095. resIndex = 0,
  23096. result = Array(nativeCeil(length / size));
  23097. while (index < length) {
  23098. result[resIndex++] = baseSlice(array, index, (index += size));
  23099. }
  23100. return result;
  23101. }
  23102. /**
  23103. * Creates an array with all falsey values removed. The values `false`, `null`,
  23104. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23105. *
  23106. * @static
  23107. * @memberOf _
  23108. * @since 0.1.0
  23109. * @category Array
  23110. * @param {Array} array The array to compact.
  23111. * @returns {Array} Returns the new array of filtered values.
  23112. * @example
  23113. *
  23114. * _.compact([0, 1, false, 2, '', 3]);
  23115. * // => [1, 2, 3]
  23116. */
  23117. function compact(array) {
  23118. var index = -1,
  23119. length = array == null ? 0 : array.length,
  23120. resIndex = 0,
  23121. result = [];
  23122. while (++index < length) {
  23123. var value = array[index];
  23124. if (value) {
  23125. result[resIndex++] = value;
  23126. }
  23127. }
  23128. return result;
  23129. }
  23130. /**
  23131. * Creates a new array concatenating `array` with any additional arrays
  23132. * and/or values.
  23133. *
  23134. * @static
  23135. * @memberOf _
  23136. * @since 4.0.0
  23137. * @category Array
  23138. * @param {Array} array The array to concatenate.
  23139. * @param {...*} [values] The values to concatenate.
  23140. * @returns {Array} Returns the new concatenated array.
  23141. * @example
  23142. *
  23143. * var array = [1];
  23144. * var other = _.concat(array, 2, [3], [[4]]);
  23145. *
  23146. * console.log(other);
  23147. * // => [1, 2, 3, [4]]
  23148. *
  23149. * console.log(array);
  23150. * // => [1]
  23151. */
  23152. function concat() {
  23153. var length = arguments.length;
  23154. if (!length) {
  23155. return [];
  23156. }
  23157. var args = Array(length - 1),
  23158. array = arguments[0],
  23159. index = length;
  23160. while (index--) {
  23161. args[index - 1] = arguments[index];
  23162. }
  23163. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23164. }
  23165. /**
  23166. * Creates an array of `array` values not included in the other given arrays
  23167. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23168. * for equality comparisons. The order and references of result values are
  23169. * determined by the first array.
  23170. *
  23171. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23172. *
  23173. * @static
  23174. * @memberOf _
  23175. * @since 0.1.0
  23176. * @category Array
  23177. * @param {Array} array The array to inspect.
  23178. * @param {...Array} [values] The values to exclude.
  23179. * @returns {Array} Returns the new array of filtered values.
  23180. * @see _.without, _.xor
  23181. * @example
  23182. *
  23183. * _.difference([2, 1], [2, 3]);
  23184. * // => [1]
  23185. */
  23186. var difference = baseRest(function(array, values) {
  23187. return isArrayLikeObject(array)
  23188. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23189. : [];
  23190. });
  23191. /**
  23192. * This method is like `_.difference` except that it accepts `iteratee` which
  23193. * is invoked for each element of `array` and `values` to generate the criterion
  23194. * by which they're compared. The order and references of result values are
  23195. * determined by the first array. The iteratee is invoked with one argument:
  23196. * (value).
  23197. *
  23198. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23199. *
  23200. * @static
  23201. * @memberOf _
  23202. * @since 4.0.0
  23203. * @category Array
  23204. * @param {Array} array The array to inspect.
  23205. * @param {...Array} [values] The values to exclude.
  23206. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23207. * @returns {Array} Returns the new array of filtered values.
  23208. * @example
  23209. *
  23210. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23211. * // => [1.2]
  23212. *
  23213. * // The `_.property` iteratee shorthand.
  23214. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23215. * // => [{ 'x': 2 }]
  23216. */
  23217. var differenceBy = baseRest(function(array, values) {
  23218. var iteratee = last(values);
  23219. if (isArrayLikeObject(iteratee)) {
  23220. iteratee = undefined;
  23221. }
  23222. return isArrayLikeObject(array)
  23223. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23224. : [];
  23225. });
  23226. /**
  23227. * This method is like `_.difference` except that it accepts `comparator`
  23228. * which is invoked to compare elements of `array` to `values`. The order and
  23229. * references of result values are determined by the first array. The comparator
  23230. * is invoked with two arguments: (arrVal, othVal).
  23231. *
  23232. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23233. *
  23234. * @static
  23235. * @memberOf _
  23236. * @since 4.0.0
  23237. * @category Array
  23238. * @param {Array} array The array to inspect.
  23239. * @param {...Array} [values] The values to exclude.
  23240. * @param {Function} [comparator] The comparator invoked per element.
  23241. * @returns {Array} Returns the new array of filtered values.
  23242. * @example
  23243. *
  23244. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23245. *
  23246. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23247. * // => [{ 'x': 2, 'y': 1 }]
  23248. */
  23249. var differenceWith = baseRest(function(array, values) {
  23250. var comparator = last(values);
  23251. if (isArrayLikeObject(comparator)) {
  23252. comparator = undefined;
  23253. }
  23254. return isArrayLikeObject(array)
  23255. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23256. : [];
  23257. });
  23258. /**
  23259. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23260. *
  23261. * @static
  23262. * @memberOf _
  23263. * @since 0.5.0
  23264. * @category Array
  23265. * @param {Array} array The array to query.
  23266. * @param {number} [n=1] The number of elements to drop.
  23267. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23268. * @returns {Array} Returns the slice of `array`.
  23269. * @example
  23270. *
  23271. * _.drop([1, 2, 3]);
  23272. * // => [2, 3]
  23273. *
  23274. * _.drop([1, 2, 3], 2);
  23275. * // => [3]
  23276. *
  23277. * _.drop([1, 2, 3], 5);
  23278. * // => []
  23279. *
  23280. * _.drop([1, 2, 3], 0);
  23281. * // => [1, 2, 3]
  23282. */
  23283. function drop(array, n, guard) {
  23284. var length = array == null ? 0 : array.length;
  23285. if (!length) {
  23286. return [];
  23287. }
  23288. n = (guard || n === undefined) ? 1 : toInteger(n);
  23289. return baseSlice(array, n < 0 ? 0 : n, length);
  23290. }
  23291. /**
  23292. * Creates a slice of `array` with `n` elements dropped from the end.
  23293. *
  23294. * @static
  23295. * @memberOf _
  23296. * @since 3.0.0
  23297. * @category Array
  23298. * @param {Array} array The array to query.
  23299. * @param {number} [n=1] The number of elements to drop.
  23300. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23301. * @returns {Array} Returns the slice of `array`.
  23302. * @example
  23303. *
  23304. * _.dropRight([1, 2, 3]);
  23305. * // => [1, 2]
  23306. *
  23307. * _.dropRight([1, 2, 3], 2);
  23308. * // => [1]
  23309. *
  23310. * _.dropRight([1, 2, 3], 5);
  23311. * // => []
  23312. *
  23313. * _.dropRight([1, 2, 3], 0);
  23314. * // => [1, 2, 3]
  23315. */
  23316. function dropRight(array, n, guard) {
  23317. var length = array == null ? 0 : array.length;
  23318. if (!length) {
  23319. return [];
  23320. }
  23321. n = (guard || n === undefined) ? 1 : toInteger(n);
  23322. n = length - n;
  23323. return baseSlice(array, 0, n < 0 ? 0 : n);
  23324. }
  23325. /**
  23326. * Creates a slice of `array` excluding elements dropped from the end.
  23327. * Elements are dropped until `predicate` returns falsey. The predicate is
  23328. * invoked with three arguments: (value, index, array).
  23329. *
  23330. * @static
  23331. * @memberOf _
  23332. * @since 3.0.0
  23333. * @category Array
  23334. * @param {Array} array The array to query.
  23335. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23336. * @returns {Array} Returns the slice of `array`.
  23337. * @example
  23338. *
  23339. * var users = [
  23340. * { 'user': 'barney', 'active': true },
  23341. * { 'user': 'fred', 'active': false },
  23342. * { 'user': 'pebbles', 'active': false }
  23343. * ];
  23344. *
  23345. * _.dropRightWhile(users, function(o) { return !o.active; });
  23346. * // => objects for ['barney']
  23347. *
  23348. * // The `_.matches` iteratee shorthand.
  23349. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23350. * // => objects for ['barney', 'fred']
  23351. *
  23352. * // The `_.matchesProperty` iteratee shorthand.
  23353. * _.dropRightWhile(users, ['active', false]);
  23354. * // => objects for ['barney']
  23355. *
  23356. * // The `_.property` iteratee shorthand.
  23357. * _.dropRightWhile(users, 'active');
  23358. * // => objects for ['barney', 'fred', 'pebbles']
  23359. */
  23360. function dropRightWhile(array, predicate) {
  23361. return (array && array.length)
  23362. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23363. : [];
  23364. }
  23365. /**
  23366. * Creates a slice of `array` excluding elements dropped from the beginning.
  23367. * Elements are dropped until `predicate` returns falsey. The predicate is
  23368. * invoked with three arguments: (value, index, array).
  23369. *
  23370. * @static
  23371. * @memberOf _
  23372. * @since 3.0.0
  23373. * @category Array
  23374. * @param {Array} array The array to query.
  23375. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23376. * @returns {Array} Returns the slice of `array`.
  23377. * @example
  23378. *
  23379. * var users = [
  23380. * { 'user': 'barney', 'active': false },
  23381. * { 'user': 'fred', 'active': false },
  23382. * { 'user': 'pebbles', 'active': true }
  23383. * ];
  23384. *
  23385. * _.dropWhile(users, function(o) { return !o.active; });
  23386. * // => objects for ['pebbles']
  23387. *
  23388. * // The `_.matches` iteratee shorthand.
  23389. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23390. * // => objects for ['fred', 'pebbles']
  23391. *
  23392. * // The `_.matchesProperty` iteratee shorthand.
  23393. * _.dropWhile(users, ['active', false]);
  23394. * // => objects for ['pebbles']
  23395. *
  23396. * // The `_.property` iteratee shorthand.
  23397. * _.dropWhile(users, 'active');
  23398. * // => objects for ['barney', 'fred', 'pebbles']
  23399. */
  23400. function dropWhile(array, predicate) {
  23401. return (array && array.length)
  23402. ? baseWhile(array, getIteratee(predicate, 3), true)
  23403. : [];
  23404. }
  23405. /**
  23406. * Fills elements of `array` with `value` from `start` up to, but not
  23407. * including, `end`.
  23408. *
  23409. * **Note:** This method mutates `array`.
  23410. *
  23411. * @static
  23412. * @memberOf _
  23413. * @since 3.2.0
  23414. * @category Array
  23415. * @param {Array} array The array to fill.
  23416. * @param {*} value The value to fill `array` with.
  23417. * @param {number} [start=0] The start position.
  23418. * @param {number} [end=array.length] The end position.
  23419. * @returns {Array} Returns `array`.
  23420. * @example
  23421. *
  23422. * var array = [1, 2, 3];
  23423. *
  23424. * _.fill(array, 'a');
  23425. * console.log(array);
  23426. * // => ['a', 'a', 'a']
  23427. *
  23428. * _.fill(Array(3), 2);
  23429. * // => [2, 2, 2]
  23430. *
  23431. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23432. * // => [4, '*', '*', 10]
  23433. */
  23434. function fill(array, value, start, end) {
  23435. var length = array == null ? 0 : array.length;
  23436. if (!length) {
  23437. return [];
  23438. }
  23439. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23440. start = 0;
  23441. end = length;
  23442. }
  23443. return baseFill(array, value, start, end);
  23444. }
  23445. /**
  23446. * This method is like `_.find` except that it returns the index of the first
  23447. * element `predicate` returns truthy for instead of the element itself.
  23448. *
  23449. * @static
  23450. * @memberOf _
  23451. * @since 1.1.0
  23452. * @category Array
  23453. * @param {Array} array The array to inspect.
  23454. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23455. * @param {number} [fromIndex=0] The index to search from.
  23456. * @returns {number} Returns the index of the found element, else `-1`.
  23457. * @example
  23458. *
  23459. * var users = [
  23460. * { 'user': 'barney', 'active': false },
  23461. * { 'user': 'fred', 'active': false },
  23462. * { 'user': 'pebbles', 'active': true }
  23463. * ];
  23464. *
  23465. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23466. * // => 0
  23467. *
  23468. * // The `_.matches` iteratee shorthand.
  23469. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23470. * // => 1
  23471. *
  23472. * // The `_.matchesProperty` iteratee shorthand.
  23473. * _.findIndex(users, ['active', false]);
  23474. * // => 0
  23475. *
  23476. * // The `_.property` iteratee shorthand.
  23477. * _.findIndex(users, 'active');
  23478. * // => 2
  23479. */
  23480. function findIndex(array, predicate, fromIndex) {
  23481. var length = array == null ? 0 : array.length;
  23482. if (!length) {
  23483. return -1;
  23484. }
  23485. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23486. if (index < 0) {
  23487. index = nativeMax(length + index, 0);
  23488. }
  23489. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23490. }
  23491. /**
  23492. * This method is like `_.findIndex` except that it iterates over elements
  23493. * of `collection` from right to left.
  23494. *
  23495. * @static
  23496. * @memberOf _
  23497. * @since 2.0.0
  23498. * @category Array
  23499. * @param {Array} array The array to inspect.
  23500. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23501. * @param {number} [fromIndex=array.length-1] The index to search from.
  23502. * @returns {number} Returns the index of the found element, else `-1`.
  23503. * @example
  23504. *
  23505. * var users = [
  23506. * { 'user': 'barney', 'active': true },
  23507. * { 'user': 'fred', 'active': false },
  23508. * { 'user': 'pebbles', 'active': false }
  23509. * ];
  23510. *
  23511. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23512. * // => 2
  23513. *
  23514. * // The `_.matches` iteratee shorthand.
  23515. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23516. * // => 0
  23517. *
  23518. * // The `_.matchesProperty` iteratee shorthand.
  23519. * _.findLastIndex(users, ['active', false]);
  23520. * // => 2
  23521. *
  23522. * // The `_.property` iteratee shorthand.
  23523. * _.findLastIndex(users, 'active');
  23524. * // => 0
  23525. */
  23526. function findLastIndex(array, predicate, fromIndex) {
  23527. var length = array == null ? 0 : array.length;
  23528. if (!length) {
  23529. return -1;
  23530. }
  23531. var index = length - 1;
  23532. if (fromIndex !== undefined) {
  23533. index = toInteger(fromIndex);
  23534. index = fromIndex < 0
  23535. ? nativeMax(length + index, 0)
  23536. : nativeMin(index, length - 1);
  23537. }
  23538. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23539. }
  23540. /**
  23541. * Flattens `array` a single level deep.
  23542. *
  23543. * @static
  23544. * @memberOf _
  23545. * @since 0.1.0
  23546. * @category Array
  23547. * @param {Array} array The array to flatten.
  23548. * @returns {Array} Returns the new flattened array.
  23549. * @example
  23550. *
  23551. * _.flatten([1, [2, [3, [4]], 5]]);
  23552. * // => [1, 2, [3, [4]], 5]
  23553. */
  23554. function flatten(array) {
  23555. var length = array == null ? 0 : array.length;
  23556. return length ? baseFlatten(array, 1) : [];
  23557. }
  23558. /**
  23559. * Recursively flattens `array`.
  23560. *
  23561. * @static
  23562. * @memberOf _
  23563. * @since 3.0.0
  23564. * @category Array
  23565. * @param {Array} array The array to flatten.
  23566. * @returns {Array} Returns the new flattened array.
  23567. * @example
  23568. *
  23569. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23570. * // => [1, 2, 3, 4, 5]
  23571. */
  23572. function flattenDeep(array) {
  23573. var length = array == null ? 0 : array.length;
  23574. return length ? baseFlatten(array, INFINITY) : [];
  23575. }
  23576. /**
  23577. * Recursively flatten `array` up to `depth` times.
  23578. *
  23579. * @static
  23580. * @memberOf _
  23581. * @since 4.4.0
  23582. * @category Array
  23583. * @param {Array} array The array to flatten.
  23584. * @param {number} [depth=1] The maximum recursion depth.
  23585. * @returns {Array} Returns the new flattened array.
  23586. * @example
  23587. *
  23588. * var array = [1, [2, [3, [4]], 5]];
  23589. *
  23590. * _.flattenDepth(array, 1);
  23591. * // => [1, 2, [3, [4]], 5]
  23592. *
  23593. * _.flattenDepth(array, 2);
  23594. * // => [1, 2, 3, [4], 5]
  23595. */
  23596. function flattenDepth(array, depth) {
  23597. var length = array == null ? 0 : array.length;
  23598. if (!length) {
  23599. return [];
  23600. }
  23601. depth = depth === undefined ? 1 : toInteger(depth);
  23602. return baseFlatten(array, depth);
  23603. }
  23604. /**
  23605. * The inverse of `_.toPairs`; this method returns an object composed
  23606. * from key-value `pairs`.
  23607. *
  23608. * @static
  23609. * @memberOf _
  23610. * @since 4.0.0
  23611. * @category Array
  23612. * @param {Array} pairs The key-value pairs.
  23613. * @returns {Object} Returns the new object.
  23614. * @example
  23615. *
  23616. * _.fromPairs([['a', 1], ['b', 2]]);
  23617. * // => { 'a': 1, 'b': 2 }
  23618. */
  23619. function fromPairs(pairs) {
  23620. var index = -1,
  23621. length = pairs == null ? 0 : pairs.length,
  23622. result = {};
  23623. while (++index < length) {
  23624. var pair = pairs[index];
  23625. result[pair[0]] = pair[1];
  23626. }
  23627. return result;
  23628. }
  23629. /**
  23630. * Gets the first element of `array`.
  23631. *
  23632. * @static
  23633. * @memberOf _
  23634. * @since 0.1.0
  23635. * @alias first
  23636. * @category Array
  23637. * @param {Array} array The array to query.
  23638. * @returns {*} Returns the first element of `array`.
  23639. * @example
  23640. *
  23641. * _.head([1, 2, 3]);
  23642. * // => 1
  23643. *
  23644. * _.head([]);
  23645. * // => undefined
  23646. */
  23647. function head(array) {
  23648. return (array && array.length) ? array[0] : undefined;
  23649. }
  23650. /**
  23651. * Gets the index at which the first occurrence of `value` is found in `array`
  23652. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23653. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23654. * offset from the end of `array`.
  23655. *
  23656. * @static
  23657. * @memberOf _
  23658. * @since 0.1.0
  23659. * @category Array
  23660. * @param {Array} array The array to inspect.
  23661. * @param {*} value The value to search for.
  23662. * @param {number} [fromIndex=0] The index to search from.
  23663. * @returns {number} Returns the index of the matched value, else `-1`.
  23664. * @example
  23665. *
  23666. * _.indexOf([1, 2, 1, 2], 2);
  23667. * // => 1
  23668. *
  23669. * // Search from the `fromIndex`.
  23670. * _.indexOf([1, 2, 1, 2], 2, 2);
  23671. * // => 3
  23672. */
  23673. function indexOf(array, value, fromIndex) {
  23674. var length = array == null ? 0 : array.length;
  23675. if (!length) {
  23676. return -1;
  23677. }
  23678. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23679. if (index < 0) {
  23680. index = nativeMax(length + index, 0);
  23681. }
  23682. return baseIndexOf(array, value, index);
  23683. }
  23684. /**
  23685. * Gets all but the last element of `array`.
  23686. *
  23687. * @static
  23688. * @memberOf _
  23689. * @since 0.1.0
  23690. * @category Array
  23691. * @param {Array} array The array to query.
  23692. * @returns {Array} Returns the slice of `array`.
  23693. * @example
  23694. *
  23695. * _.initial([1, 2, 3]);
  23696. * // => [1, 2]
  23697. */
  23698. function initial(array) {
  23699. var length = array == null ? 0 : array.length;
  23700. return length ? baseSlice(array, 0, -1) : [];
  23701. }
  23702. /**
  23703. * Creates an array of unique values that are included in all given arrays
  23704. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23705. * for equality comparisons. The order and references of result values are
  23706. * determined by the first array.
  23707. *
  23708. * @static
  23709. * @memberOf _
  23710. * @since 0.1.0
  23711. * @category Array
  23712. * @param {...Array} [arrays] The arrays to inspect.
  23713. * @returns {Array} Returns the new array of intersecting values.
  23714. * @example
  23715. *
  23716. * _.intersection([2, 1], [2, 3]);
  23717. * // => [2]
  23718. */
  23719. var intersection = baseRest(function(arrays) {
  23720. var mapped = arrayMap(arrays, castArrayLikeObject);
  23721. return (mapped.length && mapped[0] === arrays[0])
  23722. ? baseIntersection(mapped)
  23723. : [];
  23724. });
  23725. /**
  23726. * This method is like `_.intersection` except that it accepts `iteratee`
  23727. * which is invoked for each element of each `arrays` to generate the criterion
  23728. * by which they're compared. The order and references of result values are
  23729. * determined by the first array. The iteratee is invoked with one argument:
  23730. * (value).
  23731. *
  23732. * @static
  23733. * @memberOf _
  23734. * @since 4.0.0
  23735. * @category Array
  23736. * @param {...Array} [arrays] The arrays to inspect.
  23737. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23738. * @returns {Array} Returns the new array of intersecting values.
  23739. * @example
  23740. *
  23741. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23742. * // => [2.1]
  23743. *
  23744. * // The `_.property` iteratee shorthand.
  23745. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23746. * // => [{ 'x': 1 }]
  23747. */
  23748. var intersectionBy = baseRest(function(arrays) {
  23749. var iteratee = last(arrays),
  23750. mapped = arrayMap(arrays, castArrayLikeObject);
  23751. if (iteratee === last(mapped)) {
  23752. iteratee = undefined;
  23753. } else {
  23754. mapped.pop();
  23755. }
  23756. return (mapped.length && mapped[0] === arrays[0])
  23757. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23758. : [];
  23759. });
  23760. /**
  23761. * This method is like `_.intersection` except that it accepts `comparator`
  23762. * which is invoked to compare elements of `arrays`. The order and references
  23763. * of result values are determined by the first array. The comparator is
  23764. * invoked with two arguments: (arrVal, othVal).
  23765. *
  23766. * @static
  23767. * @memberOf _
  23768. * @since 4.0.0
  23769. * @category Array
  23770. * @param {...Array} [arrays] The arrays to inspect.
  23771. * @param {Function} [comparator] The comparator invoked per element.
  23772. * @returns {Array} Returns the new array of intersecting values.
  23773. * @example
  23774. *
  23775. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23776. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23777. *
  23778. * _.intersectionWith(objects, others, _.isEqual);
  23779. * // => [{ 'x': 1, 'y': 2 }]
  23780. */
  23781. var intersectionWith = baseRest(function(arrays) {
  23782. var comparator = last(arrays),
  23783. mapped = arrayMap(arrays, castArrayLikeObject);
  23784. comparator = typeof comparator == 'function' ? comparator : undefined;
  23785. if (comparator) {
  23786. mapped.pop();
  23787. }
  23788. return (mapped.length && mapped[0] === arrays[0])
  23789. ? baseIntersection(mapped, undefined, comparator)
  23790. : [];
  23791. });
  23792. /**
  23793. * Converts all elements in `array` into a string separated by `separator`.
  23794. *
  23795. * @static
  23796. * @memberOf _
  23797. * @since 4.0.0
  23798. * @category Array
  23799. * @param {Array} array The array to convert.
  23800. * @param {string} [separator=','] The element separator.
  23801. * @returns {string} Returns the joined string.
  23802. * @example
  23803. *
  23804. * _.join(['a', 'b', 'c'], '~');
  23805. * // => 'a~b~c'
  23806. */
  23807. function join(array, separator) {
  23808. return array == null ? '' : nativeJoin.call(array, separator);
  23809. }
  23810. /**
  23811. * Gets the last element of `array`.
  23812. *
  23813. * @static
  23814. * @memberOf _
  23815. * @since 0.1.0
  23816. * @category Array
  23817. * @param {Array} array The array to query.
  23818. * @returns {*} Returns the last element of `array`.
  23819. * @example
  23820. *
  23821. * _.last([1, 2, 3]);
  23822. * // => 3
  23823. */
  23824. function last(array) {
  23825. var length = array == null ? 0 : array.length;
  23826. return length ? array[length - 1] : undefined;
  23827. }
  23828. /**
  23829. * This method is like `_.indexOf` except that it iterates over elements of
  23830. * `array` from right to left.
  23831. *
  23832. * @static
  23833. * @memberOf _
  23834. * @since 0.1.0
  23835. * @category Array
  23836. * @param {Array} array The array to inspect.
  23837. * @param {*} value The value to search for.
  23838. * @param {number} [fromIndex=array.length-1] The index to search from.
  23839. * @returns {number} Returns the index of the matched value, else `-1`.
  23840. * @example
  23841. *
  23842. * _.lastIndexOf([1, 2, 1, 2], 2);
  23843. * // => 3
  23844. *
  23845. * // Search from the `fromIndex`.
  23846. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23847. * // => 1
  23848. */
  23849. function lastIndexOf(array, value, fromIndex) {
  23850. var length = array == null ? 0 : array.length;
  23851. if (!length) {
  23852. return -1;
  23853. }
  23854. var index = length;
  23855. if (fromIndex !== undefined) {
  23856. index = toInteger(fromIndex);
  23857. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23858. }
  23859. return value === value
  23860. ? strictLastIndexOf(array, value, index)
  23861. : baseFindIndex(array, baseIsNaN, index, true);
  23862. }
  23863. /**
  23864. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23865. * element from the end is returned.
  23866. *
  23867. * @static
  23868. * @memberOf _
  23869. * @since 4.11.0
  23870. * @category Array
  23871. * @param {Array} array The array to query.
  23872. * @param {number} [n=0] The index of the element to return.
  23873. * @returns {*} Returns the nth element of `array`.
  23874. * @example
  23875. *
  23876. * var array = ['a', 'b', 'c', 'd'];
  23877. *
  23878. * _.nth(array, 1);
  23879. * // => 'b'
  23880. *
  23881. * _.nth(array, -2);
  23882. * // => 'c';
  23883. */
  23884. function nth(array, n) {
  23885. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23886. }
  23887. /**
  23888. * Removes all given values from `array` using
  23889. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23890. * for equality comparisons.
  23891. *
  23892. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23893. * to remove elements from an array by predicate.
  23894. *
  23895. * @static
  23896. * @memberOf _
  23897. * @since 2.0.0
  23898. * @category Array
  23899. * @param {Array} array The array to modify.
  23900. * @param {...*} [values] The values to remove.
  23901. * @returns {Array} Returns `array`.
  23902. * @example
  23903. *
  23904. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23905. *
  23906. * _.pull(array, 'a', 'c');
  23907. * console.log(array);
  23908. * // => ['b', 'b']
  23909. */
  23910. var pull = baseRest(pullAll);
  23911. /**
  23912. * This method is like `_.pull` except that it accepts an array of values to remove.
  23913. *
  23914. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23915. *
  23916. * @static
  23917. * @memberOf _
  23918. * @since 4.0.0
  23919. * @category Array
  23920. * @param {Array} array The array to modify.
  23921. * @param {Array} values The values to remove.
  23922. * @returns {Array} Returns `array`.
  23923. * @example
  23924. *
  23925. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23926. *
  23927. * _.pullAll(array, ['a', 'c']);
  23928. * console.log(array);
  23929. * // => ['b', 'b']
  23930. */
  23931. function pullAll(array, values) {
  23932. return (array && array.length && values && values.length)
  23933. ? basePullAll(array, values)
  23934. : array;
  23935. }
  23936. /**
  23937. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23938. * invoked for each element of `array` and `values` to generate the criterion
  23939. * by which they're compared. The iteratee is invoked with one argument: (value).
  23940. *
  23941. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23942. *
  23943. * @static
  23944. * @memberOf _
  23945. * @since 4.0.0
  23946. * @category Array
  23947. * @param {Array} array The array to modify.
  23948. * @param {Array} values The values to remove.
  23949. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23950. * @returns {Array} Returns `array`.
  23951. * @example
  23952. *
  23953. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23954. *
  23955. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  23956. * console.log(array);
  23957. * // => [{ 'x': 2 }]
  23958. */
  23959. function pullAllBy(array, values, iteratee) {
  23960. return (array && array.length && values && values.length)
  23961. ? basePullAll(array, values, getIteratee(iteratee, 2))
  23962. : array;
  23963. }
  23964. /**
  23965. * This method is like `_.pullAll` except that it accepts `comparator` which
  23966. * is invoked to compare elements of `array` to `values`. The comparator is
  23967. * invoked with two arguments: (arrVal, othVal).
  23968. *
  23969. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  23970. *
  23971. * @static
  23972. * @memberOf _
  23973. * @since 4.6.0
  23974. * @category Array
  23975. * @param {Array} array The array to modify.
  23976. * @param {Array} values The values to remove.
  23977. * @param {Function} [comparator] The comparator invoked per element.
  23978. * @returns {Array} Returns `array`.
  23979. * @example
  23980. *
  23981. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  23982. *
  23983. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  23984. * console.log(array);
  23985. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  23986. */
  23987. function pullAllWith(array, values, comparator) {
  23988. return (array && array.length && values && values.length)
  23989. ? basePullAll(array, values, undefined, comparator)
  23990. : array;
  23991. }
  23992. /**
  23993. * Removes elements from `array` corresponding to `indexes` and returns an
  23994. * array of removed elements.
  23995. *
  23996. * **Note:** Unlike `_.at`, this method mutates `array`.
  23997. *
  23998. * @static
  23999. * @memberOf _
  24000. * @since 3.0.0
  24001. * @category Array
  24002. * @param {Array} array The array to modify.
  24003. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24004. * @returns {Array} Returns the new array of removed elements.
  24005. * @example
  24006. *
  24007. * var array = ['a', 'b', 'c', 'd'];
  24008. * var pulled = _.pullAt(array, [1, 3]);
  24009. *
  24010. * console.log(array);
  24011. * // => ['a', 'c']
  24012. *
  24013. * console.log(pulled);
  24014. * // => ['b', 'd']
  24015. */
  24016. var pullAt = flatRest(function(array, indexes) {
  24017. var length = array == null ? 0 : array.length,
  24018. result = baseAt(array, indexes);
  24019. basePullAt(array, arrayMap(indexes, function(index) {
  24020. return isIndex(index, length) ? +index : index;
  24021. }).sort(compareAscending));
  24022. return result;
  24023. });
  24024. /**
  24025. * Removes all elements from `array` that `predicate` returns truthy for
  24026. * and returns an array of the removed elements. The predicate is invoked
  24027. * with three arguments: (value, index, array).
  24028. *
  24029. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24030. * to pull elements from an array by value.
  24031. *
  24032. * @static
  24033. * @memberOf _
  24034. * @since 2.0.0
  24035. * @category Array
  24036. * @param {Array} array The array to modify.
  24037. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24038. * @returns {Array} Returns the new array of removed elements.
  24039. * @example
  24040. *
  24041. * var array = [1, 2, 3, 4];
  24042. * var evens = _.remove(array, function(n) {
  24043. * return n % 2 == 0;
  24044. * });
  24045. *
  24046. * console.log(array);
  24047. * // => [1, 3]
  24048. *
  24049. * console.log(evens);
  24050. * // => [2, 4]
  24051. */
  24052. function remove(array, predicate) {
  24053. var result = [];
  24054. if (!(array && array.length)) {
  24055. return result;
  24056. }
  24057. var index = -1,
  24058. indexes = [],
  24059. length = array.length;
  24060. predicate = getIteratee(predicate, 3);
  24061. while (++index < length) {
  24062. var value = array[index];
  24063. if (predicate(value, index, array)) {
  24064. result.push(value);
  24065. indexes.push(index);
  24066. }
  24067. }
  24068. basePullAt(array, indexes);
  24069. return result;
  24070. }
  24071. /**
  24072. * Reverses `array` so that the first element becomes the last, the second
  24073. * element becomes the second to last, and so on.
  24074. *
  24075. * **Note:** This method mutates `array` and is based on
  24076. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24077. *
  24078. * @static
  24079. * @memberOf _
  24080. * @since 4.0.0
  24081. * @category Array
  24082. * @param {Array} array The array to modify.
  24083. * @returns {Array} Returns `array`.
  24084. * @example
  24085. *
  24086. * var array = [1, 2, 3];
  24087. *
  24088. * _.reverse(array);
  24089. * // => [3, 2, 1]
  24090. *
  24091. * console.log(array);
  24092. * // => [3, 2, 1]
  24093. */
  24094. function reverse(array) {
  24095. return array == null ? array : nativeReverse.call(array);
  24096. }
  24097. /**
  24098. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24099. *
  24100. * **Note:** This method is used instead of
  24101. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24102. * returned.
  24103. *
  24104. * @static
  24105. * @memberOf _
  24106. * @since 3.0.0
  24107. * @category Array
  24108. * @param {Array} array The array to slice.
  24109. * @param {number} [start=0] The start position.
  24110. * @param {number} [end=array.length] The end position.
  24111. * @returns {Array} Returns the slice of `array`.
  24112. */
  24113. function slice(array, start, end) {
  24114. var length = array == null ? 0 : array.length;
  24115. if (!length) {
  24116. return [];
  24117. }
  24118. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24119. start = 0;
  24120. end = length;
  24121. }
  24122. else {
  24123. start = start == null ? 0 : toInteger(start);
  24124. end = end === undefined ? length : toInteger(end);
  24125. }
  24126. return baseSlice(array, start, end);
  24127. }
  24128. /**
  24129. * Uses a binary search to determine the lowest index at which `value`
  24130. * should be inserted into `array` in order to maintain its sort order.
  24131. *
  24132. * @static
  24133. * @memberOf _
  24134. * @since 0.1.0
  24135. * @category Array
  24136. * @param {Array} array The sorted array to inspect.
  24137. * @param {*} value The value to evaluate.
  24138. * @returns {number} Returns the index at which `value` should be inserted
  24139. * into `array`.
  24140. * @example
  24141. *
  24142. * _.sortedIndex([30, 50], 40);
  24143. * // => 1
  24144. */
  24145. function sortedIndex(array, value) {
  24146. return baseSortedIndex(array, value);
  24147. }
  24148. /**
  24149. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24150. * which is invoked for `value` and each element of `array` to compute their
  24151. * sort ranking. The iteratee is invoked with one argument: (value).
  24152. *
  24153. * @static
  24154. * @memberOf _
  24155. * @since 4.0.0
  24156. * @category Array
  24157. * @param {Array} array The sorted array to inspect.
  24158. * @param {*} value The value to evaluate.
  24159. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24160. * @returns {number} Returns the index at which `value` should be inserted
  24161. * into `array`.
  24162. * @example
  24163. *
  24164. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24165. *
  24166. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24167. * // => 0
  24168. *
  24169. * // The `_.property` iteratee shorthand.
  24170. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24171. * // => 0
  24172. */
  24173. function sortedIndexBy(array, value, iteratee) {
  24174. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24175. }
  24176. /**
  24177. * This method is like `_.indexOf` except that it performs a binary
  24178. * search on a sorted `array`.
  24179. *
  24180. * @static
  24181. * @memberOf _
  24182. * @since 4.0.0
  24183. * @category Array
  24184. * @param {Array} array The array to inspect.
  24185. * @param {*} value The value to search for.
  24186. * @returns {number} Returns the index of the matched value, else `-1`.
  24187. * @example
  24188. *
  24189. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24190. * // => 1
  24191. */
  24192. function sortedIndexOf(array, value) {
  24193. var length = array == null ? 0 : array.length;
  24194. if (length) {
  24195. var index = baseSortedIndex(array, value);
  24196. if (index < length && eq(array[index], value)) {
  24197. return index;
  24198. }
  24199. }
  24200. return -1;
  24201. }
  24202. /**
  24203. * This method is like `_.sortedIndex` except that it returns the highest
  24204. * index at which `value` should be inserted into `array` in order to
  24205. * maintain its sort order.
  24206. *
  24207. * @static
  24208. * @memberOf _
  24209. * @since 3.0.0
  24210. * @category Array
  24211. * @param {Array} array The sorted array to inspect.
  24212. * @param {*} value The value to evaluate.
  24213. * @returns {number} Returns the index at which `value` should be inserted
  24214. * into `array`.
  24215. * @example
  24216. *
  24217. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24218. * // => 4
  24219. */
  24220. function sortedLastIndex(array, value) {
  24221. return baseSortedIndex(array, value, true);
  24222. }
  24223. /**
  24224. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24225. * which is invoked for `value` and each element of `array` to compute their
  24226. * sort ranking. The iteratee is invoked with one argument: (value).
  24227. *
  24228. * @static
  24229. * @memberOf _
  24230. * @since 4.0.0
  24231. * @category Array
  24232. * @param {Array} array The sorted array to inspect.
  24233. * @param {*} value The value to evaluate.
  24234. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24235. * @returns {number} Returns the index at which `value` should be inserted
  24236. * into `array`.
  24237. * @example
  24238. *
  24239. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24240. *
  24241. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24242. * // => 1
  24243. *
  24244. * // The `_.property` iteratee shorthand.
  24245. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24246. * // => 1
  24247. */
  24248. function sortedLastIndexBy(array, value, iteratee) {
  24249. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24250. }
  24251. /**
  24252. * This method is like `_.lastIndexOf` except that it performs a binary
  24253. * search on a sorted `array`.
  24254. *
  24255. * @static
  24256. * @memberOf _
  24257. * @since 4.0.0
  24258. * @category Array
  24259. * @param {Array} array The array to inspect.
  24260. * @param {*} value The value to search for.
  24261. * @returns {number} Returns the index of the matched value, else `-1`.
  24262. * @example
  24263. *
  24264. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24265. * // => 3
  24266. */
  24267. function sortedLastIndexOf(array, value) {
  24268. var length = array == null ? 0 : array.length;
  24269. if (length) {
  24270. var index = baseSortedIndex(array, value, true) - 1;
  24271. if (eq(array[index], value)) {
  24272. return index;
  24273. }
  24274. }
  24275. return -1;
  24276. }
  24277. /**
  24278. * This method is like `_.uniq` except that it's designed and optimized
  24279. * for sorted arrays.
  24280. *
  24281. * @static
  24282. * @memberOf _
  24283. * @since 4.0.0
  24284. * @category Array
  24285. * @param {Array} array The array to inspect.
  24286. * @returns {Array} Returns the new duplicate free array.
  24287. * @example
  24288. *
  24289. * _.sortedUniq([1, 1, 2]);
  24290. * // => [1, 2]
  24291. */
  24292. function sortedUniq(array) {
  24293. return (array && array.length)
  24294. ? baseSortedUniq(array)
  24295. : [];
  24296. }
  24297. /**
  24298. * This method is like `_.uniqBy` except that it's designed and optimized
  24299. * for sorted arrays.
  24300. *
  24301. * @static
  24302. * @memberOf _
  24303. * @since 4.0.0
  24304. * @category Array
  24305. * @param {Array} array The array to inspect.
  24306. * @param {Function} [iteratee] The iteratee invoked per element.
  24307. * @returns {Array} Returns the new duplicate free array.
  24308. * @example
  24309. *
  24310. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24311. * // => [1.1, 2.3]
  24312. */
  24313. function sortedUniqBy(array, iteratee) {
  24314. return (array && array.length)
  24315. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24316. : [];
  24317. }
  24318. /**
  24319. * Gets all but the first element of `array`.
  24320. *
  24321. * @static
  24322. * @memberOf _
  24323. * @since 4.0.0
  24324. * @category Array
  24325. * @param {Array} array The array to query.
  24326. * @returns {Array} Returns the slice of `array`.
  24327. * @example
  24328. *
  24329. * _.tail([1, 2, 3]);
  24330. * // => [2, 3]
  24331. */
  24332. function tail(array) {
  24333. var length = array == null ? 0 : array.length;
  24334. return length ? baseSlice(array, 1, length) : [];
  24335. }
  24336. /**
  24337. * Creates a slice of `array` with `n` elements taken from the beginning.
  24338. *
  24339. * @static
  24340. * @memberOf _
  24341. * @since 0.1.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. * _.take([1, 2, 3]);
  24350. * // => [1]
  24351. *
  24352. * _.take([1, 2, 3], 2);
  24353. * // => [1, 2]
  24354. *
  24355. * _.take([1, 2, 3], 5);
  24356. * // => [1, 2, 3]
  24357. *
  24358. * _.take([1, 2, 3], 0);
  24359. * // => []
  24360. */
  24361. function take(array, n, guard) {
  24362. if (!(array && array.length)) {
  24363. return [];
  24364. }
  24365. n = (guard || n === undefined) ? 1 : toInteger(n);
  24366. return baseSlice(array, 0, n < 0 ? 0 : n);
  24367. }
  24368. /**
  24369. * Creates a slice of `array` with `n` elements taken from the end.
  24370. *
  24371. * @static
  24372. * @memberOf _
  24373. * @since 3.0.0
  24374. * @category Array
  24375. * @param {Array} array The array to query.
  24376. * @param {number} [n=1] The number of elements to take.
  24377. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24378. * @returns {Array} Returns the slice of `array`.
  24379. * @example
  24380. *
  24381. * _.takeRight([1, 2, 3]);
  24382. * // => [3]
  24383. *
  24384. * _.takeRight([1, 2, 3], 2);
  24385. * // => [2, 3]
  24386. *
  24387. * _.takeRight([1, 2, 3], 5);
  24388. * // => [1, 2, 3]
  24389. *
  24390. * _.takeRight([1, 2, 3], 0);
  24391. * // => []
  24392. */
  24393. function takeRight(array, n, guard) {
  24394. var length = array == null ? 0 : array.length;
  24395. if (!length) {
  24396. return [];
  24397. }
  24398. n = (guard || n === undefined) ? 1 : toInteger(n);
  24399. n = length - n;
  24400. return baseSlice(array, n < 0 ? 0 : n, length);
  24401. }
  24402. /**
  24403. * Creates a slice of `array` with elements taken from the end. Elements are
  24404. * taken until `predicate` returns falsey. The predicate is invoked with
  24405. * three arguments: (value, index, array).
  24406. *
  24407. * @static
  24408. * @memberOf _
  24409. * @since 3.0.0
  24410. * @category Array
  24411. * @param {Array} array The array to query.
  24412. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24413. * @returns {Array} Returns the slice of `array`.
  24414. * @example
  24415. *
  24416. * var users = [
  24417. * { 'user': 'barney', 'active': true },
  24418. * { 'user': 'fred', 'active': false },
  24419. * { 'user': 'pebbles', 'active': false }
  24420. * ];
  24421. *
  24422. * _.takeRightWhile(users, function(o) { return !o.active; });
  24423. * // => objects for ['fred', 'pebbles']
  24424. *
  24425. * // The `_.matches` iteratee shorthand.
  24426. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24427. * // => objects for ['pebbles']
  24428. *
  24429. * // The `_.matchesProperty` iteratee shorthand.
  24430. * _.takeRightWhile(users, ['active', false]);
  24431. * // => objects for ['fred', 'pebbles']
  24432. *
  24433. * // The `_.property` iteratee shorthand.
  24434. * _.takeRightWhile(users, 'active');
  24435. * // => []
  24436. */
  24437. function takeRightWhile(array, predicate) {
  24438. return (array && array.length)
  24439. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24440. : [];
  24441. }
  24442. /**
  24443. * Creates a slice of `array` with elements taken from the beginning. Elements
  24444. * are taken until `predicate` returns falsey. The predicate is invoked with
  24445. * three arguments: (value, index, array).
  24446. *
  24447. * @static
  24448. * @memberOf _
  24449. * @since 3.0.0
  24450. * @category Array
  24451. * @param {Array} array The array to query.
  24452. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24453. * @returns {Array} Returns the slice of `array`.
  24454. * @example
  24455. *
  24456. * var users = [
  24457. * { 'user': 'barney', 'active': false },
  24458. * { 'user': 'fred', 'active': false },
  24459. * { 'user': 'pebbles', 'active': true }
  24460. * ];
  24461. *
  24462. * _.takeWhile(users, function(o) { return !o.active; });
  24463. * // => objects for ['barney', 'fred']
  24464. *
  24465. * // The `_.matches` iteratee shorthand.
  24466. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24467. * // => objects for ['barney']
  24468. *
  24469. * // The `_.matchesProperty` iteratee shorthand.
  24470. * _.takeWhile(users, ['active', false]);
  24471. * // => objects for ['barney', 'fred']
  24472. *
  24473. * // The `_.property` iteratee shorthand.
  24474. * _.takeWhile(users, 'active');
  24475. * // => []
  24476. */
  24477. function takeWhile(array, predicate) {
  24478. return (array && array.length)
  24479. ? baseWhile(array, getIteratee(predicate, 3))
  24480. : [];
  24481. }
  24482. /**
  24483. * Creates an array of unique values, in order, from all given arrays using
  24484. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24485. * for equality comparisons.
  24486. *
  24487. * @static
  24488. * @memberOf _
  24489. * @since 0.1.0
  24490. * @category Array
  24491. * @param {...Array} [arrays] The arrays to inspect.
  24492. * @returns {Array} Returns the new array of combined values.
  24493. * @example
  24494. *
  24495. * _.union([2], [1, 2]);
  24496. * // => [2, 1]
  24497. */
  24498. var union = baseRest(function(arrays) {
  24499. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24500. });
  24501. /**
  24502. * This method is like `_.union` except that it accepts `iteratee` which is
  24503. * invoked for each element of each `arrays` to generate the criterion by
  24504. * which uniqueness is computed. Result values are chosen from the first
  24505. * array in which the value occurs. The iteratee is invoked with one argument:
  24506. * (value).
  24507. *
  24508. * @static
  24509. * @memberOf _
  24510. * @since 4.0.0
  24511. * @category Array
  24512. * @param {...Array} [arrays] The arrays to inspect.
  24513. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24514. * @returns {Array} Returns the new array of combined values.
  24515. * @example
  24516. *
  24517. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24518. * // => [2.1, 1.2]
  24519. *
  24520. * // The `_.property` iteratee shorthand.
  24521. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24522. * // => [{ 'x': 1 }, { 'x': 2 }]
  24523. */
  24524. var unionBy = baseRest(function(arrays) {
  24525. var iteratee = last(arrays);
  24526. if (isArrayLikeObject(iteratee)) {
  24527. iteratee = undefined;
  24528. }
  24529. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24530. });
  24531. /**
  24532. * This method is like `_.union` except that it accepts `comparator` which
  24533. * is invoked to compare elements of `arrays`. Result values are chosen from
  24534. * the first array in which the value occurs. The comparator is invoked
  24535. * with two arguments: (arrVal, othVal).
  24536. *
  24537. * @static
  24538. * @memberOf _
  24539. * @since 4.0.0
  24540. * @category Array
  24541. * @param {...Array} [arrays] The arrays to inspect.
  24542. * @param {Function} [comparator] The comparator invoked per element.
  24543. * @returns {Array} Returns the new array of combined values.
  24544. * @example
  24545. *
  24546. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24547. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24548. *
  24549. * _.unionWith(objects, others, _.isEqual);
  24550. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24551. */
  24552. var unionWith = baseRest(function(arrays) {
  24553. var comparator = last(arrays);
  24554. comparator = typeof comparator == 'function' ? comparator : undefined;
  24555. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24556. });
  24557. /**
  24558. * Creates a duplicate-free version of an array, using
  24559. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24560. * for equality comparisons, in which only the first occurrence of each element
  24561. * is kept. The order of result values is determined by the order they occur
  24562. * in the array.
  24563. *
  24564. * @static
  24565. * @memberOf _
  24566. * @since 0.1.0
  24567. * @category Array
  24568. * @param {Array} array The array to inspect.
  24569. * @returns {Array} Returns the new duplicate free array.
  24570. * @example
  24571. *
  24572. * _.uniq([2, 1, 2]);
  24573. * // => [2, 1]
  24574. */
  24575. function uniq(array) {
  24576. return (array && array.length) ? baseUniq(array) : [];
  24577. }
  24578. /**
  24579. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24580. * invoked for each element in `array` to generate the criterion by which
  24581. * uniqueness is computed. The order of result values is determined by the
  24582. * order they occur in the array. The iteratee is invoked with one argument:
  24583. * (value).
  24584. *
  24585. * @static
  24586. * @memberOf _
  24587. * @since 4.0.0
  24588. * @category Array
  24589. * @param {Array} array The array to inspect.
  24590. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24591. * @returns {Array} Returns the new duplicate free array.
  24592. * @example
  24593. *
  24594. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24595. * // => [2.1, 1.2]
  24596. *
  24597. * // The `_.property` iteratee shorthand.
  24598. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24599. * // => [{ 'x': 1 }, { 'x': 2 }]
  24600. */
  24601. function uniqBy(array, iteratee) {
  24602. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24603. }
  24604. /**
  24605. * This method is like `_.uniq` except that it accepts `comparator` which
  24606. * is invoked to compare elements of `array`. The order of result values is
  24607. * determined by the order they occur in the array.The comparator is invoked
  24608. * with two arguments: (arrVal, othVal).
  24609. *
  24610. * @static
  24611. * @memberOf _
  24612. * @since 4.0.0
  24613. * @category Array
  24614. * @param {Array} array The array to inspect.
  24615. * @param {Function} [comparator] The comparator invoked per element.
  24616. * @returns {Array} Returns the new duplicate free array.
  24617. * @example
  24618. *
  24619. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24620. *
  24621. * _.uniqWith(objects, _.isEqual);
  24622. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24623. */
  24624. function uniqWith(array, comparator) {
  24625. comparator = typeof comparator == 'function' ? comparator : undefined;
  24626. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24627. }
  24628. /**
  24629. * This method is like `_.zip` except that it accepts an array of grouped
  24630. * elements and creates an array regrouping the elements to their pre-zip
  24631. * configuration.
  24632. *
  24633. * @static
  24634. * @memberOf _
  24635. * @since 1.2.0
  24636. * @category Array
  24637. * @param {Array} array The array of grouped elements to process.
  24638. * @returns {Array} Returns the new array of regrouped elements.
  24639. * @example
  24640. *
  24641. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24642. * // => [['a', 1, true], ['b', 2, false]]
  24643. *
  24644. * _.unzip(zipped);
  24645. * // => [['a', 'b'], [1, 2], [true, false]]
  24646. */
  24647. function unzip(array) {
  24648. if (!(array && array.length)) {
  24649. return [];
  24650. }
  24651. var length = 0;
  24652. array = arrayFilter(array, function(group) {
  24653. if (isArrayLikeObject(group)) {
  24654. length = nativeMax(group.length, length);
  24655. return true;
  24656. }
  24657. });
  24658. return baseTimes(length, function(index) {
  24659. return arrayMap(array, baseProperty(index));
  24660. });
  24661. }
  24662. /**
  24663. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24664. * how regrouped values should be combined. The iteratee is invoked with the
  24665. * elements of each group: (...group).
  24666. *
  24667. * @static
  24668. * @memberOf _
  24669. * @since 3.8.0
  24670. * @category Array
  24671. * @param {Array} array The array of grouped elements to process.
  24672. * @param {Function} [iteratee=_.identity] The function to combine
  24673. * regrouped values.
  24674. * @returns {Array} Returns the new array of regrouped elements.
  24675. * @example
  24676. *
  24677. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24678. * // => [[1, 10, 100], [2, 20, 200]]
  24679. *
  24680. * _.unzipWith(zipped, _.add);
  24681. * // => [3, 30, 300]
  24682. */
  24683. function unzipWith(array, iteratee) {
  24684. if (!(array && array.length)) {
  24685. return [];
  24686. }
  24687. var result = unzip(array);
  24688. if (iteratee == null) {
  24689. return result;
  24690. }
  24691. return arrayMap(result, function(group) {
  24692. return apply(iteratee, undefined, group);
  24693. });
  24694. }
  24695. /**
  24696. * Creates an array excluding all given values using
  24697. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24698. * for equality comparisons.
  24699. *
  24700. * **Note:** Unlike `_.pull`, this method returns a new array.
  24701. *
  24702. * @static
  24703. * @memberOf _
  24704. * @since 0.1.0
  24705. * @category Array
  24706. * @param {Array} array The array to inspect.
  24707. * @param {...*} [values] The values to exclude.
  24708. * @returns {Array} Returns the new array of filtered values.
  24709. * @see _.difference, _.xor
  24710. * @example
  24711. *
  24712. * _.without([2, 1, 2, 3], 1, 2);
  24713. * // => [3]
  24714. */
  24715. var without = baseRest(function(array, values) {
  24716. return isArrayLikeObject(array)
  24717. ? baseDifference(array, values)
  24718. : [];
  24719. });
  24720. /**
  24721. * Creates an array of unique values that is the
  24722. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24723. * of the given arrays. The order of result values is determined by the order
  24724. * they occur in the arrays.
  24725. *
  24726. * @static
  24727. * @memberOf _
  24728. * @since 2.4.0
  24729. * @category Array
  24730. * @param {...Array} [arrays] The arrays to inspect.
  24731. * @returns {Array} Returns the new array of filtered values.
  24732. * @see _.difference, _.without
  24733. * @example
  24734. *
  24735. * _.xor([2, 1], [2, 3]);
  24736. * // => [1, 3]
  24737. */
  24738. var xor = baseRest(function(arrays) {
  24739. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24740. });
  24741. /**
  24742. * This method is like `_.xor` except that it accepts `iteratee` which is
  24743. * invoked for each element of each `arrays` to generate the criterion by
  24744. * which by which they're compared. The order of result values is determined
  24745. * by the order they occur in the arrays. The iteratee is invoked with one
  24746. * argument: (value).
  24747. *
  24748. * @static
  24749. * @memberOf _
  24750. * @since 4.0.0
  24751. * @category Array
  24752. * @param {...Array} [arrays] The arrays to inspect.
  24753. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24754. * @returns {Array} Returns the new array of filtered values.
  24755. * @example
  24756. *
  24757. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24758. * // => [1.2, 3.4]
  24759. *
  24760. * // The `_.property` iteratee shorthand.
  24761. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24762. * // => [{ 'x': 2 }]
  24763. */
  24764. var xorBy = baseRest(function(arrays) {
  24765. var iteratee = last(arrays);
  24766. if (isArrayLikeObject(iteratee)) {
  24767. iteratee = undefined;
  24768. }
  24769. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24770. });
  24771. /**
  24772. * This method is like `_.xor` except that it accepts `comparator` which is
  24773. * invoked to compare elements of `arrays`. The order of result values is
  24774. * determined by the order they occur in the arrays. The comparator is invoked
  24775. * with two arguments: (arrVal, othVal).
  24776. *
  24777. * @static
  24778. * @memberOf _
  24779. * @since 4.0.0
  24780. * @category Array
  24781. * @param {...Array} [arrays] The arrays to inspect.
  24782. * @param {Function} [comparator] The comparator invoked per element.
  24783. * @returns {Array} Returns the new array of filtered values.
  24784. * @example
  24785. *
  24786. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24787. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24788. *
  24789. * _.xorWith(objects, others, _.isEqual);
  24790. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24791. */
  24792. var xorWith = baseRest(function(arrays) {
  24793. var comparator = last(arrays);
  24794. comparator = typeof comparator == 'function' ? comparator : undefined;
  24795. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24796. });
  24797. /**
  24798. * Creates an array of grouped elements, the first of which contains the
  24799. * first elements of the given arrays, the second of which contains the
  24800. * second elements of the given arrays, and so on.
  24801. *
  24802. * @static
  24803. * @memberOf _
  24804. * @since 0.1.0
  24805. * @category Array
  24806. * @param {...Array} [arrays] The arrays to process.
  24807. * @returns {Array} Returns the new array of grouped elements.
  24808. * @example
  24809. *
  24810. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24811. * // => [['a', 1, true], ['b', 2, false]]
  24812. */
  24813. var zip = baseRest(unzip);
  24814. /**
  24815. * This method is like `_.fromPairs` except that it accepts two arrays,
  24816. * one of property identifiers and one of corresponding values.
  24817. *
  24818. * @static
  24819. * @memberOf _
  24820. * @since 0.4.0
  24821. * @category Array
  24822. * @param {Array} [props=[]] The property identifiers.
  24823. * @param {Array} [values=[]] The property values.
  24824. * @returns {Object} Returns the new object.
  24825. * @example
  24826. *
  24827. * _.zipObject(['a', 'b'], [1, 2]);
  24828. * // => { 'a': 1, 'b': 2 }
  24829. */
  24830. function zipObject(props, values) {
  24831. return baseZipObject(props || [], values || [], assignValue);
  24832. }
  24833. /**
  24834. * This method is like `_.zipObject` except that it supports property paths.
  24835. *
  24836. * @static
  24837. * @memberOf _
  24838. * @since 4.1.0
  24839. * @category Array
  24840. * @param {Array} [props=[]] The property identifiers.
  24841. * @param {Array} [values=[]] The property values.
  24842. * @returns {Object} Returns the new object.
  24843. * @example
  24844. *
  24845. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24846. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24847. */
  24848. function zipObjectDeep(props, values) {
  24849. return baseZipObject(props || [], values || [], baseSet);
  24850. }
  24851. /**
  24852. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24853. * how grouped values should be combined. The iteratee is invoked with the
  24854. * elements of each group: (...group).
  24855. *
  24856. * @static
  24857. * @memberOf _
  24858. * @since 3.8.0
  24859. * @category Array
  24860. * @param {...Array} [arrays] The arrays to process.
  24861. * @param {Function} [iteratee=_.identity] The function to combine
  24862. * grouped values.
  24863. * @returns {Array} Returns the new array of grouped elements.
  24864. * @example
  24865. *
  24866. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24867. * return a + b + c;
  24868. * });
  24869. * // => [111, 222]
  24870. */
  24871. var zipWith = baseRest(function(arrays) {
  24872. var length = arrays.length,
  24873. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24874. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24875. return unzipWith(arrays, iteratee);
  24876. });
  24877. /*------------------------------------------------------------------------*/
  24878. /**
  24879. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24880. * chain sequences enabled. The result of such sequences must be unwrapped
  24881. * with `_#value`.
  24882. *
  24883. * @static
  24884. * @memberOf _
  24885. * @since 1.3.0
  24886. * @category Seq
  24887. * @param {*} value The value to wrap.
  24888. * @returns {Object} Returns the new `lodash` wrapper instance.
  24889. * @example
  24890. *
  24891. * var users = [
  24892. * { 'user': 'barney', 'age': 36 },
  24893. * { 'user': 'fred', 'age': 40 },
  24894. * { 'user': 'pebbles', 'age': 1 }
  24895. * ];
  24896. *
  24897. * var youngest = _
  24898. * .chain(users)
  24899. * .sortBy('age')
  24900. * .map(function(o) {
  24901. * return o.user + ' is ' + o.age;
  24902. * })
  24903. * .head()
  24904. * .value();
  24905. * // => 'pebbles is 1'
  24906. */
  24907. function chain(value) {
  24908. var result = lodash(value);
  24909. result.__chain__ = true;
  24910. return result;
  24911. }
  24912. /**
  24913. * This method invokes `interceptor` and returns `value`. The interceptor
  24914. * is invoked with one argument; (value). The purpose of this method is to
  24915. * "tap into" a method chain sequence in order to modify intermediate results.
  24916. *
  24917. * @static
  24918. * @memberOf _
  24919. * @since 0.1.0
  24920. * @category Seq
  24921. * @param {*} value The value to provide to `interceptor`.
  24922. * @param {Function} interceptor The function to invoke.
  24923. * @returns {*} Returns `value`.
  24924. * @example
  24925. *
  24926. * _([1, 2, 3])
  24927. * .tap(function(array) {
  24928. * // Mutate input array.
  24929. * array.pop();
  24930. * })
  24931. * .reverse()
  24932. * .value();
  24933. * // => [2, 1]
  24934. */
  24935. function tap(value, interceptor) {
  24936. interceptor(value);
  24937. return value;
  24938. }
  24939. /**
  24940. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24941. * The purpose of this method is to "pass thru" values replacing intermediate
  24942. * results in a method chain sequence.
  24943. *
  24944. * @static
  24945. * @memberOf _
  24946. * @since 3.0.0
  24947. * @category Seq
  24948. * @param {*} value The value to provide to `interceptor`.
  24949. * @param {Function} interceptor The function to invoke.
  24950. * @returns {*} Returns the result of `interceptor`.
  24951. * @example
  24952. *
  24953. * _(' abc ')
  24954. * .chain()
  24955. * .trim()
  24956. * .thru(function(value) {
  24957. * return [value];
  24958. * })
  24959. * .value();
  24960. * // => ['abc']
  24961. */
  24962. function thru(value, interceptor) {
  24963. return interceptor(value);
  24964. }
  24965. /**
  24966. * This method is the wrapper version of `_.at`.
  24967. *
  24968. * @name at
  24969. * @memberOf _
  24970. * @since 1.0.0
  24971. * @category Seq
  24972. * @param {...(string|string[])} [paths] The property paths to pick.
  24973. * @returns {Object} Returns the new `lodash` wrapper instance.
  24974. * @example
  24975. *
  24976. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  24977. *
  24978. * _(object).at(['a[0].b.c', 'a[1]']).value();
  24979. * // => [3, 4]
  24980. */
  24981. var wrapperAt = flatRest(function(paths) {
  24982. var length = paths.length,
  24983. start = length ? paths[0] : 0,
  24984. value = this.__wrapped__,
  24985. interceptor = function(object) { return baseAt(object, paths); };
  24986. if (length > 1 || this.__actions__.length ||
  24987. !(value instanceof LazyWrapper) || !isIndex(start)) {
  24988. return this.thru(interceptor);
  24989. }
  24990. value = value.slice(start, +start + (length ? 1 : 0));
  24991. value.__actions__.push({
  24992. 'func': thru,
  24993. 'args': [interceptor],
  24994. 'thisArg': undefined
  24995. });
  24996. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  24997. if (length && !array.length) {
  24998. array.push(undefined);
  24999. }
  25000. return array;
  25001. });
  25002. });
  25003. /**
  25004. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25005. *
  25006. * @name chain
  25007. * @memberOf _
  25008. * @since 0.1.0
  25009. * @category Seq
  25010. * @returns {Object} Returns the new `lodash` wrapper instance.
  25011. * @example
  25012. *
  25013. * var users = [
  25014. * { 'user': 'barney', 'age': 36 },
  25015. * { 'user': 'fred', 'age': 40 }
  25016. * ];
  25017. *
  25018. * // A sequence without explicit chaining.
  25019. * _(users).head();
  25020. * // => { 'user': 'barney', 'age': 36 }
  25021. *
  25022. * // A sequence with explicit chaining.
  25023. * _(users)
  25024. * .chain()
  25025. * .head()
  25026. * .pick('user')
  25027. * .value();
  25028. * // => { 'user': 'barney' }
  25029. */
  25030. function wrapperChain() {
  25031. return chain(this);
  25032. }
  25033. /**
  25034. * Executes the chain sequence and returns the wrapped result.
  25035. *
  25036. * @name commit
  25037. * @memberOf _
  25038. * @since 3.2.0
  25039. * @category Seq
  25040. * @returns {Object} Returns the new `lodash` wrapper instance.
  25041. * @example
  25042. *
  25043. * var array = [1, 2];
  25044. * var wrapped = _(array).push(3);
  25045. *
  25046. * console.log(array);
  25047. * // => [1, 2]
  25048. *
  25049. * wrapped = wrapped.commit();
  25050. * console.log(array);
  25051. * // => [1, 2, 3]
  25052. *
  25053. * wrapped.last();
  25054. * // => 3
  25055. *
  25056. * console.log(array);
  25057. * // => [1, 2, 3]
  25058. */
  25059. function wrapperCommit() {
  25060. return new LodashWrapper(this.value(), this.__chain__);
  25061. }
  25062. /**
  25063. * Gets the next value on a wrapped object following the
  25064. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25065. *
  25066. * @name next
  25067. * @memberOf _
  25068. * @since 4.0.0
  25069. * @category Seq
  25070. * @returns {Object} Returns the next iterator value.
  25071. * @example
  25072. *
  25073. * var wrapped = _([1, 2]);
  25074. *
  25075. * wrapped.next();
  25076. * // => { 'done': false, 'value': 1 }
  25077. *
  25078. * wrapped.next();
  25079. * // => { 'done': false, 'value': 2 }
  25080. *
  25081. * wrapped.next();
  25082. * // => { 'done': true, 'value': undefined }
  25083. */
  25084. function wrapperNext() {
  25085. if (this.__values__ === undefined) {
  25086. this.__values__ = toArray(this.value());
  25087. }
  25088. var done = this.__index__ >= this.__values__.length,
  25089. value = done ? undefined : this.__values__[this.__index__++];
  25090. return { 'done': done, 'value': value };
  25091. }
  25092. /**
  25093. * Enables the wrapper to be iterable.
  25094. *
  25095. * @name Symbol.iterator
  25096. * @memberOf _
  25097. * @since 4.0.0
  25098. * @category Seq
  25099. * @returns {Object} Returns the wrapper object.
  25100. * @example
  25101. *
  25102. * var wrapped = _([1, 2]);
  25103. *
  25104. * wrapped[Symbol.iterator]() === wrapped;
  25105. * // => true
  25106. *
  25107. * Array.from(wrapped);
  25108. * // => [1, 2]
  25109. */
  25110. function wrapperToIterator() {
  25111. return this;
  25112. }
  25113. /**
  25114. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25115. *
  25116. * @name plant
  25117. * @memberOf _
  25118. * @since 3.2.0
  25119. * @category Seq
  25120. * @param {*} value The value to plant.
  25121. * @returns {Object} Returns the new `lodash` wrapper instance.
  25122. * @example
  25123. *
  25124. * function square(n) {
  25125. * return n * n;
  25126. * }
  25127. *
  25128. * var wrapped = _([1, 2]).map(square);
  25129. * var other = wrapped.plant([3, 4]);
  25130. *
  25131. * other.value();
  25132. * // => [9, 16]
  25133. *
  25134. * wrapped.value();
  25135. * // => [1, 4]
  25136. */
  25137. function wrapperPlant(value) {
  25138. var result,
  25139. parent = this;
  25140. while (parent instanceof baseLodash) {
  25141. var clone = wrapperClone(parent);
  25142. clone.__index__ = 0;
  25143. clone.__values__ = undefined;
  25144. if (result) {
  25145. previous.__wrapped__ = clone;
  25146. } else {
  25147. result = clone;
  25148. }
  25149. var previous = clone;
  25150. parent = parent.__wrapped__;
  25151. }
  25152. previous.__wrapped__ = value;
  25153. return result;
  25154. }
  25155. /**
  25156. * This method is the wrapper version of `_.reverse`.
  25157. *
  25158. * **Note:** This method mutates the wrapped array.
  25159. *
  25160. * @name reverse
  25161. * @memberOf _
  25162. * @since 0.1.0
  25163. * @category Seq
  25164. * @returns {Object} Returns the new `lodash` wrapper instance.
  25165. * @example
  25166. *
  25167. * var array = [1, 2, 3];
  25168. *
  25169. * _(array).reverse().value()
  25170. * // => [3, 2, 1]
  25171. *
  25172. * console.log(array);
  25173. * // => [3, 2, 1]
  25174. */
  25175. function wrapperReverse() {
  25176. var value = this.__wrapped__;
  25177. if (value instanceof LazyWrapper) {
  25178. var wrapped = value;
  25179. if (this.__actions__.length) {
  25180. wrapped = new LazyWrapper(this);
  25181. }
  25182. wrapped = wrapped.reverse();
  25183. wrapped.__actions__.push({
  25184. 'func': thru,
  25185. 'args': [reverse],
  25186. 'thisArg': undefined
  25187. });
  25188. return new LodashWrapper(wrapped, this.__chain__);
  25189. }
  25190. return this.thru(reverse);
  25191. }
  25192. /**
  25193. * Executes the chain sequence to resolve the unwrapped value.
  25194. *
  25195. * @name value
  25196. * @memberOf _
  25197. * @since 0.1.0
  25198. * @alias toJSON, valueOf
  25199. * @category Seq
  25200. * @returns {*} Returns the resolved unwrapped value.
  25201. * @example
  25202. *
  25203. * _([1, 2, 3]).value();
  25204. * // => [1, 2, 3]
  25205. */
  25206. function wrapperValue() {
  25207. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25208. }
  25209. /*------------------------------------------------------------------------*/
  25210. /**
  25211. * Creates an object composed of keys generated from the results of running
  25212. * each element of `collection` thru `iteratee`. The corresponding value of
  25213. * each key is the number of times the key was returned by `iteratee`. The
  25214. * iteratee is invoked with one argument: (value).
  25215. *
  25216. * @static
  25217. * @memberOf _
  25218. * @since 0.5.0
  25219. * @category Collection
  25220. * @param {Array|Object} collection The collection to iterate over.
  25221. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25222. * @returns {Object} Returns the composed aggregate object.
  25223. * @example
  25224. *
  25225. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25226. * // => { '4': 1, '6': 2 }
  25227. *
  25228. * // The `_.property` iteratee shorthand.
  25229. * _.countBy(['one', 'two', 'three'], 'length');
  25230. * // => { '3': 2, '5': 1 }
  25231. */
  25232. var countBy = createAggregator(function(result, value, key) {
  25233. if (hasOwnProperty.call(result, key)) {
  25234. ++result[key];
  25235. } else {
  25236. baseAssignValue(result, key, 1);
  25237. }
  25238. });
  25239. /**
  25240. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25241. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25242. * invoked with three arguments: (value, index|key, collection).
  25243. *
  25244. * **Note:** This method returns `true` for
  25245. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25246. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25247. * elements of empty collections.
  25248. *
  25249. * @static
  25250. * @memberOf _
  25251. * @since 0.1.0
  25252. * @category Collection
  25253. * @param {Array|Object} collection The collection to iterate over.
  25254. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25255. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25256. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25257. * else `false`.
  25258. * @example
  25259. *
  25260. * _.every([true, 1, null, 'yes'], Boolean);
  25261. * // => false
  25262. *
  25263. * var users = [
  25264. * { 'user': 'barney', 'age': 36, 'active': false },
  25265. * { 'user': 'fred', 'age': 40, 'active': false }
  25266. * ];
  25267. *
  25268. * // The `_.matches` iteratee shorthand.
  25269. * _.every(users, { 'user': 'barney', 'active': false });
  25270. * // => false
  25271. *
  25272. * // The `_.matchesProperty` iteratee shorthand.
  25273. * _.every(users, ['active', false]);
  25274. * // => true
  25275. *
  25276. * // The `_.property` iteratee shorthand.
  25277. * _.every(users, 'active');
  25278. * // => false
  25279. */
  25280. function every(collection, predicate, guard) {
  25281. var func = isArray(collection) ? arrayEvery : baseEvery;
  25282. if (guard && isIterateeCall(collection, predicate, guard)) {
  25283. predicate = undefined;
  25284. }
  25285. return func(collection, getIteratee(predicate, 3));
  25286. }
  25287. /**
  25288. * Iterates over elements of `collection`, returning an array of all elements
  25289. * `predicate` returns truthy for. The predicate is invoked with three
  25290. * arguments: (value, index|key, collection).
  25291. *
  25292. * **Note:** Unlike `_.remove`, this method returns a new array.
  25293. *
  25294. * @static
  25295. * @memberOf _
  25296. * @since 0.1.0
  25297. * @category Collection
  25298. * @param {Array|Object} collection The collection to iterate over.
  25299. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25300. * @returns {Array} Returns the new filtered array.
  25301. * @see _.reject
  25302. * @example
  25303. *
  25304. * var users = [
  25305. * { 'user': 'barney', 'age': 36, 'active': true },
  25306. * { 'user': 'fred', 'age': 40, 'active': false }
  25307. * ];
  25308. *
  25309. * _.filter(users, function(o) { return !o.active; });
  25310. * // => objects for ['fred']
  25311. *
  25312. * // The `_.matches` iteratee shorthand.
  25313. * _.filter(users, { 'age': 36, 'active': true });
  25314. * // => objects for ['barney']
  25315. *
  25316. * // The `_.matchesProperty` iteratee shorthand.
  25317. * _.filter(users, ['active', false]);
  25318. * // => objects for ['fred']
  25319. *
  25320. * // The `_.property` iteratee shorthand.
  25321. * _.filter(users, 'active');
  25322. * // => objects for ['barney']
  25323. */
  25324. function filter(collection, predicate) {
  25325. var func = isArray(collection) ? arrayFilter : baseFilter;
  25326. return func(collection, getIteratee(predicate, 3));
  25327. }
  25328. /**
  25329. * Iterates over elements of `collection`, returning the first element
  25330. * `predicate` returns truthy for. The predicate is invoked with three
  25331. * arguments: (value, index|key, collection).
  25332. *
  25333. * @static
  25334. * @memberOf _
  25335. * @since 0.1.0
  25336. * @category Collection
  25337. * @param {Array|Object} collection The collection to inspect.
  25338. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25339. * @param {number} [fromIndex=0] The index to search from.
  25340. * @returns {*} Returns the matched element, else `undefined`.
  25341. * @example
  25342. *
  25343. * var users = [
  25344. * { 'user': 'barney', 'age': 36, 'active': true },
  25345. * { 'user': 'fred', 'age': 40, 'active': false },
  25346. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25347. * ];
  25348. *
  25349. * _.find(users, function(o) { return o.age < 40; });
  25350. * // => object for 'barney'
  25351. *
  25352. * // The `_.matches` iteratee shorthand.
  25353. * _.find(users, { 'age': 1, 'active': true });
  25354. * // => object for 'pebbles'
  25355. *
  25356. * // The `_.matchesProperty` iteratee shorthand.
  25357. * _.find(users, ['active', false]);
  25358. * // => object for 'fred'
  25359. *
  25360. * // The `_.property` iteratee shorthand.
  25361. * _.find(users, 'active');
  25362. * // => object for 'barney'
  25363. */
  25364. var find = createFind(findIndex);
  25365. /**
  25366. * This method is like `_.find` except that it iterates over elements of
  25367. * `collection` from right to left.
  25368. *
  25369. * @static
  25370. * @memberOf _
  25371. * @since 2.0.0
  25372. * @category Collection
  25373. * @param {Array|Object} collection The collection to inspect.
  25374. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25375. * @param {number} [fromIndex=collection.length-1] The index to search from.
  25376. * @returns {*} Returns the matched element, else `undefined`.
  25377. * @example
  25378. *
  25379. * _.findLast([1, 2, 3, 4], function(n) {
  25380. * return n % 2 == 1;
  25381. * });
  25382. * // => 3
  25383. */
  25384. var findLast = createFind(findLastIndex);
  25385. /**
  25386. * Creates a flattened array of values by running each element in `collection`
  25387. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25388. * with three arguments: (value, index|key, collection).
  25389. *
  25390. * @static
  25391. * @memberOf _
  25392. * @since 4.0.0
  25393. * @category Collection
  25394. * @param {Array|Object} collection The collection to iterate over.
  25395. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25396. * @returns {Array} Returns the new flattened array.
  25397. * @example
  25398. *
  25399. * function duplicate(n) {
  25400. * return [n, n];
  25401. * }
  25402. *
  25403. * _.flatMap([1, 2], duplicate);
  25404. * // => [1, 1, 2, 2]
  25405. */
  25406. function flatMap(collection, iteratee) {
  25407. return baseFlatten(map(collection, iteratee), 1);
  25408. }
  25409. /**
  25410. * This method is like `_.flatMap` except that it recursively flattens the
  25411. * mapped results.
  25412. *
  25413. * @static
  25414. * @memberOf _
  25415. * @since 4.7.0
  25416. * @category Collection
  25417. * @param {Array|Object} collection The collection to iterate over.
  25418. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25419. * @returns {Array} Returns the new flattened array.
  25420. * @example
  25421. *
  25422. * function duplicate(n) {
  25423. * return [[[n, n]]];
  25424. * }
  25425. *
  25426. * _.flatMapDeep([1, 2], duplicate);
  25427. * // => [1, 1, 2, 2]
  25428. */
  25429. function flatMapDeep(collection, iteratee) {
  25430. return baseFlatten(map(collection, iteratee), INFINITY);
  25431. }
  25432. /**
  25433. * This method is like `_.flatMap` except that it recursively flattens the
  25434. * mapped results up to `depth` times.
  25435. *
  25436. * @static
  25437. * @memberOf _
  25438. * @since 4.7.0
  25439. * @category Collection
  25440. * @param {Array|Object} collection The collection to iterate over.
  25441. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25442. * @param {number} [depth=1] The maximum recursion depth.
  25443. * @returns {Array} Returns the new flattened array.
  25444. * @example
  25445. *
  25446. * function duplicate(n) {
  25447. * return [[[n, n]]];
  25448. * }
  25449. *
  25450. * _.flatMapDepth([1, 2], duplicate, 2);
  25451. * // => [[1, 1], [2, 2]]
  25452. */
  25453. function flatMapDepth(collection, iteratee, depth) {
  25454. depth = depth === undefined ? 1 : toInteger(depth);
  25455. return baseFlatten(map(collection, iteratee), depth);
  25456. }
  25457. /**
  25458. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25459. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25460. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25461. *
  25462. * **Note:** As with other "Collections" methods, objects with a "length"
  25463. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25464. * or `_.forOwn` for object iteration.
  25465. *
  25466. * @static
  25467. * @memberOf _
  25468. * @since 0.1.0
  25469. * @alias each
  25470. * @category Collection
  25471. * @param {Array|Object} collection The collection to iterate over.
  25472. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25473. * @returns {Array|Object} Returns `collection`.
  25474. * @see _.forEachRight
  25475. * @example
  25476. *
  25477. * _.forEach([1, 2], function(value) {
  25478. * console.log(value);
  25479. * });
  25480. * // => Logs `1` then `2`.
  25481. *
  25482. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25483. * console.log(key);
  25484. * });
  25485. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25486. */
  25487. function forEach(collection, iteratee) {
  25488. var func = isArray(collection) ? arrayEach : baseEach;
  25489. return func(collection, getIteratee(iteratee, 3));
  25490. }
  25491. /**
  25492. * This method is like `_.forEach` except that it iterates over elements of
  25493. * `collection` from right to left.
  25494. *
  25495. * @static
  25496. * @memberOf _
  25497. * @since 2.0.0
  25498. * @alias eachRight
  25499. * @category Collection
  25500. * @param {Array|Object} collection The collection to iterate over.
  25501. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25502. * @returns {Array|Object} Returns `collection`.
  25503. * @see _.forEach
  25504. * @example
  25505. *
  25506. * _.forEachRight([1, 2], function(value) {
  25507. * console.log(value);
  25508. * });
  25509. * // => Logs `2` then `1`.
  25510. */
  25511. function forEachRight(collection, iteratee) {
  25512. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25513. return func(collection, getIteratee(iteratee, 3));
  25514. }
  25515. /**
  25516. * Creates an object composed of keys generated from the results of running
  25517. * each element of `collection` thru `iteratee`. The order of grouped values
  25518. * is determined by the order they occur in `collection`. The corresponding
  25519. * value of each key is an array of elements responsible for generating the
  25520. * key. The iteratee is invoked with one argument: (value).
  25521. *
  25522. * @static
  25523. * @memberOf _
  25524. * @since 0.1.0
  25525. * @category Collection
  25526. * @param {Array|Object} collection The collection to iterate over.
  25527. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25528. * @returns {Object} Returns the composed aggregate object.
  25529. * @example
  25530. *
  25531. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25532. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25533. *
  25534. * // The `_.property` iteratee shorthand.
  25535. * _.groupBy(['one', 'two', 'three'], 'length');
  25536. * // => { '3': ['one', 'two'], '5': ['three'] }
  25537. */
  25538. var groupBy = createAggregator(function(result, value, key) {
  25539. if (hasOwnProperty.call(result, key)) {
  25540. result[key].push(value);
  25541. } else {
  25542. baseAssignValue(result, key, [value]);
  25543. }
  25544. });
  25545. /**
  25546. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25547. * checked for a substring of `value`, otherwise
  25548. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25549. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25550. * the offset from the end of `collection`.
  25551. *
  25552. * @static
  25553. * @memberOf _
  25554. * @since 0.1.0
  25555. * @category Collection
  25556. * @param {Array|Object|string} collection The collection to inspect.
  25557. * @param {*} value The value to search for.
  25558. * @param {number} [fromIndex=0] The index to search from.
  25559. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25560. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25561. * @example
  25562. *
  25563. * _.includes([1, 2, 3], 1);
  25564. * // => true
  25565. *
  25566. * _.includes([1, 2, 3], 1, 2);
  25567. * // => false
  25568. *
  25569. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25570. * // => true
  25571. *
  25572. * _.includes('abcd', 'bc');
  25573. * // => true
  25574. */
  25575. function includes(collection, value, fromIndex, guard) {
  25576. collection = isArrayLike(collection) ? collection : values(collection);
  25577. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25578. var length = collection.length;
  25579. if (fromIndex < 0) {
  25580. fromIndex = nativeMax(length + fromIndex, 0);
  25581. }
  25582. return isString(collection)
  25583. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25584. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25585. }
  25586. /**
  25587. * Invokes the method at `path` of each element in `collection`, returning
  25588. * an array of the results of each invoked method. Any additional arguments
  25589. * are provided to each invoked method. If `path` is a function, it's invoked
  25590. * for, and `this` bound to, each element in `collection`.
  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 {Array|Function|string} path The path of the method to invoke or
  25598. * the function invoked per iteration.
  25599. * @param {...*} [args] The arguments to invoke each method with.
  25600. * @returns {Array} Returns the array of results.
  25601. * @example
  25602. *
  25603. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25604. * // => [[1, 5, 7], [1, 2, 3]]
  25605. *
  25606. * _.invokeMap([123, 456], String.prototype.split, '');
  25607. * // => [['1', '2', '3'], ['4', '5', '6']]
  25608. */
  25609. var invokeMap = baseRest(function(collection, path, args) {
  25610. var index = -1,
  25611. isFunc = typeof path == 'function',
  25612. result = isArrayLike(collection) ? Array(collection.length) : [];
  25613. baseEach(collection, function(value) {
  25614. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25615. });
  25616. return result;
  25617. });
  25618. /**
  25619. * Creates an object composed of keys generated from the results of running
  25620. * each element of `collection` thru `iteratee`. The corresponding value of
  25621. * each key is the last element responsible for generating the key. The
  25622. * iteratee is invoked with one argument: (value).
  25623. *
  25624. * @static
  25625. * @memberOf _
  25626. * @since 4.0.0
  25627. * @category Collection
  25628. * @param {Array|Object} collection The collection to iterate over.
  25629. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25630. * @returns {Object} Returns the composed aggregate object.
  25631. * @example
  25632. *
  25633. * var array = [
  25634. * { 'dir': 'left', 'code': 97 },
  25635. * { 'dir': 'right', 'code': 100 }
  25636. * ];
  25637. *
  25638. * _.keyBy(array, function(o) {
  25639. * return String.fromCharCode(o.code);
  25640. * });
  25641. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25642. *
  25643. * _.keyBy(array, 'dir');
  25644. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25645. */
  25646. var keyBy = createAggregator(function(result, value, key) {
  25647. baseAssignValue(result, key, value);
  25648. });
  25649. /**
  25650. * Creates an array of values by running each element in `collection` thru
  25651. * `iteratee`. The iteratee is invoked with three arguments:
  25652. * (value, index|key, collection).
  25653. *
  25654. * Many lodash methods are guarded to work as iteratees for methods like
  25655. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25656. *
  25657. * The guarded methods are:
  25658. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25659. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25660. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25661. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25662. *
  25663. * @static
  25664. * @memberOf _
  25665. * @since 0.1.0
  25666. * @category Collection
  25667. * @param {Array|Object} collection The collection to iterate over.
  25668. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25669. * @returns {Array} Returns the new mapped array.
  25670. * @example
  25671. *
  25672. * function square(n) {
  25673. * return n * n;
  25674. * }
  25675. *
  25676. * _.map([4, 8], square);
  25677. * // => [16, 64]
  25678. *
  25679. * _.map({ 'a': 4, 'b': 8 }, square);
  25680. * // => [16, 64] (iteration order is not guaranteed)
  25681. *
  25682. * var users = [
  25683. * { 'user': 'barney' },
  25684. * { 'user': 'fred' }
  25685. * ];
  25686. *
  25687. * // The `_.property` iteratee shorthand.
  25688. * _.map(users, 'user');
  25689. * // => ['barney', 'fred']
  25690. */
  25691. function map(collection, iteratee) {
  25692. var func = isArray(collection) ? arrayMap : baseMap;
  25693. return func(collection, getIteratee(iteratee, 3));
  25694. }
  25695. /**
  25696. * This method is like `_.sortBy` except that it allows specifying the sort
  25697. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25698. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25699. * descending or "asc" for ascending sort order of corresponding values.
  25700. *
  25701. * @static
  25702. * @memberOf _
  25703. * @since 4.0.0
  25704. * @category Collection
  25705. * @param {Array|Object} collection The collection to iterate over.
  25706. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25707. * The iteratees to sort by.
  25708. * @param {string[]} [orders] The sort orders of `iteratees`.
  25709. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25710. * @returns {Array} Returns the new sorted array.
  25711. * @example
  25712. *
  25713. * var users = [
  25714. * { 'user': 'fred', 'age': 48 },
  25715. * { 'user': 'barney', 'age': 34 },
  25716. * { 'user': 'fred', 'age': 40 },
  25717. * { 'user': 'barney', 'age': 36 }
  25718. * ];
  25719. *
  25720. * // Sort by `user` in ascending order and by `age` in descending order.
  25721. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25722. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25723. */
  25724. function orderBy(collection, iteratees, orders, guard) {
  25725. if (collection == null) {
  25726. return [];
  25727. }
  25728. if (!isArray(iteratees)) {
  25729. iteratees = iteratees == null ? [] : [iteratees];
  25730. }
  25731. orders = guard ? undefined : orders;
  25732. if (!isArray(orders)) {
  25733. orders = orders == null ? [] : [orders];
  25734. }
  25735. return baseOrderBy(collection, iteratees, orders);
  25736. }
  25737. /**
  25738. * Creates an array of elements split into two groups, the first of which
  25739. * contains elements `predicate` returns truthy for, the second of which
  25740. * contains elements `predicate` returns falsey for. The predicate is
  25741. * invoked with one argument: (value).
  25742. *
  25743. * @static
  25744. * @memberOf _
  25745. * @since 3.0.0
  25746. * @category Collection
  25747. * @param {Array|Object} collection The collection to iterate over.
  25748. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25749. * @returns {Array} Returns the array of grouped elements.
  25750. * @example
  25751. *
  25752. * var users = [
  25753. * { 'user': 'barney', 'age': 36, 'active': false },
  25754. * { 'user': 'fred', 'age': 40, 'active': true },
  25755. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25756. * ];
  25757. *
  25758. * _.partition(users, function(o) { return o.active; });
  25759. * // => objects for [['fred'], ['barney', 'pebbles']]
  25760. *
  25761. * // The `_.matches` iteratee shorthand.
  25762. * _.partition(users, { 'age': 1, 'active': false });
  25763. * // => objects for [['pebbles'], ['barney', 'fred']]
  25764. *
  25765. * // The `_.matchesProperty` iteratee shorthand.
  25766. * _.partition(users, ['active', false]);
  25767. * // => objects for [['barney', 'pebbles'], ['fred']]
  25768. *
  25769. * // The `_.property` iteratee shorthand.
  25770. * _.partition(users, 'active');
  25771. * // => objects for [['fred'], ['barney', 'pebbles']]
  25772. */
  25773. var partition = createAggregator(function(result, value, key) {
  25774. result[key ? 0 : 1].push(value);
  25775. }, function() { return [[], []]; });
  25776. /**
  25777. * Reduces `collection` to a value which is the accumulated result of running
  25778. * each element in `collection` thru `iteratee`, where each successive
  25779. * invocation is supplied the return value of the previous. If `accumulator`
  25780. * is not given, the first element of `collection` is used as the initial
  25781. * value. The iteratee is invoked with four arguments:
  25782. * (accumulator, value, index|key, collection).
  25783. *
  25784. * Many lodash methods are guarded to work as iteratees for methods like
  25785. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25786. *
  25787. * The guarded methods are:
  25788. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25789. * and `sortBy`
  25790. *
  25791. * @static
  25792. * @memberOf _
  25793. * @since 0.1.0
  25794. * @category Collection
  25795. * @param {Array|Object} collection The collection to iterate over.
  25796. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25797. * @param {*} [accumulator] The initial value.
  25798. * @returns {*} Returns the accumulated value.
  25799. * @see _.reduceRight
  25800. * @example
  25801. *
  25802. * _.reduce([1, 2], function(sum, n) {
  25803. * return sum + n;
  25804. * }, 0);
  25805. * // => 3
  25806. *
  25807. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25808. * (result[value] || (result[value] = [])).push(key);
  25809. * return result;
  25810. * }, {});
  25811. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25812. */
  25813. function reduce(collection, iteratee, accumulator) {
  25814. var func = isArray(collection) ? arrayReduce : baseReduce,
  25815. initAccum = arguments.length < 3;
  25816. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25817. }
  25818. /**
  25819. * This method is like `_.reduce` except that it iterates over elements of
  25820. * `collection` from right to left.
  25821. *
  25822. * @static
  25823. * @memberOf _
  25824. * @since 0.1.0
  25825. * @category Collection
  25826. * @param {Array|Object} collection The collection to iterate over.
  25827. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25828. * @param {*} [accumulator] The initial value.
  25829. * @returns {*} Returns the accumulated value.
  25830. * @see _.reduce
  25831. * @example
  25832. *
  25833. * var array = [[0, 1], [2, 3], [4, 5]];
  25834. *
  25835. * _.reduceRight(array, function(flattened, other) {
  25836. * return flattened.concat(other);
  25837. * }, []);
  25838. * // => [4, 5, 2, 3, 0, 1]
  25839. */
  25840. function reduceRight(collection, iteratee, accumulator) {
  25841. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25842. initAccum = arguments.length < 3;
  25843. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25844. }
  25845. /**
  25846. * The opposite of `_.filter`; this method returns the elements of `collection`
  25847. * that `predicate` does **not** return truthy for.
  25848. *
  25849. * @static
  25850. * @memberOf _
  25851. * @since 0.1.0
  25852. * @category Collection
  25853. * @param {Array|Object} collection The collection to iterate over.
  25854. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25855. * @returns {Array} Returns the new filtered array.
  25856. * @see _.filter
  25857. * @example
  25858. *
  25859. * var users = [
  25860. * { 'user': 'barney', 'age': 36, 'active': false },
  25861. * { 'user': 'fred', 'age': 40, 'active': true }
  25862. * ];
  25863. *
  25864. * _.reject(users, function(o) { return !o.active; });
  25865. * // => objects for ['fred']
  25866. *
  25867. * // The `_.matches` iteratee shorthand.
  25868. * _.reject(users, { 'age': 40, 'active': true });
  25869. * // => objects for ['barney']
  25870. *
  25871. * // The `_.matchesProperty` iteratee shorthand.
  25872. * _.reject(users, ['active', false]);
  25873. * // => objects for ['fred']
  25874. *
  25875. * // The `_.property` iteratee shorthand.
  25876. * _.reject(users, 'active');
  25877. * // => objects for ['barney']
  25878. */
  25879. function reject(collection, predicate) {
  25880. var func = isArray(collection) ? arrayFilter : baseFilter;
  25881. return func(collection, negate(getIteratee(predicate, 3)));
  25882. }
  25883. /**
  25884. * Gets a random element from `collection`.
  25885. *
  25886. * @static
  25887. * @memberOf _
  25888. * @since 2.0.0
  25889. * @category Collection
  25890. * @param {Array|Object} collection The collection to sample.
  25891. * @returns {*} Returns the random element.
  25892. * @example
  25893. *
  25894. * _.sample([1, 2, 3, 4]);
  25895. * // => 2
  25896. */
  25897. function sample(collection) {
  25898. var func = isArray(collection) ? arraySample : baseSample;
  25899. return func(collection);
  25900. }
  25901. /**
  25902. * Gets `n` random elements at unique keys from `collection` up to the
  25903. * size of `collection`.
  25904. *
  25905. * @static
  25906. * @memberOf _
  25907. * @since 4.0.0
  25908. * @category Collection
  25909. * @param {Array|Object} collection The collection to sample.
  25910. * @param {number} [n=1] The number of elements to sample.
  25911. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25912. * @returns {Array} Returns the random elements.
  25913. * @example
  25914. *
  25915. * _.sampleSize([1, 2, 3], 2);
  25916. * // => [3, 1]
  25917. *
  25918. * _.sampleSize([1, 2, 3], 4);
  25919. * // => [2, 3, 1]
  25920. */
  25921. function sampleSize(collection, n, guard) {
  25922. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25923. n = 1;
  25924. } else {
  25925. n = toInteger(n);
  25926. }
  25927. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25928. return func(collection, n);
  25929. }
  25930. /**
  25931. * Creates an array of shuffled values, using a version of the
  25932. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25933. *
  25934. * @static
  25935. * @memberOf _
  25936. * @since 0.1.0
  25937. * @category Collection
  25938. * @param {Array|Object} collection The collection to shuffle.
  25939. * @returns {Array} Returns the new shuffled array.
  25940. * @example
  25941. *
  25942. * _.shuffle([1, 2, 3, 4]);
  25943. * // => [4, 1, 3, 2]
  25944. */
  25945. function shuffle(collection) {
  25946. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25947. return func(collection);
  25948. }
  25949. /**
  25950. * Gets the size of `collection` by returning its length for array-like
  25951. * values or the number of own enumerable string keyed properties for objects.
  25952. *
  25953. * @static
  25954. * @memberOf _
  25955. * @since 0.1.0
  25956. * @category Collection
  25957. * @param {Array|Object|string} collection The collection to inspect.
  25958. * @returns {number} Returns the collection size.
  25959. * @example
  25960. *
  25961. * _.size([1, 2, 3]);
  25962. * // => 3
  25963. *
  25964. * _.size({ 'a': 1, 'b': 2 });
  25965. * // => 2
  25966. *
  25967. * _.size('pebbles');
  25968. * // => 7
  25969. */
  25970. function size(collection) {
  25971. if (collection == null) {
  25972. return 0;
  25973. }
  25974. if (isArrayLike(collection)) {
  25975. return isString(collection) ? stringSize(collection) : collection.length;
  25976. }
  25977. var tag = getTag(collection);
  25978. if (tag == mapTag || tag == setTag) {
  25979. return collection.size;
  25980. }
  25981. return baseKeys(collection).length;
  25982. }
  25983. /**
  25984. * Checks if `predicate` returns truthy for **any** element of `collection`.
  25985. * Iteration is stopped once `predicate` returns truthy. The predicate is
  25986. * invoked with three arguments: (value, index|key, collection).
  25987. *
  25988. * @static
  25989. * @memberOf _
  25990. * @since 0.1.0
  25991. * @category Collection
  25992. * @param {Array|Object} collection The collection to iterate over.
  25993. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25994. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25995. * @returns {boolean} Returns `true` if any element passes the predicate check,
  25996. * else `false`.
  25997. * @example
  25998. *
  25999. * _.some([null, 0, 'yes', false], Boolean);
  26000. * // => true
  26001. *
  26002. * var users = [
  26003. * { 'user': 'barney', 'active': true },
  26004. * { 'user': 'fred', 'active': false }
  26005. * ];
  26006. *
  26007. * // The `_.matches` iteratee shorthand.
  26008. * _.some(users, { 'user': 'barney', 'active': false });
  26009. * // => false
  26010. *
  26011. * // The `_.matchesProperty` iteratee shorthand.
  26012. * _.some(users, ['active', false]);
  26013. * // => true
  26014. *
  26015. * // The `_.property` iteratee shorthand.
  26016. * _.some(users, 'active');
  26017. * // => true
  26018. */
  26019. function some(collection, predicate, guard) {
  26020. var func = isArray(collection) ? arraySome : baseSome;
  26021. if (guard && isIterateeCall(collection, predicate, guard)) {
  26022. predicate = undefined;
  26023. }
  26024. return func(collection, getIteratee(predicate, 3));
  26025. }
  26026. /**
  26027. * Creates an array of elements, sorted in ascending order by the results of
  26028. * running each element in a collection thru each iteratee. This method
  26029. * performs a stable sort, that is, it preserves the original sort order of
  26030. * equal elements. The iteratees are invoked with one argument: (value).
  26031. *
  26032. * @static
  26033. * @memberOf _
  26034. * @since 0.1.0
  26035. * @category Collection
  26036. * @param {Array|Object} collection The collection to iterate over.
  26037. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26038. * The iteratees to sort by.
  26039. * @returns {Array} Returns the new sorted array.
  26040. * @example
  26041. *
  26042. * var users = [
  26043. * { 'user': 'fred', 'age': 48 },
  26044. * { 'user': 'barney', 'age': 36 },
  26045. * { 'user': 'fred', 'age': 40 },
  26046. * { 'user': 'barney', 'age': 34 }
  26047. * ];
  26048. *
  26049. * _.sortBy(users, [function(o) { return o.user; }]);
  26050. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26051. *
  26052. * _.sortBy(users, ['user', 'age']);
  26053. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26054. */
  26055. var sortBy = baseRest(function(collection, iteratees) {
  26056. if (collection == null) {
  26057. return [];
  26058. }
  26059. var length = iteratees.length;
  26060. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26061. iteratees = [];
  26062. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26063. iteratees = [iteratees[0]];
  26064. }
  26065. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26066. });
  26067. /*------------------------------------------------------------------------*/
  26068. /**
  26069. * Gets the timestamp of the number of milliseconds that have elapsed since
  26070. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26071. *
  26072. * @static
  26073. * @memberOf _
  26074. * @since 2.4.0
  26075. * @category Date
  26076. * @returns {number} Returns the timestamp.
  26077. * @example
  26078. *
  26079. * _.defer(function(stamp) {
  26080. * console.log(_.now() - stamp);
  26081. * }, _.now());
  26082. * // => Logs the number of milliseconds it took for the deferred invocation.
  26083. */
  26084. var now = ctxNow || function() {
  26085. return root.Date.now();
  26086. };
  26087. /*------------------------------------------------------------------------*/
  26088. /**
  26089. * The opposite of `_.before`; this method creates a function that invokes
  26090. * `func` once it's called `n` or more times.
  26091. *
  26092. * @static
  26093. * @memberOf _
  26094. * @since 0.1.0
  26095. * @category Function
  26096. * @param {number} n The number of calls before `func` is invoked.
  26097. * @param {Function} func The function to restrict.
  26098. * @returns {Function} Returns the new restricted function.
  26099. * @example
  26100. *
  26101. * var saves = ['profile', 'settings'];
  26102. *
  26103. * var done = _.after(saves.length, function() {
  26104. * console.log('done saving!');
  26105. * });
  26106. *
  26107. * _.forEach(saves, function(type) {
  26108. * asyncSave({ 'type': type, 'complete': done });
  26109. * });
  26110. * // => Logs 'done saving!' after the two async saves have completed.
  26111. */
  26112. function after(n, func) {
  26113. if (typeof func != 'function') {
  26114. throw new TypeError(FUNC_ERROR_TEXT);
  26115. }
  26116. n = toInteger(n);
  26117. return function() {
  26118. if (--n < 1) {
  26119. return func.apply(this, arguments);
  26120. }
  26121. };
  26122. }
  26123. /**
  26124. * Creates a function that invokes `func`, with up to `n` arguments,
  26125. * ignoring any additional arguments.
  26126. *
  26127. * @static
  26128. * @memberOf _
  26129. * @since 3.0.0
  26130. * @category Function
  26131. * @param {Function} func The function to cap arguments for.
  26132. * @param {number} [n=func.length] The arity cap.
  26133. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26134. * @returns {Function} Returns the new capped function.
  26135. * @example
  26136. *
  26137. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26138. * // => [6, 8, 10]
  26139. */
  26140. function ary(func, n, guard) {
  26141. n = guard ? undefined : n;
  26142. n = (func && n == null) ? func.length : n;
  26143. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26144. }
  26145. /**
  26146. * Creates a function that invokes `func`, with the `this` binding and arguments
  26147. * of the created function, while it's called less than `n` times. Subsequent
  26148. * calls to the created function return the result of the last `func` invocation.
  26149. *
  26150. * @static
  26151. * @memberOf _
  26152. * @since 3.0.0
  26153. * @category Function
  26154. * @param {number} n The number of calls at which `func` is no longer invoked.
  26155. * @param {Function} func The function to restrict.
  26156. * @returns {Function} Returns the new restricted function.
  26157. * @example
  26158. *
  26159. * jQuery(element).on('click', _.before(5, addContactToList));
  26160. * // => Allows adding up to 4 contacts to the list.
  26161. */
  26162. function before(n, func) {
  26163. var result;
  26164. if (typeof func != 'function') {
  26165. throw new TypeError(FUNC_ERROR_TEXT);
  26166. }
  26167. n = toInteger(n);
  26168. return function() {
  26169. if (--n > 0) {
  26170. result = func.apply(this, arguments);
  26171. }
  26172. if (n <= 1) {
  26173. func = undefined;
  26174. }
  26175. return result;
  26176. };
  26177. }
  26178. /**
  26179. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26180. * and `partials` prepended to the arguments it receives.
  26181. *
  26182. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26183. * may be used as a placeholder for partially applied arguments.
  26184. *
  26185. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26186. * property of bound functions.
  26187. *
  26188. * @static
  26189. * @memberOf _
  26190. * @since 0.1.0
  26191. * @category Function
  26192. * @param {Function} func The function to bind.
  26193. * @param {*} thisArg The `this` binding of `func`.
  26194. * @param {...*} [partials] The arguments to be partially applied.
  26195. * @returns {Function} Returns the new bound function.
  26196. * @example
  26197. *
  26198. * function greet(greeting, punctuation) {
  26199. * return greeting + ' ' + this.user + punctuation;
  26200. * }
  26201. *
  26202. * var object = { 'user': 'fred' };
  26203. *
  26204. * var bound = _.bind(greet, object, 'hi');
  26205. * bound('!');
  26206. * // => 'hi fred!'
  26207. *
  26208. * // Bound with placeholders.
  26209. * var bound = _.bind(greet, object, _, '!');
  26210. * bound('hi');
  26211. * // => 'hi fred!'
  26212. */
  26213. var bind = baseRest(function(func, thisArg, partials) {
  26214. var bitmask = WRAP_BIND_FLAG;
  26215. if (partials.length) {
  26216. var holders = replaceHolders(partials, getHolder(bind));
  26217. bitmask |= WRAP_PARTIAL_FLAG;
  26218. }
  26219. return createWrap(func, bitmask, thisArg, partials, holders);
  26220. });
  26221. /**
  26222. * Creates a function that invokes the method at `object[key]` with `partials`
  26223. * prepended to the arguments it receives.
  26224. *
  26225. * This method differs from `_.bind` by allowing bound functions to reference
  26226. * methods that may be redefined or don't yet exist. See
  26227. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26228. * for more details.
  26229. *
  26230. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26231. * builds, may be used as a placeholder for partially applied arguments.
  26232. *
  26233. * @static
  26234. * @memberOf _
  26235. * @since 0.10.0
  26236. * @category Function
  26237. * @param {Object} object The object to invoke the method on.
  26238. * @param {string} key The key of the method.
  26239. * @param {...*} [partials] The arguments to be partially applied.
  26240. * @returns {Function} Returns the new bound function.
  26241. * @example
  26242. *
  26243. * var object = {
  26244. * 'user': 'fred',
  26245. * 'greet': function(greeting, punctuation) {
  26246. * return greeting + ' ' + this.user + punctuation;
  26247. * }
  26248. * };
  26249. *
  26250. * var bound = _.bindKey(object, 'greet', 'hi');
  26251. * bound('!');
  26252. * // => 'hi fred!'
  26253. *
  26254. * object.greet = function(greeting, punctuation) {
  26255. * return greeting + 'ya ' + this.user + punctuation;
  26256. * };
  26257. *
  26258. * bound('!');
  26259. * // => 'hiya fred!'
  26260. *
  26261. * // Bound with placeholders.
  26262. * var bound = _.bindKey(object, 'greet', _, '!');
  26263. * bound('hi');
  26264. * // => 'hiya fred!'
  26265. */
  26266. var bindKey = baseRest(function(object, key, partials) {
  26267. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26268. if (partials.length) {
  26269. var holders = replaceHolders(partials, getHolder(bindKey));
  26270. bitmask |= WRAP_PARTIAL_FLAG;
  26271. }
  26272. return createWrap(key, bitmask, object, partials, holders);
  26273. });
  26274. /**
  26275. * Creates a function that accepts arguments of `func` and either invokes
  26276. * `func` returning its result, if at least `arity` number of arguments have
  26277. * been provided, or returns a function that accepts the remaining `func`
  26278. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26279. * is not sufficient.
  26280. *
  26281. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26282. * may be used as a placeholder for provided arguments.
  26283. *
  26284. * **Note:** This method doesn't set the "length" property of curried functions.
  26285. *
  26286. * @static
  26287. * @memberOf _
  26288. * @since 2.0.0
  26289. * @category Function
  26290. * @param {Function} func The function to curry.
  26291. * @param {number} [arity=func.length] The arity of `func`.
  26292. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26293. * @returns {Function} Returns the new curried function.
  26294. * @example
  26295. *
  26296. * var abc = function(a, b, c) {
  26297. * return [a, b, c];
  26298. * };
  26299. *
  26300. * var curried = _.curry(abc);
  26301. *
  26302. * curried(1)(2)(3);
  26303. * // => [1, 2, 3]
  26304. *
  26305. * curried(1, 2)(3);
  26306. * // => [1, 2, 3]
  26307. *
  26308. * curried(1, 2, 3);
  26309. * // => [1, 2, 3]
  26310. *
  26311. * // Curried with placeholders.
  26312. * curried(1)(_, 3)(2);
  26313. * // => [1, 2, 3]
  26314. */
  26315. function curry(func, arity, guard) {
  26316. arity = guard ? undefined : arity;
  26317. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26318. result.placeholder = curry.placeholder;
  26319. return result;
  26320. }
  26321. /**
  26322. * This method is like `_.curry` except that arguments are applied to `func`
  26323. * in the manner of `_.partialRight` instead of `_.partial`.
  26324. *
  26325. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26326. * builds, may be used as a placeholder for provided arguments.
  26327. *
  26328. * **Note:** This method doesn't set the "length" property of curried functions.
  26329. *
  26330. * @static
  26331. * @memberOf _
  26332. * @since 3.0.0
  26333. * @category Function
  26334. * @param {Function} func The function to curry.
  26335. * @param {number} [arity=func.length] The arity of `func`.
  26336. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26337. * @returns {Function} Returns the new curried function.
  26338. * @example
  26339. *
  26340. * var abc = function(a, b, c) {
  26341. * return [a, b, c];
  26342. * };
  26343. *
  26344. * var curried = _.curryRight(abc);
  26345. *
  26346. * curried(3)(2)(1);
  26347. * // => [1, 2, 3]
  26348. *
  26349. * curried(2, 3)(1);
  26350. * // => [1, 2, 3]
  26351. *
  26352. * curried(1, 2, 3);
  26353. * // => [1, 2, 3]
  26354. *
  26355. * // Curried with placeholders.
  26356. * curried(3)(1, _)(2);
  26357. * // => [1, 2, 3]
  26358. */
  26359. function curryRight(func, arity, guard) {
  26360. arity = guard ? undefined : arity;
  26361. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26362. result.placeholder = curryRight.placeholder;
  26363. return result;
  26364. }
  26365. /**
  26366. * Creates a debounced function that delays invoking `func` until after `wait`
  26367. * milliseconds have elapsed since the last time the debounced function was
  26368. * invoked. The debounced function comes with a `cancel` method to cancel
  26369. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26370. * Provide `options` to indicate whether `func` should be invoked on the
  26371. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26372. * with the last arguments provided to the debounced function. Subsequent
  26373. * calls to the debounced function return the result of the last `func`
  26374. * invocation.
  26375. *
  26376. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26377. * invoked on the trailing edge of the timeout only if the debounced function
  26378. * is invoked more than once during the `wait` timeout.
  26379. *
  26380. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26381. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26382. *
  26383. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26384. * for details over the differences between `_.debounce` and `_.throttle`.
  26385. *
  26386. * @static
  26387. * @memberOf _
  26388. * @since 0.1.0
  26389. * @category Function
  26390. * @param {Function} func The function to debounce.
  26391. * @param {number} [wait=0] The number of milliseconds to delay.
  26392. * @param {Object} [options={}] The options object.
  26393. * @param {boolean} [options.leading=false]
  26394. * Specify invoking on the leading edge of the timeout.
  26395. * @param {number} [options.maxWait]
  26396. * The maximum time `func` is allowed to be delayed before it's invoked.
  26397. * @param {boolean} [options.trailing=true]
  26398. * Specify invoking on the trailing edge of the timeout.
  26399. * @returns {Function} Returns the new debounced function.
  26400. * @example
  26401. *
  26402. * // Avoid costly calculations while the window size is in flux.
  26403. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26404. *
  26405. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26406. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26407. * 'leading': true,
  26408. * 'trailing': false
  26409. * }));
  26410. *
  26411. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26412. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26413. * var source = new EventSource('/stream');
  26414. * jQuery(source).on('message', debounced);
  26415. *
  26416. * // Cancel the trailing debounced invocation.
  26417. * jQuery(window).on('popstate', debounced.cancel);
  26418. */
  26419. function debounce(func, wait, options) {
  26420. var lastArgs,
  26421. lastThis,
  26422. maxWait,
  26423. result,
  26424. timerId,
  26425. lastCallTime,
  26426. lastInvokeTime = 0,
  26427. leading = false,
  26428. maxing = false,
  26429. trailing = true;
  26430. if (typeof func != 'function') {
  26431. throw new TypeError(FUNC_ERROR_TEXT);
  26432. }
  26433. wait = toNumber(wait) || 0;
  26434. if (isObject(options)) {
  26435. leading = !!options.leading;
  26436. maxing = 'maxWait' in options;
  26437. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26438. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26439. }
  26440. function invokeFunc(time) {
  26441. var args = lastArgs,
  26442. thisArg = lastThis;
  26443. lastArgs = lastThis = undefined;
  26444. lastInvokeTime = time;
  26445. result = func.apply(thisArg, args);
  26446. return result;
  26447. }
  26448. function leadingEdge(time) {
  26449. // Reset any `maxWait` timer.
  26450. lastInvokeTime = time;
  26451. // Start the timer for the trailing edge.
  26452. timerId = setTimeout(timerExpired, wait);
  26453. // Invoke the leading edge.
  26454. return leading ? invokeFunc(time) : result;
  26455. }
  26456. function remainingWait(time) {
  26457. var timeSinceLastCall = time - lastCallTime,
  26458. timeSinceLastInvoke = time - lastInvokeTime,
  26459. timeWaiting = wait - timeSinceLastCall;
  26460. return maxing
  26461. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26462. : timeWaiting;
  26463. }
  26464. function shouldInvoke(time) {
  26465. var timeSinceLastCall = time - lastCallTime,
  26466. timeSinceLastInvoke = time - lastInvokeTime;
  26467. // Either this is the first call, activity has stopped and we're at the
  26468. // trailing edge, the system time has gone backwards and we're treating
  26469. // it as the trailing edge, or we've hit the `maxWait` limit.
  26470. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26471. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26472. }
  26473. function timerExpired() {
  26474. var time = now();
  26475. if (shouldInvoke(time)) {
  26476. return trailingEdge(time);
  26477. }
  26478. // Restart the timer.
  26479. timerId = setTimeout(timerExpired, remainingWait(time));
  26480. }
  26481. function trailingEdge(time) {
  26482. timerId = undefined;
  26483. // Only invoke if we have `lastArgs` which means `func` has been
  26484. // debounced at least once.
  26485. if (trailing && lastArgs) {
  26486. return invokeFunc(time);
  26487. }
  26488. lastArgs = lastThis = undefined;
  26489. return result;
  26490. }
  26491. function cancel() {
  26492. if (timerId !== undefined) {
  26493. clearTimeout(timerId);
  26494. }
  26495. lastInvokeTime = 0;
  26496. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26497. }
  26498. function flush() {
  26499. return timerId === undefined ? result : trailingEdge(now());
  26500. }
  26501. function debounced() {
  26502. var time = now(),
  26503. isInvoking = shouldInvoke(time);
  26504. lastArgs = arguments;
  26505. lastThis = this;
  26506. lastCallTime = time;
  26507. if (isInvoking) {
  26508. if (timerId === undefined) {
  26509. return leadingEdge(lastCallTime);
  26510. }
  26511. if (maxing) {
  26512. // Handle invocations in a tight loop.
  26513. clearTimeout(timerId);
  26514. timerId = setTimeout(timerExpired, wait);
  26515. return invokeFunc(lastCallTime);
  26516. }
  26517. }
  26518. if (timerId === undefined) {
  26519. timerId = setTimeout(timerExpired, wait);
  26520. }
  26521. return result;
  26522. }
  26523. debounced.cancel = cancel;
  26524. debounced.flush = flush;
  26525. return debounced;
  26526. }
  26527. /**
  26528. * Defers invoking the `func` until the current call stack has cleared. Any
  26529. * additional arguments are provided to `func` when it's invoked.
  26530. *
  26531. * @static
  26532. * @memberOf _
  26533. * @since 0.1.0
  26534. * @category Function
  26535. * @param {Function} func The function to defer.
  26536. * @param {...*} [args] The arguments to invoke `func` with.
  26537. * @returns {number} Returns the timer id.
  26538. * @example
  26539. *
  26540. * _.defer(function(text) {
  26541. * console.log(text);
  26542. * }, 'deferred');
  26543. * // => Logs 'deferred' after one millisecond.
  26544. */
  26545. var defer = baseRest(function(func, args) {
  26546. return baseDelay(func, 1, args);
  26547. });
  26548. /**
  26549. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26550. * provided to `func` when it's invoked.
  26551. *
  26552. * @static
  26553. * @memberOf _
  26554. * @since 0.1.0
  26555. * @category Function
  26556. * @param {Function} func The function to delay.
  26557. * @param {number} wait The number of milliseconds to delay invocation.
  26558. * @param {...*} [args] The arguments to invoke `func` with.
  26559. * @returns {number} Returns the timer id.
  26560. * @example
  26561. *
  26562. * _.delay(function(text) {
  26563. * console.log(text);
  26564. * }, 1000, 'later');
  26565. * // => Logs 'later' after one second.
  26566. */
  26567. var delay = baseRest(function(func, wait, args) {
  26568. return baseDelay(func, toNumber(wait) || 0, args);
  26569. });
  26570. /**
  26571. * Creates a function that invokes `func` with arguments reversed.
  26572. *
  26573. * @static
  26574. * @memberOf _
  26575. * @since 4.0.0
  26576. * @category Function
  26577. * @param {Function} func The function to flip arguments for.
  26578. * @returns {Function} Returns the new flipped function.
  26579. * @example
  26580. *
  26581. * var flipped = _.flip(function() {
  26582. * return _.toArray(arguments);
  26583. * });
  26584. *
  26585. * flipped('a', 'b', 'c', 'd');
  26586. * // => ['d', 'c', 'b', 'a']
  26587. */
  26588. function flip(func) {
  26589. return createWrap(func, WRAP_FLIP_FLAG);
  26590. }
  26591. /**
  26592. * Creates a function that memoizes the result of `func`. If `resolver` is
  26593. * provided, it determines the cache key for storing the result based on the
  26594. * arguments provided to the memoized function. By default, the first argument
  26595. * provided to the memoized function is used as the map cache key. The `func`
  26596. * is invoked with the `this` binding of the memoized function.
  26597. *
  26598. * **Note:** The cache is exposed as the `cache` property on the memoized
  26599. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26600. * constructor with one whose instances implement the
  26601. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26602. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26603. *
  26604. * @static
  26605. * @memberOf _
  26606. * @since 0.1.0
  26607. * @category Function
  26608. * @param {Function} func The function to have its output memoized.
  26609. * @param {Function} [resolver] The function to resolve the cache key.
  26610. * @returns {Function} Returns the new memoized function.
  26611. * @example
  26612. *
  26613. * var object = { 'a': 1, 'b': 2 };
  26614. * var other = { 'c': 3, 'd': 4 };
  26615. *
  26616. * var values = _.memoize(_.values);
  26617. * values(object);
  26618. * // => [1, 2]
  26619. *
  26620. * values(other);
  26621. * // => [3, 4]
  26622. *
  26623. * object.a = 2;
  26624. * values(object);
  26625. * // => [1, 2]
  26626. *
  26627. * // Modify the result cache.
  26628. * values.cache.set(object, ['a', 'b']);
  26629. * values(object);
  26630. * // => ['a', 'b']
  26631. *
  26632. * // Replace `_.memoize.Cache`.
  26633. * _.memoize.Cache = WeakMap;
  26634. */
  26635. function memoize(func, resolver) {
  26636. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26637. throw new TypeError(FUNC_ERROR_TEXT);
  26638. }
  26639. var memoized = function() {
  26640. var args = arguments,
  26641. key = resolver ? resolver.apply(this, args) : args[0],
  26642. cache = memoized.cache;
  26643. if (cache.has(key)) {
  26644. return cache.get(key);
  26645. }
  26646. var result = func.apply(this, args);
  26647. memoized.cache = cache.set(key, result) || cache;
  26648. return result;
  26649. };
  26650. memoized.cache = new (memoize.Cache || MapCache);
  26651. return memoized;
  26652. }
  26653. // Expose `MapCache`.
  26654. memoize.Cache = MapCache;
  26655. /**
  26656. * Creates a function that negates the result of the predicate `func`. The
  26657. * `func` predicate is invoked with the `this` binding and arguments of the
  26658. * created function.
  26659. *
  26660. * @static
  26661. * @memberOf _
  26662. * @since 3.0.0
  26663. * @category Function
  26664. * @param {Function} predicate The predicate to negate.
  26665. * @returns {Function} Returns the new negated function.
  26666. * @example
  26667. *
  26668. * function isEven(n) {
  26669. * return n % 2 == 0;
  26670. * }
  26671. *
  26672. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26673. * // => [1, 3, 5]
  26674. */
  26675. function negate(predicate) {
  26676. if (typeof predicate != 'function') {
  26677. throw new TypeError(FUNC_ERROR_TEXT);
  26678. }
  26679. return function() {
  26680. var args = arguments;
  26681. switch (args.length) {
  26682. case 0: return !predicate.call(this);
  26683. case 1: return !predicate.call(this, args[0]);
  26684. case 2: return !predicate.call(this, args[0], args[1]);
  26685. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26686. }
  26687. return !predicate.apply(this, args);
  26688. };
  26689. }
  26690. /**
  26691. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26692. * to the function return the value of the first invocation. The `func` is
  26693. * invoked with the `this` binding and arguments of the created function.
  26694. *
  26695. * @static
  26696. * @memberOf _
  26697. * @since 0.1.0
  26698. * @category Function
  26699. * @param {Function} func The function to restrict.
  26700. * @returns {Function} Returns the new restricted function.
  26701. * @example
  26702. *
  26703. * var initialize = _.once(createApplication);
  26704. * initialize();
  26705. * initialize();
  26706. * // => `createApplication` is invoked once
  26707. */
  26708. function once(func) {
  26709. return before(2, func);
  26710. }
  26711. /**
  26712. * Creates a function that invokes `func` with its arguments transformed.
  26713. *
  26714. * @static
  26715. * @since 4.0.0
  26716. * @memberOf _
  26717. * @category Function
  26718. * @param {Function} func The function to wrap.
  26719. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26720. * The argument transforms.
  26721. * @returns {Function} Returns the new function.
  26722. * @example
  26723. *
  26724. * function doubled(n) {
  26725. * return n * 2;
  26726. * }
  26727. *
  26728. * function square(n) {
  26729. * return n * n;
  26730. * }
  26731. *
  26732. * var func = _.overArgs(function(x, y) {
  26733. * return [x, y];
  26734. * }, [square, doubled]);
  26735. *
  26736. * func(9, 3);
  26737. * // => [81, 6]
  26738. *
  26739. * func(10, 5);
  26740. * // => [100, 10]
  26741. */
  26742. var overArgs = castRest(function(func, transforms) {
  26743. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26744. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26745. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26746. var funcsLength = transforms.length;
  26747. return baseRest(function(args) {
  26748. var index = -1,
  26749. length = nativeMin(args.length, funcsLength);
  26750. while (++index < length) {
  26751. args[index] = transforms[index].call(this, args[index]);
  26752. }
  26753. return apply(func, this, args);
  26754. });
  26755. });
  26756. /**
  26757. * Creates a function that invokes `func` with `partials` prepended to the
  26758. * arguments it receives. This method is like `_.bind` except it does **not**
  26759. * alter the `this` binding.
  26760. *
  26761. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26762. * builds, may be used as a placeholder for partially applied arguments.
  26763. *
  26764. * **Note:** This method doesn't set the "length" property of partially
  26765. * applied functions.
  26766. *
  26767. * @static
  26768. * @memberOf _
  26769. * @since 0.2.0
  26770. * @category Function
  26771. * @param {Function} func The function to partially apply arguments to.
  26772. * @param {...*} [partials] The arguments to be partially applied.
  26773. * @returns {Function} Returns the new partially applied function.
  26774. * @example
  26775. *
  26776. * function greet(greeting, name) {
  26777. * return greeting + ' ' + name;
  26778. * }
  26779. *
  26780. * var sayHelloTo = _.partial(greet, 'hello');
  26781. * sayHelloTo('fred');
  26782. * // => 'hello fred'
  26783. *
  26784. * // Partially applied with placeholders.
  26785. * var greetFred = _.partial(greet, _, 'fred');
  26786. * greetFred('hi');
  26787. * // => 'hi fred'
  26788. */
  26789. var partial = baseRest(function(func, partials) {
  26790. var holders = replaceHolders(partials, getHolder(partial));
  26791. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26792. });
  26793. /**
  26794. * This method is like `_.partial` except that partially applied arguments
  26795. * are appended to the arguments it receives.
  26796. *
  26797. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  26798. * builds, may be used as a placeholder for partially applied arguments.
  26799. *
  26800. * **Note:** This method doesn't set the "length" property of partially
  26801. * applied functions.
  26802. *
  26803. * @static
  26804. * @memberOf _
  26805. * @since 1.0.0
  26806. * @category Function
  26807. * @param {Function} func The function to partially apply arguments to.
  26808. * @param {...*} [partials] The arguments to be partially applied.
  26809. * @returns {Function} Returns the new partially applied function.
  26810. * @example
  26811. *
  26812. * function greet(greeting, name) {
  26813. * return greeting + ' ' + name;
  26814. * }
  26815. *
  26816. * var greetFred = _.partialRight(greet, 'fred');
  26817. * greetFred('hi');
  26818. * // => 'hi fred'
  26819. *
  26820. * // Partially applied with placeholders.
  26821. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26822. * sayHelloTo('fred');
  26823. * // => 'hello fred'
  26824. */
  26825. var partialRight = baseRest(function(func, partials) {
  26826. var holders = replaceHolders(partials, getHolder(partialRight));
  26827. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26828. });
  26829. /**
  26830. * Creates a function that invokes `func` with arguments arranged according
  26831. * to the specified `indexes` where the argument value at the first index is
  26832. * provided as the first argument, the argument value at the second index is
  26833. * provided as the second argument, and so on.
  26834. *
  26835. * @static
  26836. * @memberOf _
  26837. * @since 3.0.0
  26838. * @category Function
  26839. * @param {Function} func The function to rearrange arguments for.
  26840. * @param {...(number|number[])} indexes The arranged argument indexes.
  26841. * @returns {Function} Returns the new function.
  26842. * @example
  26843. *
  26844. * var rearged = _.rearg(function(a, b, c) {
  26845. * return [a, b, c];
  26846. * }, [2, 0, 1]);
  26847. *
  26848. * rearged('b', 'c', 'a')
  26849. * // => ['a', 'b', 'c']
  26850. */
  26851. var rearg = flatRest(function(func, indexes) {
  26852. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26853. });
  26854. /**
  26855. * Creates a function that invokes `func` with the `this` binding of the
  26856. * created function and arguments from `start` and beyond provided as
  26857. * an array.
  26858. *
  26859. * **Note:** This method is based on the
  26860. * [rest parameter](https://mdn.io/rest_parameters).
  26861. *
  26862. * @static
  26863. * @memberOf _
  26864. * @since 4.0.0
  26865. * @category Function
  26866. * @param {Function} func The function to apply a rest parameter to.
  26867. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26868. * @returns {Function} Returns the new function.
  26869. * @example
  26870. *
  26871. * var say = _.rest(function(what, names) {
  26872. * return what + ' ' + _.initial(names).join(', ') +
  26873. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26874. * });
  26875. *
  26876. * say('hello', 'fred', 'barney', 'pebbles');
  26877. * // => 'hello fred, barney, & pebbles'
  26878. */
  26879. function rest(func, start) {
  26880. if (typeof func != 'function') {
  26881. throw new TypeError(FUNC_ERROR_TEXT);
  26882. }
  26883. start = start === undefined ? start : toInteger(start);
  26884. return baseRest(func, start);
  26885. }
  26886. /**
  26887. * Creates a function that invokes `func` with the `this` binding of the
  26888. * create function and an array of arguments much like
  26889. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26890. *
  26891. * **Note:** This method is based on the
  26892. * [spread operator](https://mdn.io/spread_operator).
  26893. *
  26894. * @static
  26895. * @memberOf _
  26896. * @since 3.2.0
  26897. * @category Function
  26898. * @param {Function} func The function to spread arguments over.
  26899. * @param {number} [start=0] The start position of the spread.
  26900. * @returns {Function} Returns the new function.
  26901. * @example
  26902. *
  26903. * var say = _.spread(function(who, what) {
  26904. * return who + ' says ' + what;
  26905. * });
  26906. *
  26907. * say(['fred', 'hello']);
  26908. * // => 'fred says hello'
  26909. *
  26910. * var numbers = Promise.all([
  26911. * Promise.resolve(40),
  26912. * Promise.resolve(36)
  26913. * ]);
  26914. *
  26915. * numbers.then(_.spread(function(x, y) {
  26916. * return x + y;
  26917. * }));
  26918. * // => a Promise of 76
  26919. */
  26920. function spread(func, start) {
  26921. if (typeof func != 'function') {
  26922. throw new TypeError(FUNC_ERROR_TEXT);
  26923. }
  26924. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26925. return baseRest(function(args) {
  26926. var array = args[start],
  26927. otherArgs = castSlice(args, 0, start);
  26928. if (array) {
  26929. arrayPush(otherArgs, array);
  26930. }
  26931. return apply(func, this, otherArgs);
  26932. });
  26933. }
  26934. /**
  26935. * Creates a throttled function that only invokes `func` at most once per
  26936. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26937. * method to cancel delayed `func` invocations and a `flush` method to
  26938. * immediately invoke them. Provide `options` to indicate whether `func`
  26939. * should be invoked on the leading and/or trailing edge of the `wait`
  26940. * timeout. The `func` is invoked with the last arguments provided to the
  26941. * throttled function. Subsequent calls to the throttled function return the
  26942. * result of the last `func` invocation.
  26943. *
  26944. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26945. * invoked on the trailing edge of the timeout only if the throttled function
  26946. * is invoked more than once during the `wait` timeout.
  26947. *
  26948. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26949. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26950. *
  26951. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26952. * for details over the differences between `_.throttle` and `_.debounce`.
  26953. *
  26954. * @static
  26955. * @memberOf _
  26956. * @since 0.1.0
  26957. * @category Function
  26958. * @param {Function} func The function to throttle.
  26959. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  26960. * @param {Object} [options={}] The options object.
  26961. * @param {boolean} [options.leading=true]
  26962. * Specify invoking on the leading edge of the timeout.
  26963. * @param {boolean} [options.trailing=true]
  26964. * Specify invoking on the trailing edge of the timeout.
  26965. * @returns {Function} Returns the new throttled function.
  26966. * @example
  26967. *
  26968. * // Avoid excessively updating the position while scrolling.
  26969. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  26970. *
  26971. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  26972. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  26973. * jQuery(element).on('click', throttled);
  26974. *
  26975. * // Cancel the trailing throttled invocation.
  26976. * jQuery(window).on('popstate', throttled.cancel);
  26977. */
  26978. function throttle(func, wait, options) {
  26979. var leading = true,
  26980. trailing = true;
  26981. if (typeof func != 'function') {
  26982. throw new TypeError(FUNC_ERROR_TEXT);
  26983. }
  26984. if (isObject(options)) {
  26985. leading = 'leading' in options ? !!options.leading : leading;
  26986. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26987. }
  26988. return debounce(func, wait, {
  26989. 'leading': leading,
  26990. 'maxWait': wait,
  26991. 'trailing': trailing
  26992. });
  26993. }
  26994. /**
  26995. * Creates a function that accepts up to one argument, ignoring any
  26996. * additional arguments.
  26997. *
  26998. * @static
  26999. * @memberOf _
  27000. * @since 4.0.0
  27001. * @category Function
  27002. * @param {Function} func The function to cap arguments for.
  27003. * @returns {Function} Returns the new capped function.
  27004. * @example
  27005. *
  27006. * _.map(['6', '8', '10'], _.unary(parseInt));
  27007. * // => [6, 8, 10]
  27008. */
  27009. function unary(func) {
  27010. return ary(func, 1);
  27011. }
  27012. /**
  27013. * Creates a function that provides `value` to `wrapper` as its first
  27014. * argument. Any additional arguments provided to the function are appended
  27015. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27016. * binding of the created function.
  27017. *
  27018. * @static
  27019. * @memberOf _
  27020. * @since 0.1.0
  27021. * @category Function
  27022. * @param {*} value The value to wrap.
  27023. * @param {Function} [wrapper=identity] The wrapper function.
  27024. * @returns {Function} Returns the new function.
  27025. * @example
  27026. *
  27027. * var p = _.wrap(_.escape, function(func, text) {
  27028. * return '<p>' + func(text) + '</p>';
  27029. * });
  27030. *
  27031. * p('fred, barney, & pebbles');
  27032. * // => '<p>fred, barney, &amp; pebbles</p>'
  27033. */
  27034. function wrap(value, wrapper) {
  27035. return partial(castFunction(wrapper), value);
  27036. }
  27037. /*------------------------------------------------------------------------*/
  27038. /**
  27039. * Casts `value` as an array if it's not one.
  27040. *
  27041. * @static
  27042. * @memberOf _
  27043. * @since 4.4.0
  27044. * @category Lang
  27045. * @param {*} value The value to inspect.
  27046. * @returns {Array} Returns the cast array.
  27047. * @example
  27048. *
  27049. * _.castArray(1);
  27050. * // => [1]
  27051. *
  27052. * _.castArray({ 'a': 1 });
  27053. * // => [{ 'a': 1 }]
  27054. *
  27055. * _.castArray('abc');
  27056. * // => ['abc']
  27057. *
  27058. * _.castArray(null);
  27059. * // => [null]
  27060. *
  27061. * _.castArray(undefined);
  27062. * // => [undefined]
  27063. *
  27064. * _.castArray();
  27065. * // => []
  27066. *
  27067. * var array = [1, 2, 3];
  27068. * console.log(_.castArray(array) === array);
  27069. * // => true
  27070. */
  27071. function castArray() {
  27072. if (!arguments.length) {
  27073. return [];
  27074. }
  27075. var value = arguments[0];
  27076. return isArray(value) ? value : [value];
  27077. }
  27078. /**
  27079. * Creates a shallow clone of `value`.
  27080. *
  27081. * **Note:** This method is loosely based on the
  27082. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27083. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27084. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27085. * arrays. The own enumerable properties of `arguments` objects are cloned
  27086. * as plain objects. An empty object is returned for uncloneable values such
  27087. * as error objects, functions, DOM nodes, and WeakMaps.
  27088. *
  27089. * @static
  27090. * @memberOf _
  27091. * @since 0.1.0
  27092. * @category Lang
  27093. * @param {*} value The value to clone.
  27094. * @returns {*} Returns the cloned value.
  27095. * @see _.cloneDeep
  27096. * @example
  27097. *
  27098. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27099. *
  27100. * var shallow = _.clone(objects);
  27101. * console.log(shallow[0] === objects[0]);
  27102. * // => true
  27103. */
  27104. function clone(value) {
  27105. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27106. }
  27107. /**
  27108. * This method is like `_.clone` except that it accepts `customizer` which
  27109. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27110. * cloning is handled by the method instead. The `customizer` is invoked with
  27111. * up to four arguments; (value [, index|key, object, stack]).
  27112. *
  27113. * @static
  27114. * @memberOf _
  27115. * @since 4.0.0
  27116. * @category Lang
  27117. * @param {*} value The value to clone.
  27118. * @param {Function} [customizer] The function to customize cloning.
  27119. * @returns {*} Returns the cloned value.
  27120. * @see _.cloneDeepWith
  27121. * @example
  27122. *
  27123. * function customizer(value) {
  27124. * if (_.isElement(value)) {
  27125. * return value.cloneNode(false);
  27126. * }
  27127. * }
  27128. *
  27129. * var el = _.cloneWith(document.body, customizer);
  27130. *
  27131. * console.log(el === document.body);
  27132. * // => false
  27133. * console.log(el.nodeName);
  27134. * // => 'BODY'
  27135. * console.log(el.childNodes.length);
  27136. * // => 0
  27137. */
  27138. function cloneWith(value, customizer) {
  27139. customizer = typeof customizer == 'function' ? customizer : undefined;
  27140. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27141. }
  27142. /**
  27143. * This method is like `_.clone` except that it recursively clones `value`.
  27144. *
  27145. * @static
  27146. * @memberOf _
  27147. * @since 1.0.0
  27148. * @category Lang
  27149. * @param {*} value The value to recursively clone.
  27150. * @returns {*} Returns the deep cloned value.
  27151. * @see _.clone
  27152. * @example
  27153. *
  27154. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27155. *
  27156. * var deep = _.cloneDeep(objects);
  27157. * console.log(deep[0] === objects[0]);
  27158. * // => false
  27159. */
  27160. function cloneDeep(value) {
  27161. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27162. }
  27163. /**
  27164. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27165. *
  27166. * @static
  27167. * @memberOf _
  27168. * @since 4.0.0
  27169. * @category Lang
  27170. * @param {*} value The value to recursively clone.
  27171. * @param {Function} [customizer] The function to customize cloning.
  27172. * @returns {*} Returns the deep cloned value.
  27173. * @see _.cloneWith
  27174. * @example
  27175. *
  27176. * function customizer(value) {
  27177. * if (_.isElement(value)) {
  27178. * return value.cloneNode(true);
  27179. * }
  27180. * }
  27181. *
  27182. * var el = _.cloneDeepWith(document.body, customizer);
  27183. *
  27184. * console.log(el === document.body);
  27185. * // => false
  27186. * console.log(el.nodeName);
  27187. * // => 'BODY'
  27188. * console.log(el.childNodes.length);
  27189. * // => 20
  27190. */
  27191. function cloneDeepWith(value, customizer) {
  27192. customizer = typeof customizer == 'function' ? customizer : undefined;
  27193. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27194. }
  27195. /**
  27196. * Checks if `object` conforms to `source` by invoking the predicate
  27197. * properties of `source` with the corresponding property values of `object`.
  27198. *
  27199. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27200. * partially applied.
  27201. *
  27202. * @static
  27203. * @memberOf _
  27204. * @since 4.14.0
  27205. * @category Lang
  27206. * @param {Object} object The object to inspect.
  27207. * @param {Object} source The object of property predicates to conform to.
  27208. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27209. * @example
  27210. *
  27211. * var object = { 'a': 1, 'b': 2 };
  27212. *
  27213. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27214. * // => true
  27215. *
  27216. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27217. * // => false
  27218. */
  27219. function conformsTo(object, source) {
  27220. return source == null || baseConformsTo(object, source, keys(source));
  27221. }
  27222. /**
  27223. * Performs a
  27224. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27225. * comparison between two values to determine if they are equivalent.
  27226. *
  27227. * @static
  27228. * @memberOf _
  27229. * @since 4.0.0
  27230. * @category Lang
  27231. * @param {*} value The value to compare.
  27232. * @param {*} other The other value to compare.
  27233. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27234. * @example
  27235. *
  27236. * var object = { 'a': 1 };
  27237. * var other = { 'a': 1 };
  27238. *
  27239. * _.eq(object, object);
  27240. * // => true
  27241. *
  27242. * _.eq(object, other);
  27243. * // => false
  27244. *
  27245. * _.eq('a', 'a');
  27246. * // => true
  27247. *
  27248. * _.eq('a', Object('a'));
  27249. * // => false
  27250. *
  27251. * _.eq(NaN, NaN);
  27252. * // => true
  27253. */
  27254. function eq(value, other) {
  27255. return value === other || (value !== value && other !== other);
  27256. }
  27257. /**
  27258. * Checks if `value` is greater than `other`.
  27259. *
  27260. * @static
  27261. * @memberOf _
  27262. * @since 3.9.0
  27263. * @category Lang
  27264. * @param {*} value The value to compare.
  27265. * @param {*} other The other value to compare.
  27266. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27267. * else `false`.
  27268. * @see _.lt
  27269. * @example
  27270. *
  27271. * _.gt(3, 1);
  27272. * // => true
  27273. *
  27274. * _.gt(3, 3);
  27275. * // => false
  27276. *
  27277. * _.gt(1, 3);
  27278. * // => false
  27279. */
  27280. var gt = createRelationalOperation(baseGt);
  27281. /**
  27282. * Checks if `value` is greater than or equal to `other`.
  27283. *
  27284. * @static
  27285. * @memberOf _
  27286. * @since 3.9.0
  27287. * @category Lang
  27288. * @param {*} value The value to compare.
  27289. * @param {*} other The other value to compare.
  27290. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27291. * `other`, else `false`.
  27292. * @see _.lte
  27293. * @example
  27294. *
  27295. * _.gte(3, 1);
  27296. * // => true
  27297. *
  27298. * _.gte(3, 3);
  27299. * // => true
  27300. *
  27301. * _.gte(1, 3);
  27302. * // => false
  27303. */
  27304. var gte = createRelationalOperation(function(value, other) {
  27305. return value >= other;
  27306. });
  27307. /**
  27308. * Checks if `value` is likely an `arguments` object.
  27309. *
  27310. * @static
  27311. * @memberOf _
  27312. * @since 0.1.0
  27313. * @category Lang
  27314. * @param {*} value The value to check.
  27315. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27316. * else `false`.
  27317. * @example
  27318. *
  27319. * _.isArguments(function() { return arguments; }());
  27320. * // => true
  27321. *
  27322. * _.isArguments([1, 2, 3]);
  27323. * // => false
  27324. */
  27325. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27326. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27327. !propertyIsEnumerable.call(value, 'callee');
  27328. };
  27329. /**
  27330. * Checks if `value` is classified as an `Array` object.
  27331. *
  27332. * @static
  27333. * @memberOf _
  27334. * @since 0.1.0
  27335. * @category Lang
  27336. * @param {*} value The value to check.
  27337. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27338. * @example
  27339. *
  27340. * _.isArray([1, 2, 3]);
  27341. * // => true
  27342. *
  27343. * _.isArray(document.body.children);
  27344. * // => false
  27345. *
  27346. * _.isArray('abc');
  27347. * // => false
  27348. *
  27349. * _.isArray(_.noop);
  27350. * // => false
  27351. */
  27352. var isArray = Array.isArray;
  27353. /**
  27354. * Checks if `value` is classified as an `ArrayBuffer` object.
  27355. *
  27356. * @static
  27357. * @memberOf _
  27358. * @since 4.3.0
  27359. * @category Lang
  27360. * @param {*} value The value to check.
  27361. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27362. * @example
  27363. *
  27364. * _.isArrayBuffer(new ArrayBuffer(2));
  27365. * // => true
  27366. *
  27367. * _.isArrayBuffer(new Array(2));
  27368. * // => false
  27369. */
  27370. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27371. /**
  27372. * Checks if `value` is array-like. A value is considered array-like if it's
  27373. * not a function and has a `value.length` that's an integer greater than or
  27374. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27375. *
  27376. * @static
  27377. * @memberOf _
  27378. * @since 4.0.0
  27379. * @category Lang
  27380. * @param {*} value The value to check.
  27381. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27382. * @example
  27383. *
  27384. * _.isArrayLike([1, 2, 3]);
  27385. * // => true
  27386. *
  27387. * _.isArrayLike(document.body.children);
  27388. * // => true
  27389. *
  27390. * _.isArrayLike('abc');
  27391. * // => true
  27392. *
  27393. * _.isArrayLike(_.noop);
  27394. * // => false
  27395. */
  27396. function isArrayLike(value) {
  27397. return value != null && isLength(value.length) && !isFunction(value);
  27398. }
  27399. /**
  27400. * This method is like `_.isArrayLike` except that it also checks if `value`
  27401. * is an object.
  27402. *
  27403. * @static
  27404. * @memberOf _
  27405. * @since 4.0.0
  27406. * @category Lang
  27407. * @param {*} value The value to check.
  27408. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27409. * else `false`.
  27410. * @example
  27411. *
  27412. * _.isArrayLikeObject([1, 2, 3]);
  27413. * // => true
  27414. *
  27415. * _.isArrayLikeObject(document.body.children);
  27416. * // => true
  27417. *
  27418. * _.isArrayLikeObject('abc');
  27419. * // => false
  27420. *
  27421. * _.isArrayLikeObject(_.noop);
  27422. * // => false
  27423. */
  27424. function isArrayLikeObject(value) {
  27425. return isObjectLike(value) && isArrayLike(value);
  27426. }
  27427. /**
  27428. * Checks if `value` is classified as a boolean primitive or object.
  27429. *
  27430. * @static
  27431. * @memberOf _
  27432. * @since 0.1.0
  27433. * @category Lang
  27434. * @param {*} value The value to check.
  27435. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27436. * @example
  27437. *
  27438. * _.isBoolean(false);
  27439. * // => true
  27440. *
  27441. * _.isBoolean(null);
  27442. * // => false
  27443. */
  27444. function isBoolean(value) {
  27445. return value === true || value === false ||
  27446. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27447. }
  27448. /**
  27449. * Checks if `value` is a buffer.
  27450. *
  27451. * @static
  27452. * @memberOf _
  27453. * @since 4.3.0
  27454. * @category Lang
  27455. * @param {*} value The value to check.
  27456. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27457. * @example
  27458. *
  27459. * _.isBuffer(new Buffer(2));
  27460. * // => true
  27461. *
  27462. * _.isBuffer(new Uint8Array(2));
  27463. * // => false
  27464. */
  27465. var isBuffer = nativeIsBuffer || stubFalse;
  27466. /**
  27467. * Checks if `value` is classified as a `Date` object.
  27468. *
  27469. * @static
  27470. * @memberOf _
  27471. * @since 0.1.0
  27472. * @category Lang
  27473. * @param {*} value The value to check.
  27474. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27475. * @example
  27476. *
  27477. * _.isDate(new Date);
  27478. * // => true
  27479. *
  27480. * _.isDate('Mon April 23 2012');
  27481. * // => false
  27482. */
  27483. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27484. /**
  27485. * Checks if `value` is likely a DOM element.
  27486. *
  27487. * @static
  27488. * @memberOf _
  27489. * @since 0.1.0
  27490. * @category Lang
  27491. * @param {*} value The value to check.
  27492. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27493. * @example
  27494. *
  27495. * _.isElement(document.body);
  27496. * // => true
  27497. *
  27498. * _.isElement('<body>');
  27499. * // => false
  27500. */
  27501. function isElement(value) {
  27502. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27503. }
  27504. /**
  27505. * Checks if `value` is an empty object, collection, map, or set.
  27506. *
  27507. * Objects are considered empty if they have no own enumerable string keyed
  27508. * properties.
  27509. *
  27510. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27511. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27512. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27513. *
  27514. * @static
  27515. * @memberOf _
  27516. * @since 0.1.0
  27517. * @category Lang
  27518. * @param {*} value The value to check.
  27519. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27520. * @example
  27521. *
  27522. * _.isEmpty(null);
  27523. * // => true
  27524. *
  27525. * _.isEmpty(true);
  27526. * // => true
  27527. *
  27528. * _.isEmpty(1);
  27529. * // => true
  27530. *
  27531. * _.isEmpty([1, 2, 3]);
  27532. * // => false
  27533. *
  27534. * _.isEmpty({ 'a': 1 });
  27535. * // => false
  27536. */
  27537. function isEmpty(value) {
  27538. if (value == null) {
  27539. return true;
  27540. }
  27541. if (isArrayLike(value) &&
  27542. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27543. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27544. return !value.length;
  27545. }
  27546. var tag = getTag(value);
  27547. if (tag == mapTag || tag == setTag) {
  27548. return !value.size;
  27549. }
  27550. if (isPrototype(value)) {
  27551. return !baseKeys(value).length;
  27552. }
  27553. for (var key in value) {
  27554. if (hasOwnProperty.call(value, key)) {
  27555. return false;
  27556. }
  27557. }
  27558. return true;
  27559. }
  27560. /**
  27561. * Performs a deep comparison between two values to determine if they are
  27562. * equivalent.
  27563. *
  27564. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27565. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27566. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27567. * by their own, not inherited, enumerable properties. Functions and DOM
  27568. * nodes are compared by strict equality, i.e. `===`.
  27569. *
  27570. * @static
  27571. * @memberOf _
  27572. * @since 0.1.0
  27573. * @category Lang
  27574. * @param {*} value The value to compare.
  27575. * @param {*} other The other value to compare.
  27576. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27577. * @example
  27578. *
  27579. * var object = { 'a': 1 };
  27580. * var other = { 'a': 1 };
  27581. *
  27582. * _.isEqual(object, other);
  27583. * // => true
  27584. *
  27585. * object === other;
  27586. * // => false
  27587. */
  27588. function isEqual(value, other) {
  27589. return baseIsEqual(value, other);
  27590. }
  27591. /**
  27592. * This method is like `_.isEqual` except that it accepts `customizer` which
  27593. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27594. * are handled by the method instead. The `customizer` is invoked with up to
  27595. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27596. *
  27597. * @static
  27598. * @memberOf _
  27599. * @since 4.0.0
  27600. * @category Lang
  27601. * @param {*} value The value to compare.
  27602. * @param {*} other The other value to compare.
  27603. * @param {Function} [customizer] The function to customize comparisons.
  27604. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27605. * @example
  27606. *
  27607. * function isGreeting(value) {
  27608. * return /^h(?:i|ello)$/.test(value);
  27609. * }
  27610. *
  27611. * function customizer(objValue, othValue) {
  27612. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27613. * return true;
  27614. * }
  27615. * }
  27616. *
  27617. * var array = ['hello', 'goodbye'];
  27618. * var other = ['hi', 'goodbye'];
  27619. *
  27620. * _.isEqualWith(array, other, customizer);
  27621. * // => true
  27622. */
  27623. function isEqualWith(value, other, customizer) {
  27624. customizer = typeof customizer == 'function' ? customizer : undefined;
  27625. var result = customizer ? customizer(value, other) : undefined;
  27626. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27627. }
  27628. /**
  27629. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27630. * `SyntaxError`, `TypeError`, or `URIError` object.
  27631. *
  27632. * @static
  27633. * @memberOf _
  27634. * @since 3.0.0
  27635. * @category Lang
  27636. * @param {*} value The value to check.
  27637. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27638. * @example
  27639. *
  27640. * _.isError(new Error);
  27641. * // => true
  27642. *
  27643. * _.isError(Error);
  27644. * // => false
  27645. */
  27646. function isError(value) {
  27647. if (!isObjectLike(value)) {
  27648. return false;
  27649. }
  27650. var tag = baseGetTag(value);
  27651. return tag == errorTag || tag == domExcTag ||
  27652. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27653. }
  27654. /**
  27655. * Checks if `value` is a finite primitive number.
  27656. *
  27657. * **Note:** This method is based on
  27658. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27659. *
  27660. * @static
  27661. * @memberOf _
  27662. * @since 0.1.0
  27663. * @category Lang
  27664. * @param {*} value The value to check.
  27665. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27666. * @example
  27667. *
  27668. * _.isFinite(3);
  27669. * // => true
  27670. *
  27671. * _.isFinite(Number.MIN_VALUE);
  27672. * // => true
  27673. *
  27674. * _.isFinite(Infinity);
  27675. * // => false
  27676. *
  27677. * _.isFinite('3');
  27678. * // => false
  27679. */
  27680. function isFinite(value) {
  27681. return typeof value == 'number' && nativeIsFinite(value);
  27682. }
  27683. /**
  27684. * Checks if `value` is classified as a `Function` object.
  27685. *
  27686. * @static
  27687. * @memberOf _
  27688. * @since 0.1.0
  27689. * @category Lang
  27690. * @param {*} value The value to check.
  27691. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27692. * @example
  27693. *
  27694. * _.isFunction(_);
  27695. * // => true
  27696. *
  27697. * _.isFunction(/abc/);
  27698. * // => false
  27699. */
  27700. function isFunction(value) {
  27701. if (!isObject(value)) {
  27702. return false;
  27703. }
  27704. // The use of `Object#toString` avoids issues with the `typeof` operator
  27705. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27706. var tag = baseGetTag(value);
  27707. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27708. }
  27709. /**
  27710. * Checks if `value` is an integer.
  27711. *
  27712. * **Note:** This method is based on
  27713. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27714. *
  27715. * @static
  27716. * @memberOf _
  27717. * @since 4.0.0
  27718. * @category Lang
  27719. * @param {*} value The value to check.
  27720. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27721. * @example
  27722. *
  27723. * _.isInteger(3);
  27724. * // => true
  27725. *
  27726. * _.isInteger(Number.MIN_VALUE);
  27727. * // => false
  27728. *
  27729. * _.isInteger(Infinity);
  27730. * // => false
  27731. *
  27732. * _.isInteger('3');
  27733. * // => false
  27734. */
  27735. function isInteger(value) {
  27736. return typeof value == 'number' && value == toInteger(value);
  27737. }
  27738. /**
  27739. * Checks if `value` is a valid array-like length.
  27740. *
  27741. * **Note:** This method is loosely based on
  27742. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27743. *
  27744. * @static
  27745. * @memberOf _
  27746. * @since 4.0.0
  27747. * @category Lang
  27748. * @param {*} value The value to check.
  27749. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27750. * @example
  27751. *
  27752. * _.isLength(3);
  27753. * // => true
  27754. *
  27755. * _.isLength(Number.MIN_VALUE);
  27756. * // => false
  27757. *
  27758. * _.isLength(Infinity);
  27759. * // => false
  27760. *
  27761. * _.isLength('3');
  27762. * // => false
  27763. */
  27764. function isLength(value) {
  27765. return typeof value == 'number' &&
  27766. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27767. }
  27768. /**
  27769. * Checks if `value` is the
  27770. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27771. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27772. *
  27773. * @static
  27774. * @memberOf _
  27775. * @since 0.1.0
  27776. * @category Lang
  27777. * @param {*} value The value to check.
  27778. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27779. * @example
  27780. *
  27781. * _.isObject({});
  27782. * // => true
  27783. *
  27784. * _.isObject([1, 2, 3]);
  27785. * // => true
  27786. *
  27787. * _.isObject(_.noop);
  27788. * // => true
  27789. *
  27790. * _.isObject(null);
  27791. * // => false
  27792. */
  27793. function isObject(value) {
  27794. var type = typeof value;
  27795. return value != null && (type == 'object' || type == 'function');
  27796. }
  27797. /**
  27798. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27799. * and has a `typeof` result of "object".
  27800. *
  27801. * @static
  27802. * @memberOf _
  27803. * @since 4.0.0
  27804. * @category Lang
  27805. * @param {*} value The value to check.
  27806. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27807. * @example
  27808. *
  27809. * _.isObjectLike({});
  27810. * // => true
  27811. *
  27812. * _.isObjectLike([1, 2, 3]);
  27813. * // => true
  27814. *
  27815. * _.isObjectLike(_.noop);
  27816. * // => false
  27817. *
  27818. * _.isObjectLike(null);
  27819. * // => false
  27820. */
  27821. function isObjectLike(value) {
  27822. return value != null && typeof value == 'object';
  27823. }
  27824. /**
  27825. * Checks if `value` is classified as a `Map` object.
  27826. *
  27827. * @static
  27828. * @memberOf _
  27829. * @since 4.3.0
  27830. * @category Lang
  27831. * @param {*} value The value to check.
  27832. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27833. * @example
  27834. *
  27835. * _.isMap(new Map);
  27836. * // => true
  27837. *
  27838. * _.isMap(new WeakMap);
  27839. * // => false
  27840. */
  27841. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27842. /**
  27843. * Performs a partial deep comparison between `object` and `source` to
  27844. * determine if `object` contains equivalent property values.
  27845. *
  27846. * **Note:** This method is equivalent to `_.matches` when `source` is
  27847. * partially applied.
  27848. *
  27849. * Partial comparisons will match empty array and empty object `source`
  27850. * values against any array or object value, respectively. See `_.isEqual`
  27851. * for a list of supported value comparisons.
  27852. *
  27853. * @static
  27854. * @memberOf _
  27855. * @since 3.0.0
  27856. * @category Lang
  27857. * @param {Object} object The object to inspect.
  27858. * @param {Object} source The object of property values to match.
  27859. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27860. * @example
  27861. *
  27862. * var object = { 'a': 1, 'b': 2 };
  27863. *
  27864. * _.isMatch(object, { 'b': 2 });
  27865. * // => true
  27866. *
  27867. * _.isMatch(object, { 'b': 1 });
  27868. * // => false
  27869. */
  27870. function isMatch(object, source) {
  27871. return object === source || baseIsMatch(object, source, getMatchData(source));
  27872. }
  27873. /**
  27874. * This method is like `_.isMatch` except that it accepts `customizer` which
  27875. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27876. * are handled by the method instead. The `customizer` is invoked with five
  27877. * arguments: (objValue, srcValue, index|key, object, source).
  27878. *
  27879. * @static
  27880. * @memberOf _
  27881. * @since 4.0.0
  27882. * @category Lang
  27883. * @param {Object} object The object to inspect.
  27884. * @param {Object} source The object of property values to match.
  27885. * @param {Function} [customizer] The function to customize comparisons.
  27886. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27887. * @example
  27888. *
  27889. * function isGreeting(value) {
  27890. * return /^h(?:i|ello)$/.test(value);
  27891. * }
  27892. *
  27893. * function customizer(objValue, srcValue) {
  27894. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27895. * return true;
  27896. * }
  27897. * }
  27898. *
  27899. * var object = { 'greeting': 'hello' };
  27900. * var source = { 'greeting': 'hi' };
  27901. *
  27902. * _.isMatchWith(object, source, customizer);
  27903. * // => true
  27904. */
  27905. function isMatchWith(object, source, customizer) {
  27906. customizer = typeof customizer == 'function' ? customizer : undefined;
  27907. return baseIsMatch(object, source, getMatchData(source), customizer);
  27908. }
  27909. /**
  27910. * Checks if `value` is `NaN`.
  27911. *
  27912. * **Note:** This method is based on
  27913. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27914. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27915. * `undefined` and other non-number values.
  27916. *
  27917. * @static
  27918. * @memberOf _
  27919. * @since 0.1.0
  27920. * @category Lang
  27921. * @param {*} value The value to check.
  27922. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27923. * @example
  27924. *
  27925. * _.isNaN(NaN);
  27926. * // => true
  27927. *
  27928. * _.isNaN(new Number(NaN));
  27929. * // => true
  27930. *
  27931. * isNaN(undefined);
  27932. * // => true
  27933. *
  27934. * _.isNaN(undefined);
  27935. * // => false
  27936. */
  27937. function isNaN(value) {
  27938. // An `NaN` primitive is the only value that is not equal to itself.
  27939. // Perform the `toStringTag` check first to avoid errors with some
  27940. // ActiveX objects in IE.
  27941. return isNumber(value) && value != +value;
  27942. }
  27943. /**
  27944. * Checks if `value` is a pristine native function.
  27945. *
  27946. * **Note:** This method can't reliably detect native functions in the presence
  27947. * of the core-js package because core-js circumvents this kind of detection.
  27948. * Despite multiple requests, the core-js maintainer has made it clear: any
  27949. * attempt to fix the detection will be obstructed. As a result, we're left
  27950. * with little choice but to throw an error. Unfortunately, this also affects
  27951. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27952. * which rely on core-js.
  27953. *
  27954. * @static
  27955. * @memberOf _
  27956. * @since 3.0.0
  27957. * @category Lang
  27958. * @param {*} value The value to check.
  27959. * @returns {boolean} Returns `true` if `value` is a native function,
  27960. * else `false`.
  27961. * @example
  27962. *
  27963. * _.isNative(Array.prototype.push);
  27964. * // => true
  27965. *
  27966. * _.isNative(_);
  27967. * // => false
  27968. */
  27969. function isNative(value) {
  27970. if (isMaskable(value)) {
  27971. throw new Error(CORE_ERROR_TEXT);
  27972. }
  27973. return baseIsNative(value);
  27974. }
  27975. /**
  27976. * Checks if `value` is `null`.
  27977. *
  27978. * @static
  27979. * @memberOf _
  27980. * @since 0.1.0
  27981. * @category Lang
  27982. * @param {*} value The value to check.
  27983. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  27984. * @example
  27985. *
  27986. * _.isNull(null);
  27987. * // => true
  27988. *
  27989. * _.isNull(void 0);
  27990. * // => false
  27991. */
  27992. function isNull(value) {
  27993. return value === null;
  27994. }
  27995. /**
  27996. * Checks if `value` is `null` or `undefined`.
  27997. *
  27998. * @static
  27999. * @memberOf _
  28000. * @since 4.0.0
  28001. * @category Lang
  28002. * @param {*} value The value to check.
  28003. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28004. * @example
  28005. *
  28006. * _.isNil(null);
  28007. * // => true
  28008. *
  28009. * _.isNil(void 0);
  28010. * // => true
  28011. *
  28012. * _.isNil(NaN);
  28013. * // => false
  28014. */
  28015. function isNil(value) {
  28016. return value == null;
  28017. }
  28018. /**
  28019. * Checks if `value` is classified as a `Number` primitive or object.
  28020. *
  28021. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28022. * classified as numbers, use the `_.isFinite` method.
  28023. *
  28024. * @static
  28025. * @memberOf _
  28026. * @since 0.1.0
  28027. * @category Lang
  28028. * @param {*} value The value to check.
  28029. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28030. * @example
  28031. *
  28032. * _.isNumber(3);
  28033. * // => true
  28034. *
  28035. * _.isNumber(Number.MIN_VALUE);
  28036. * // => true
  28037. *
  28038. * _.isNumber(Infinity);
  28039. * // => true
  28040. *
  28041. * _.isNumber('3');
  28042. * // => false
  28043. */
  28044. function isNumber(value) {
  28045. return typeof value == 'number' ||
  28046. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28047. }
  28048. /**
  28049. * Checks if `value` is a plain object, that is, an object created by the
  28050. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28051. *
  28052. * @static
  28053. * @memberOf _
  28054. * @since 0.8.0
  28055. * @category Lang
  28056. * @param {*} value The value to check.
  28057. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28058. * @example
  28059. *
  28060. * function Foo() {
  28061. * this.a = 1;
  28062. * }
  28063. *
  28064. * _.isPlainObject(new Foo);
  28065. * // => false
  28066. *
  28067. * _.isPlainObject([1, 2, 3]);
  28068. * // => false
  28069. *
  28070. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28071. * // => true
  28072. *
  28073. * _.isPlainObject(Object.create(null));
  28074. * // => true
  28075. */
  28076. function isPlainObject(value) {
  28077. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28078. return false;
  28079. }
  28080. var proto = getPrototype(value);
  28081. if (proto === null) {
  28082. return true;
  28083. }
  28084. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28085. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28086. funcToString.call(Ctor) == objectCtorString;
  28087. }
  28088. /**
  28089. * Checks if `value` is classified as a `RegExp` object.
  28090. *
  28091. * @static
  28092. * @memberOf _
  28093. * @since 0.1.0
  28094. * @category Lang
  28095. * @param {*} value The value to check.
  28096. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28097. * @example
  28098. *
  28099. * _.isRegExp(/abc/);
  28100. * // => true
  28101. *
  28102. * _.isRegExp('/abc/');
  28103. * // => false
  28104. */
  28105. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28106. /**
  28107. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28108. * double precision number which isn't the result of a rounded unsafe integer.
  28109. *
  28110. * **Note:** This method is based on
  28111. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28112. *
  28113. * @static
  28114. * @memberOf _
  28115. * @since 4.0.0
  28116. * @category Lang
  28117. * @param {*} value The value to check.
  28118. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28119. * @example
  28120. *
  28121. * _.isSafeInteger(3);
  28122. * // => true
  28123. *
  28124. * _.isSafeInteger(Number.MIN_VALUE);
  28125. * // => false
  28126. *
  28127. * _.isSafeInteger(Infinity);
  28128. * // => false
  28129. *
  28130. * _.isSafeInteger('3');
  28131. * // => false
  28132. */
  28133. function isSafeInteger(value) {
  28134. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28135. }
  28136. /**
  28137. * Checks if `value` is classified as a `Set` object.
  28138. *
  28139. * @static
  28140. * @memberOf _
  28141. * @since 4.3.0
  28142. * @category Lang
  28143. * @param {*} value The value to check.
  28144. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28145. * @example
  28146. *
  28147. * _.isSet(new Set);
  28148. * // => true
  28149. *
  28150. * _.isSet(new WeakSet);
  28151. * // => false
  28152. */
  28153. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28154. /**
  28155. * Checks if `value` is classified as a `String` primitive or object.
  28156. *
  28157. * @static
  28158. * @since 0.1.0
  28159. * @memberOf _
  28160. * @category Lang
  28161. * @param {*} value The value to check.
  28162. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28163. * @example
  28164. *
  28165. * _.isString('abc');
  28166. * // => true
  28167. *
  28168. * _.isString(1);
  28169. * // => false
  28170. */
  28171. function isString(value) {
  28172. return typeof value == 'string' ||
  28173. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28174. }
  28175. /**
  28176. * Checks if `value` is classified as a `Symbol` primitive or object.
  28177. *
  28178. * @static
  28179. * @memberOf _
  28180. * @since 4.0.0
  28181. * @category Lang
  28182. * @param {*} value The value to check.
  28183. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28184. * @example
  28185. *
  28186. * _.isSymbol(Symbol.iterator);
  28187. * // => true
  28188. *
  28189. * _.isSymbol('abc');
  28190. * // => false
  28191. */
  28192. function isSymbol(value) {
  28193. return typeof value == 'symbol' ||
  28194. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28195. }
  28196. /**
  28197. * Checks if `value` is classified as a typed array.
  28198. *
  28199. * @static
  28200. * @memberOf _
  28201. * @since 3.0.0
  28202. * @category Lang
  28203. * @param {*} value The value to check.
  28204. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28205. * @example
  28206. *
  28207. * _.isTypedArray(new Uint8Array);
  28208. * // => true
  28209. *
  28210. * _.isTypedArray([]);
  28211. * // => false
  28212. */
  28213. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28214. /**
  28215. * Checks if `value` is `undefined`.
  28216. *
  28217. * @static
  28218. * @since 0.1.0
  28219. * @memberOf _
  28220. * @category Lang
  28221. * @param {*} value The value to check.
  28222. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28223. * @example
  28224. *
  28225. * _.isUndefined(void 0);
  28226. * // => true
  28227. *
  28228. * _.isUndefined(null);
  28229. * // => false
  28230. */
  28231. function isUndefined(value) {
  28232. return value === undefined;
  28233. }
  28234. /**
  28235. * Checks if `value` is classified as a `WeakMap` object.
  28236. *
  28237. * @static
  28238. * @memberOf _
  28239. * @since 4.3.0
  28240. * @category Lang
  28241. * @param {*} value The value to check.
  28242. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28243. * @example
  28244. *
  28245. * _.isWeakMap(new WeakMap);
  28246. * // => true
  28247. *
  28248. * _.isWeakMap(new Map);
  28249. * // => false
  28250. */
  28251. function isWeakMap(value) {
  28252. return isObjectLike(value) && getTag(value) == weakMapTag;
  28253. }
  28254. /**
  28255. * Checks if `value` is classified as a `WeakSet` object.
  28256. *
  28257. * @static
  28258. * @memberOf _
  28259. * @since 4.3.0
  28260. * @category Lang
  28261. * @param {*} value The value to check.
  28262. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28263. * @example
  28264. *
  28265. * _.isWeakSet(new WeakSet);
  28266. * // => true
  28267. *
  28268. * _.isWeakSet(new Set);
  28269. * // => false
  28270. */
  28271. function isWeakSet(value) {
  28272. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28273. }
  28274. /**
  28275. * Checks if `value` is less than `other`.
  28276. *
  28277. * @static
  28278. * @memberOf _
  28279. * @since 3.9.0
  28280. * @category Lang
  28281. * @param {*} value The value to compare.
  28282. * @param {*} other The other value to compare.
  28283. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28284. * else `false`.
  28285. * @see _.gt
  28286. * @example
  28287. *
  28288. * _.lt(1, 3);
  28289. * // => true
  28290. *
  28291. * _.lt(3, 3);
  28292. * // => false
  28293. *
  28294. * _.lt(3, 1);
  28295. * // => false
  28296. */
  28297. var lt = createRelationalOperation(baseLt);
  28298. /**
  28299. * Checks if `value` is less than or equal to `other`.
  28300. *
  28301. * @static
  28302. * @memberOf _
  28303. * @since 3.9.0
  28304. * @category Lang
  28305. * @param {*} value The value to compare.
  28306. * @param {*} other The other value to compare.
  28307. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28308. * `other`, else `false`.
  28309. * @see _.gte
  28310. * @example
  28311. *
  28312. * _.lte(1, 3);
  28313. * // => true
  28314. *
  28315. * _.lte(3, 3);
  28316. * // => true
  28317. *
  28318. * _.lte(3, 1);
  28319. * // => false
  28320. */
  28321. var lte = createRelationalOperation(function(value, other) {
  28322. return value <= other;
  28323. });
  28324. /**
  28325. * Converts `value` to an array.
  28326. *
  28327. * @static
  28328. * @since 0.1.0
  28329. * @memberOf _
  28330. * @category Lang
  28331. * @param {*} value The value to convert.
  28332. * @returns {Array} Returns the converted array.
  28333. * @example
  28334. *
  28335. * _.toArray({ 'a': 1, 'b': 2 });
  28336. * // => [1, 2]
  28337. *
  28338. * _.toArray('abc');
  28339. * // => ['a', 'b', 'c']
  28340. *
  28341. * _.toArray(1);
  28342. * // => []
  28343. *
  28344. * _.toArray(null);
  28345. * // => []
  28346. */
  28347. function toArray(value) {
  28348. if (!value) {
  28349. return [];
  28350. }
  28351. if (isArrayLike(value)) {
  28352. return isString(value) ? stringToArray(value) : copyArray(value);
  28353. }
  28354. if (symIterator && value[symIterator]) {
  28355. return iteratorToArray(value[symIterator]());
  28356. }
  28357. var tag = getTag(value),
  28358. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28359. return func(value);
  28360. }
  28361. /**
  28362. * Converts `value` to a finite number.
  28363. *
  28364. * @static
  28365. * @memberOf _
  28366. * @since 4.12.0
  28367. * @category Lang
  28368. * @param {*} value The value to convert.
  28369. * @returns {number} Returns the converted number.
  28370. * @example
  28371. *
  28372. * _.toFinite(3.2);
  28373. * // => 3.2
  28374. *
  28375. * _.toFinite(Number.MIN_VALUE);
  28376. * // => 5e-324
  28377. *
  28378. * _.toFinite(Infinity);
  28379. * // => 1.7976931348623157e+308
  28380. *
  28381. * _.toFinite('3.2');
  28382. * // => 3.2
  28383. */
  28384. function toFinite(value) {
  28385. if (!value) {
  28386. return value === 0 ? value : 0;
  28387. }
  28388. value = toNumber(value);
  28389. if (value === INFINITY || value === -INFINITY) {
  28390. var sign = (value < 0 ? -1 : 1);
  28391. return sign * MAX_INTEGER;
  28392. }
  28393. return value === value ? value : 0;
  28394. }
  28395. /**
  28396. * Converts `value` to an integer.
  28397. *
  28398. * **Note:** This method is loosely based on
  28399. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  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. * _.toInteger(3.2);
  28410. * // => 3
  28411. *
  28412. * _.toInteger(Number.MIN_VALUE);
  28413. * // => 0
  28414. *
  28415. * _.toInteger(Infinity);
  28416. * // => 1.7976931348623157e+308
  28417. *
  28418. * _.toInteger('3.2');
  28419. * // => 3
  28420. */
  28421. function toInteger(value) {
  28422. var result = toFinite(value),
  28423. remainder = result % 1;
  28424. return result === result ? (remainder ? result - remainder : result) : 0;
  28425. }
  28426. /**
  28427. * Converts `value` to an integer suitable for use as the length of an
  28428. * array-like object.
  28429. *
  28430. * **Note:** This method is based on
  28431. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28432. *
  28433. * @static
  28434. * @memberOf _
  28435. * @since 4.0.0
  28436. * @category Lang
  28437. * @param {*} value The value to convert.
  28438. * @returns {number} Returns the converted integer.
  28439. * @example
  28440. *
  28441. * _.toLength(3.2);
  28442. * // => 3
  28443. *
  28444. * _.toLength(Number.MIN_VALUE);
  28445. * // => 0
  28446. *
  28447. * _.toLength(Infinity);
  28448. * // => 4294967295
  28449. *
  28450. * _.toLength('3.2');
  28451. * // => 3
  28452. */
  28453. function toLength(value) {
  28454. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28455. }
  28456. /**
  28457. * Converts `value` to a number.
  28458. *
  28459. * @static
  28460. * @memberOf _
  28461. * @since 4.0.0
  28462. * @category Lang
  28463. * @param {*} value The value to process.
  28464. * @returns {number} Returns the number.
  28465. * @example
  28466. *
  28467. * _.toNumber(3.2);
  28468. * // => 3.2
  28469. *
  28470. * _.toNumber(Number.MIN_VALUE);
  28471. * // => 5e-324
  28472. *
  28473. * _.toNumber(Infinity);
  28474. * // => Infinity
  28475. *
  28476. * _.toNumber('3.2');
  28477. * // => 3.2
  28478. */
  28479. function toNumber(value) {
  28480. if (typeof value == 'number') {
  28481. return value;
  28482. }
  28483. if (isSymbol(value)) {
  28484. return NAN;
  28485. }
  28486. if (isObject(value)) {
  28487. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28488. value = isObject(other) ? (other + '') : other;
  28489. }
  28490. if (typeof value != 'string') {
  28491. return value === 0 ? value : +value;
  28492. }
  28493. value = value.replace(reTrim, '');
  28494. var isBinary = reIsBinary.test(value);
  28495. return (isBinary || reIsOctal.test(value))
  28496. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28497. : (reIsBadHex.test(value) ? NAN : +value);
  28498. }
  28499. /**
  28500. * Converts `value` to a plain object flattening inherited enumerable string
  28501. * keyed properties of `value` to own properties of the plain object.
  28502. *
  28503. * @static
  28504. * @memberOf _
  28505. * @since 3.0.0
  28506. * @category Lang
  28507. * @param {*} value The value to convert.
  28508. * @returns {Object} Returns the converted plain object.
  28509. * @example
  28510. *
  28511. * function Foo() {
  28512. * this.b = 2;
  28513. * }
  28514. *
  28515. * Foo.prototype.c = 3;
  28516. *
  28517. * _.assign({ 'a': 1 }, new Foo);
  28518. * // => { 'a': 1, 'b': 2 }
  28519. *
  28520. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28521. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28522. */
  28523. function toPlainObject(value) {
  28524. return copyObject(value, keysIn(value));
  28525. }
  28526. /**
  28527. * Converts `value` to a safe integer. A safe integer can be compared and
  28528. * represented correctly.
  28529. *
  28530. * @static
  28531. * @memberOf _
  28532. * @since 4.0.0
  28533. * @category Lang
  28534. * @param {*} value The value to convert.
  28535. * @returns {number} Returns the converted integer.
  28536. * @example
  28537. *
  28538. * _.toSafeInteger(3.2);
  28539. * // => 3
  28540. *
  28541. * _.toSafeInteger(Number.MIN_VALUE);
  28542. * // => 0
  28543. *
  28544. * _.toSafeInteger(Infinity);
  28545. * // => 9007199254740991
  28546. *
  28547. * _.toSafeInteger('3.2');
  28548. * // => 3
  28549. */
  28550. function toSafeInteger(value) {
  28551. return value
  28552. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28553. : (value === 0 ? value : 0);
  28554. }
  28555. /**
  28556. * Converts `value` to a string. An empty string is returned for `null`
  28557. * and `undefined` values. The sign of `-0` is preserved.
  28558. *
  28559. * @static
  28560. * @memberOf _
  28561. * @since 4.0.0
  28562. * @category Lang
  28563. * @param {*} value The value to convert.
  28564. * @returns {string} Returns the converted string.
  28565. * @example
  28566. *
  28567. * _.toString(null);
  28568. * // => ''
  28569. *
  28570. * _.toString(-0);
  28571. * // => '-0'
  28572. *
  28573. * _.toString([1, 2, 3]);
  28574. * // => '1,2,3'
  28575. */
  28576. function toString(value) {
  28577. return value == null ? '' : baseToString(value);
  28578. }
  28579. /*------------------------------------------------------------------------*/
  28580. /**
  28581. * Assigns own enumerable string keyed properties of source objects to the
  28582. * destination object. Source objects are applied from left to right.
  28583. * Subsequent sources overwrite property assignments of previous sources.
  28584. *
  28585. * **Note:** This method mutates `object` and is loosely based on
  28586. * [`Object.assign`](https://mdn.io/Object/assign).
  28587. *
  28588. * @static
  28589. * @memberOf _
  28590. * @since 0.10.0
  28591. * @category Object
  28592. * @param {Object} object The destination object.
  28593. * @param {...Object} [sources] The source objects.
  28594. * @returns {Object} Returns `object`.
  28595. * @see _.assignIn
  28596. * @example
  28597. *
  28598. * function Foo() {
  28599. * this.a = 1;
  28600. * }
  28601. *
  28602. * function Bar() {
  28603. * this.c = 3;
  28604. * }
  28605. *
  28606. * Foo.prototype.b = 2;
  28607. * Bar.prototype.d = 4;
  28608. *
  28609. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28610. * // => { 'a': 1, 'c': 3 }
  28611. */
  28612. var assign = createAssigner(function(object, source) {
  28613. if (isPrototype(source) || isArrayLike(source)) {
  28614. copyObject(source, keys(source), object);
  28615. return;
  28616. }
  28617. for (var key in source) {
  28618. if (hasOwnProperty.call(source, key)) {
  28619. assignValue(object, key, source[key]);
  28620. }
  28621. }
  28622. });
  28623. /**
  28624. * This method is like `_.assign` except that it iterates over own and
  28625. * inherited source properties.
  28626. *
  28627. * **Note:** This method mutates `object`.
  28628. *
  28629. * @static
  28630. * @memberOf _
  28631. * @since 4.0.0
  28632. * @alias extend
  28633. * @category Object
  28634. * @param {Object} object The destination object.
  28635. * @param {...Object} [sources] The source objects.
  28636. * @returns {Object} Returns `object`.
  28637. * @see _.assign
  28638. * @example
  28639. *
  28640. * function Foo() {
  28641. * this.a = 1;
  28642. * }
  28643. *
  28644. * function Bar() {
  28645. * this.c = 3;
  28646. * }
  28647. *
  28648. * Foo.prototype.b = 2;
  28649. * Bar.prototype.d = 4;
  28650. *
  28651. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28652. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28653. */
  28654. var assignIn = createAssigner(function(object, source) {
  28655. copyObject(source, keysIn(source), object);
  28656. });
  28657. /**
  28658. * This method is like `_.assignIn` 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. * @alias extendWith
  28669. * @category Object
  28670. * @param {Object} object The destination object.
  28671. * @param {...Object} sources The source objects.
  28672. * @param {Function} [customizer] The function to customize assigned values.
  28673. * @returns {Object} Returns `object`.
  28674. * @see _.assignWith
  28675. * @example
  28676. *
  28677. * function customizer(objValue, srcValue) {
  28678. * return _.isUndefined(objValue) ? srcValue : objValue;
  28679. * }
  28680. *
  28681. * var defaults = _.partialRight(_.assignInWith, customizer);
  28682. *
  28683. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28684. * // => { 'a': 1, 'b': 2 }
  28685. */
  28686. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28687. copyObject(source, keysIn(source), object, customizer);
  28688. });
  28689. /**
  28690. * This method is like `_.assign` except that it accepts `customizer`
  28691. * which is invoked to produce the assigned values. If `customizer` returns
  28692. * `undefined`, assignment is handled by the method instead. The `customizer`
  28693. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28694. *
  28695. * **Note:** This method mutates `object`.
  28696. *
  28697. * @static
  28698. * @memberOf _
  28699. * @since 4.0.0
  28700. * @category Object
  28701. * @param {Object} object The destination object.
  28702. * @param {...Object} sources The source objects.
  28703. * @param {Function} [customizer] The function to customize assigned values.
  28704. * @returns {Object} Returns `object`.
  28705. * @see _.assignInWith
  28706. * @example
  28707. *
  28708. * function customizer(objValue, srcValue) {
  28709. * return _.isUndefined(objValue) ? srcValue : objValue;
  28710. * }
  28711. *
  28712. * var defaults = _.partialRight(_.assignWith, customizer);
  28713. *
  28714. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28715. * // => { 'a': 1, 'b': 2 }
  28716. */
  28717. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28718. copyObject(source, keys(source), object, customizer);
  28719. });
  28720. /**
  28721. * Creates an array of values corresponding to `paths` of `object`.
  28722. *
  28723. * @static
  28724. * @memberOf _
  28725. * @since 1.0.0
  28726. * @category Object
  28727. * @param {Object} object The object to iterate over.
  28728. * @param {...(string|string[])} [paths] The property paths to pick.
  28729. * @returns {Array} Returns the picked values.
  28730. * @example
  28731. *
  28732. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28733. *
  28734. * _.at(object, ['a[0].b.c', 'a[1]']);
  28735. * // => [3, 4]
  28736. */
  28737. var at = flatRest(baseAt);
  28738. /**
  28739. * Creates an object that inherits from the `prototype` object. If a
  28740. * `properties` object is given, its own enumerable string keyed properties
  28741. * are assigned to the created object.
  28742. *
  28743. * @static
  28744. * @memberOf _
  28745. * @since 2.3.0
  28746. * @category Object
  28747. * @param {Object} prototype The object to inherit from.
  28748. * @param {Object} [properties] The properties to assign to the object.
  28749. * @returns {Object} Returns the new object.
  28750. * @example
  28751. *
  28752. * function Shape() {
  28753. * this.x = 0;
  28754. * this.y = 0;
  28755. * }
  28756. *
  28757. * function Circle() {
  28758. * Shape.call(this);
  28759. * }
  28760. *
  28761. * Circle.prototype = _.create(Shape.prototype, {
  28762. * 'constructor': Circle
  28763. * });
  28764. *
  28765. * var circle = new Circle;
  28766. * circle instanceof Circle;
  28767. * // => true
  28768. *
  28769. * circle instanceof Shape;
  28770. * // => true
  28771. */
  28772. function create(prototype, properties) {
  28773. var result = baseCreate(prototype);
  28774. return properties == null ? result : baseAssign(result, properties);
  28775. }
  28776. /**
  28777. * Assigns own and inherited enumerable string keyed properties of source
  28778. * objects to the destination object for all destination properties that
  28779. * resolve to `undefined`. Source objects are applied from left to right.
  28780. * Once a property is set, additional values of the same property are ignored.
  28781. *
  28782. * **Note:** This method mutates `object`.
  28783. *
  28784. * @static
  28785. * @since 0.1.0
  28786. * @memberOf _
  28787. * @category Object
  28788. * @param {Object} object The destination object.
  28789. * @param {...Object} [sources] The source objects.
  28790. * @returns {Object} Returns `object`.
  28791. * @see _.defaultsDeep
  28792. * @example
  28793. *
  28794. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28795. * // => { 'a': 1, 'b': 2 }
  28796. */
  28797. var defaults = baseRest(function(object, sources) {
  28798. object = Object(object);
  28799. var index = -1;
  28800. var length = sources.length;
  28801. var guard = length > 2 ? sources[2] : undefined;
  28802. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28803. length = 1;
  28804. }
  28805. while (++index < length) {
  28806. var source = sources[index];
  28807. var props = keysIn(source);
  28808. var propsIndex = -1;
  28809. var propsLength = props.length;
  28810. while (++propsIndex < propsLength) {
  28811. var key = props[propsIndex];
  28812. var value = object[key];
  28813. if (value === undefined ||
  28814. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28815. object[key] = source[key];
  28816. }
  28817. }
  28818. }
  28819. return object;
  28820. });
  28821. /**
  28822. * This method is like `_.defaults` except that it recursively assigns
  28823. * default properties.
  28824. *
  28825. * **Note:** This method mutates `object`.
  28826. *
  28827. * @static
  28828. * @memberOf _
  28829. * @since 3.10.0
  28830. * @category Object
  28831. * @param {Object} object The destination object.
  28832. * @param {...Object} [sources] The source objects.
  28833. * @returns {Object} Returns `object`.
  28834. * @see _.defaults
  28835. * @example
  28836. *
  28837. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28838. * // => { 'a': { 'b': 2, 'c': 3 } }
  28839. */
  28840. var defaultsDeep = baseRest(function(args) {
  28841. args.push(undefined, customDefaultsMerge);
  28842. return apply(mergeWith, undefined, args);
  28843. });
  28844. /**
  28845. * This method is like `_.find` except that it returns the key of the first
  28846. * element `predicate` returns truthy for instead of the element itself.
  28847. *
  28848. * @static
  28849. * @memberOf _
  28850. * @since 1.1.0
  28851. * @category Object
  28852. * @param {Object} object The object to inspect.
  28853. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28854. * @returns {string|undefined} Returns the key of the matched element,
  28855. * else `undefined`.
  28856. * @example
  28857. *
  28858. * var users = {
  28859. * 'barney': { 'age': 36, 'active': true },
  28860. * 'fred': { 'age': 40, 'active': false },
  28861. * 'pebbles': { 'age': 1, 'active': true }
  28862. * };
  28863. *
  28864. * _.findKey(users, function(o) { return o.age < 40; });
  28865. * // => 'barney' (iteration order is not guaranteed)
  28866. *
  28867. * // The `_.matches` iteratee shorthand.
  28868. * _.findKey(users, { 'age': 1, 'active': true });
  28869. * // => 'pebbles'
  28870. *
  28871. * // The `_.matchesProperty` iteratee shorthand.
  28872. * _.findKey(users, ['active', false]);
  28873. * // => 'fred'
  28874. *
  28875. * // The `_.property` iteratee shorthand.
  28876. * _.findKey(users, 'active');
  28877. * // => 'barney'
  28878. */
  28879. function findKey(object, predicate) {
  28880. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28881. }
  28882. /**
  28883. * This method is like `_.findKey` except that it iterates over elements of
  28884. * a collection in the opposite order.
  28885. *
  28886. * @static
  28887. * @memberOf _
  28888. * @since 2.0.0
  28889. * @category Object
  28890. * @param {Object} object The object to inspect.
  28891. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28892. * @returns {string|undefined} Returns the key of the matched element,
  28893. * else `undefined`.
  28894. * @example
  28895. *
  28896. * var users = {
  28897. * 'barney': { 'age': 36, 'active': true },
  28898. * 'fred': { 'age': 40, 'active': false },
  28899. * 'pebbles': { 'age': 1, 'active': true }
  28900. * };
  28901. *
  28902. * _.findLastKey(users, function(o) { return o.age < 40; });
  28903. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28904. *
  28905. * // The `_.matches` iteratee shorthand.
  28906. * _.findLastKey(users, { 'age': 36, 'active': true });
  28907. * // => 'barney'
  28908. *
  28909. * // The `_.matchesProperty` iteratee shorthand.
  28910. * _.findLastKey(users, ['active', false]);
  28911. * // => 'fred'
  28912. *
  28913. * // The `_.property` iteratee shorthand.
  28914. * _.findLastKey(users, 'active');
  28915. * // => 'pebbles'
  28916. */
  28917. function findLastKey(object, predicate) {
  28918. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28919. }
  28920. /**
  28921. * Iterates over own and inherited enumerable string keyed properties of an
  28922. * object and invokes `iteratee` for each property. The iteratee is invoked
  28923. * with three arguments: (value, key, object). Iteratee functions may exit
  28924. * iteration early by explicitly returning `false`.
  28925. *
  28926. * @static
  28927. * @memberOf _
  28928. * @since 0.3.0
  28929. * @category Object
  28930. * @param {Object} object The object to iterate over.
  28931. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28932. * @returns {Object} Returns `object`.
  28933. * @see _.forInRight
  28934. * @example
  28935. *
  28936. * function Foo() {
  28937. * this.a = 1;
  28938. * this.b = 2;
  28939. * }
  28940. *
  28941. * Foo.prototype.c = 3;
  28942. *
  28943. * _.forIn(new Foo, function(value, key) {
  28944. * console.log(key);
  28945. * });
  28946. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28947. */
  28948. function forIn(object, iteratee) {
  28949. return object == null
  28950. ? object
  28951. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28952. }
  28953. /**
  28954. * This method is like `_.forIn` except that it iterates over properties of
  28955. * `object` in the opposite order.
  28956. *
  28957. * @static
  28958. * @memberOf _
  28959. * @since 2.0.0
  28960. * @category Object
  28961. * @param {Object} object The object to iterate over.
  28962. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28963. * @returns {Object} Returns `object`.
  28964. * @see _.forIn
  28965. * @example
  28966. *
  28967. * function Foo() {
  28968. * this.a = 1;
  28969. * this.b = 2;
  28970. * }
  28971. *
  28972. * Foo.prototype.c = 3;
  28973. *
  28974. * _.forInRight(new Foo, function(value, key) {
  28975. * console.log(key);
  28976. * });
  28977. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  28978. */
  28979. function forInRight(object, iteratee) {
  28980. return object == null
  28981. ? object
  28982. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  28983. }
  28984. /**
  28985. * Iterates over own enumerable string keyed properties of an object and
  28986. * invokes `iteratee` for each property. The iteratee is invoked with three
  28987. * arguments: (value, key, object). Iteratee functions may exit iteration
  28988. * early by explicitly returning `false`.
  28989. *
  28990. * @static
  28991. * @memberOf _
  28992. * @since 0.3.0
  28993. * @category Object
  28994. * @param {Object} object The object to iterate over.
  28995. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28996. * @returns {Object} Returns `object`.
  28997. * @see _.forOwnRight
  28998. * @example
  28999. *
  29000. * function Foo() {
  29001. * this.a = 1;
  29002. * this.b = 2;
  29003. * }
  29004. *
  29005. * Foo.prototype.c = 3;
  29006. *
  29007. * _.forOwn(new Foo, function(value, key) {
  29008. * console.log(key);
  29009. * });
  29010. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29011. */
  29012. function forOwn(object, iteratee) {
  29013. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29014. }
  29015. /**
  29016. * This method is like `_.forOwn` except that it iterates over properties of
  29017. * `object` in the opposite order.
  29018. *
  29019. * @static
  29020. * @memberOf _
  29021. * @since 2.0.0
  29022. * @category Object
  29023. * @param {Object} object The object to iterate over.
  29024. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29025. * @returns {Object} Returns `object`.
  29026. * @see _.forOwn
  29027. * @example
  29028. *
  29029. * function Foo() {
  29030. * this.a = 1;
  29031. * this.b = 2;
  29032. * }
  29033. *
  29034. * Foo.prototype.c = 3;
  29035. *
  29036. * _.forOwnRight(new Foo, function(value, key) {
  29037. * console.log(key);
  29038. * });
  29039. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29040. */
  29041. function forOwnRight(object, iteratee) {
  29042. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29043. }
  29044. /**
  29045. * Creates an array of function property names from own enumerable properties
  29046. * of `object`.
  29047. *
  29048. * @static
  29049. * @since 0.1.0
  29050. * @memberOf _
  29051. * @category Object
  29052. * @param {Object} object The object to inspect.
  29053. * @returns {Array} Returns the function names.
  29054. * @see _.functionsIn
  29055. * @example
  29056. *
  29057. * function Foo() {
  29058. * this.a = _.constant('a');
  29059. * this.b = _.constant('b');
  29060. * }
  29061. *
  29062. * Foo.prototype.c = _.constant('c');
  29063. *
  29064. * _.functions(new Foo);
  29065. * // => ['a', 'b']
  29066. */
  29067. function functions(object) {
  29068. return object == null ? [] : baseFunctions(object, keys(object));
  29069. }
  29070. /**
  29071. * Creates an array of function property names from own and inherited
  29072. * enumerable properties of `object`.
  29073. *
  29074. * @static
  29075. * @memberOf _
  29076. * @since 4.0.0
  29077. * @category Object
  29078. * @param {Object} object The object to inspect.
  29079. * @returns {Array} Returns the function names.
  29080. * @see _.functions
  29081. * @example
  29082. *
  29083. * function Foo() {
  29084. * this.a = _.constant('a');
  29085. * this.b = _.constant('b');
  29086. * }
  29087. *
  29088. * Foo.prototype.c = _.constant('c');
  29089. *
  29090. * _.functionsIn(new Foo);
  29091. * // => ['a', 'b', 'c']
  29092. */
  29093. function functionsIn(object) {
  29094. return object == null ? [] : baseFunctions(object, keysIn(object));
  29095. }
  29096. /**
  29097. * Gets the value at `path` of `object`. If the resolved value is
  29098. * `undefined`, the `defaultValue` is returned in its place.
  29099. *
  29100. * @static
  29101. * @memberOf _
  29102. * @since 3.7.0
  29103. * @category Object
  29104. * @param {Object} object The object to query.
  29105. * @param {Array|string} path The path of the property to get.
  29106. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29107. * @returns {*} Returns the resolved value.
  29108. * @example
  29109. *
  29110. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29111. *
  29112. * _.get(object, 'a[0].b.c');
  29113. * // => 3
  29114. *
  29115. * _.get(object, ['a', '0', 'b', 'c']);
  29116. * // => 3
  29117. *
  29118. * _.get(object, 'a.b.c', 'default');
  29119. * // => 'default'
  29120. */
  29121. function get(object, path, defaultValue) {
  29122. var result = object == null ? undefined : baseGet(object, path);
  29123. return result === undefined ? defaultValue : result;
  29124. }
  29125. /**
  29126. * Checks if `path` is a direct property of `object`.
  29127. *
  29128. * @static
  29129. * @since 0.1.0
  29130. * @memberOf _
  29131. * @category Object
  29132. * @param {Object} object The object to query.
  29133. * @param {Array|string} path The path to check.
  29134. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29135. * @example
  29136. *
  29137. * var object = { 'a': { 'b': 2 } };
  29138. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29139. *
  29140. * _.has(object, 'a');
  29141. * // => true
  29142. *
  29143. * _.has(object, 'a.b');
  29144. * // => true
  29145. *
  29146. * _.has(object, ['a', 'b']);
  29147. * // => true
  29148. *
  29149. * _.has(other, 'a');
  29150. * // => false
  29151. */
  29152. function has(object, path) {
  29153. return object != null && hasPath(object, path, baseHas);
  29154. }
  29155. /**
  29156. * Checks if `path` is a direct or inherited property of `object`.
  29157. *
  29158. * @static
  29159. * @memberOf _
  29160. * @since 4.0.0
  29161. * @category Object
  29162. * @param {Object} object The object to query.
  29163. * @param {Array|string} path The path to check.
  29164. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29165. * @example
  29166. *
  29167. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29168. *
  29169. * _.hasIn(object, 'a');
  29170. * // => true
  29171. *
  29172. * _.hasIn(object, 'a.b');
  29173. * // => true
  29174. *
  29175. * _.hasIn(object, ['a', 'b']);
  29176. * // => true
  29177. *
  29178. * _.hasIn(object, 'b');
  29179. * // => false
  29180. */
  29181. function hasIn(object, path) {
  29182. return object != null && hasPath(object, path, baseHasIn);
  29183. }
  29184. /**
  29185. * Creates an object composed of the inverted keys and values of `object`.
  29186. * If `object` contains duplicate values, subsequent values overwrite
  29187. * property assignments of previous values.
  29188. *
  29189. * @static
  29190. * @memberOf _
  29191. * @since 0.7.0
  29192. * @category Object
  29193. * @param {Object} object The object to invert.
  29194. * @returns {Object} Returns the new inverted object.
  29195. * @example
  29196. *
  29197. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29198. *
  29199. * _.invert(object);
  29200. * // => { '1': 'c', '2': 'b' }
  29201. */
  29202. var invert = createInverter(function(result, value, key) {
  29203. if (value != null &&
  29204. typeof value.toString != 'function') {
  29205. value = nativeObjectToString.call(value);
  29206. }
  29207. result[value] = key;
  29208. }, constant(identity));
  29209. /**
  29210. * This method is like `_.invert` except that the inverted object is generated
  29211. * from the results of running each element of `object` thru `iteratee`. The
  29212. * corresponding inverted value of each inverted key is an array of keys
  29213. * responsible for generating the inverted value. The iteratee is invoked
  29214. * with one argument: (value).
  29215. *
  29216. * @static
  29217. * @memberOf _
  29218. * @since 4.1.0
  29219. * @category Object
  29220. * @param {Object} object The object to invert.
  29221. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29222. * @returns {Object} Returns the new inverted object.
  29223. * @example
  29224. *
  29225. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29226. *
  29227. * _.invertBy(object);
  29228. * // => { '1': ['a', 'c'], '2': ['b'] }
  29229. *
  29230. * _.invertBy(object, function(value) {
  29231. * return 'group' + value;
  29232. * });
  29233. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29234. */
  29235. var invertBy = createInverter(function(result, value, key) {
  29236. if (value != null &&
  29237. typeof value.toString != 'function') {
  29238. value = nativeObjectToString.call(value);
  29239. }
  29240. if (hasOwnProperty.call(result, value)) {
  29241. result[value].push(key);
  29242. } else {
  29243. result[value] = [key];
  29244. }
  29245. }, getIteratee);
  29246. /**
  29247. * Invokes the method at `path` of `object`.
  29248. *
  29249. * @static
  29250. * @memberOf _
  29251. * @since 4.0.0
  29252. * @category Object
  29253. * @param {Object} object The object to query.
  29254. * @param {Array|string} path The path of the method to invoke.
  29255. * @param {...*} [args] The arguments to invoke the method with.
  29256. * @returns {*} Returns the result of the invoked method.
  29257. * @example
  29258. *
  29259. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29260. *
  29261. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29262. * // => [2, 3]
  29263. */
  29264. var invoke = baseRest(baseInvoke);
  29265. /**
  29266. * Creates an array of the own enumerable property names of `object`.
  29267. *
  29268. * **Note:** Non-object values are coerced to objects. See the
  29269. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29270. * for more details.
  29271. *
  29272. * @static
  29273. * @since 0.1.0
  29274. * @memberOf _
  29275. * @category Object
  29276. * @param {Object} object The object to query.
  29277. * @returns {Array} Returns the array of property names.
  29278. * @example
  29279. *
  29280. * function Foo() {
  29281. * this.a = 1;
  29282. * this.b = 2;
  29283. * }
  29284. *
  29285. * Foo.prototype.c = 3;
  29286. *
  29287. * _.keys(new Foo);
  29288. * // => ['a', 'b'] (iteration order is not guaranteed)
  29289. *
  29290. * _.keys('hi');
  29291. * // => ['0', '1']
  29292. */
  29293. function keys(object) {
  29294. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29295. }
  29296. /**
  29297. * Creates an array of the own and inherited enumerable property names of `object`.
  29298. *
  29299. * **Note:** Non-object values are coerced to objects.
  29300. *
  29301. * @static
  29302. * @memberOf _
  29303. * @since 3.0.0
  29304. * @category Object
  29305. * @param {Object} object The object to query.
  29306. * @returns {Array} Returns the array of property names.
  29307. * @example
  29308. *
  29309. * function Foo() {
  29310. * this.a = 1;
  29311. * this.b = 2;
  29312. * }
  29313. *
  29314. * Foo.prototype.c = 3;
  29315. *
  29316. * _.keysIn(new Foo);
  29317. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29318. */
  29319. function keysIn(object) {
  29320. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29321. }
  29322. /**
  29323. * The opposite of `_.mapValues`; this method creates an object with the
  29324. * same values as `object` and keys generated by running each own enumerable
  29325. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29326. * with three arguments: (value, key, object).
  29327. *
  29328. * @static
  29329. * @memberOf _
  29330. * @since 3.8.0
  29331. * @category Object
  29332. * @param {Object} object The object to iterate over.
  29333. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29334. * @returns {Object} Returns the new mapped object.
  29335. * @see _.mapValues
  29336. * @example
  29337. *
  29338. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29339. * return key + value;
  29340. * });
  29341. * // => { 'a1': 1, 'b2': 2 }
  29342. */
  29343. function mapKeys(object, iteratee) {
  29344. var result = {};
  29345. iteratee = getIteratee(iteratee, 3);
  29346. baseForOwn(object, function(value, key, object) {
  29347. baseAssignValue(result, iteratee(value, key, object), value);
  29348. });
  29349. return result;
  29350. }
  29351. /**
  29352. * Creates an object with the same keys as `object` and values generated
  29353. * by running each own enumerable string keyed property of `object` thru
  29354. * `iteratee`. The iteratee is invoked with three arguments:
  29355. * (value, key, object).
  29356. *
  29357. * @static
  29358. * @memberOf _
  29359. * @since 2.4.0
  29360. * @category Object
  29361. * @param {Object} object The object to iterate over.
  29362. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29363. * @returns {Object} Returns the new mapped object.
  29364. * @see _.mapKeys
  29365. * @example
  29366. *
  29367. * var users = {
  29368. * 'fred': { 'user': 'fred', 'age': 40 },
  29369. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29370. * };
  29371. *
  29372. * _.mapValues(users, function(o) { return o.age; });
  29373. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29374. *
  29375. * // The `_.property` iteratee shorthand.
  29376. * _.mapValues(users, 'age');
  29377. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29378. */
  29379. function mapValues(object, iteratee) {
  29380. var result = {};
  29381. iteratee = getIteratee(iteratee, 3);
  29382. baseForOwn(object, function(value, key, object) {
  29383. baseAssignValue(result, key, iteratee(value, key, object));
  29384. });
  29385. return result;
  29386. }
  29387. /**
  29388. * This method is like `_.assign` except that it recursively merges own and
  29389. * inherited enumerable string keyed properties of source objects into the
  29390. * destination object. Source properties that resolve to `undefined` are
  29391. * skipped if a destination value exists. Array and plain object properties
  29392. * are merged recursively. Other objects and value types are overridden by
  29393. * assignment. Source objects are applied from left to right. Subsequent
  29394. * sources overwrite property assignments of previous sources.
  29395. *
  29396. * **Note:** This method mutates `object`.
  29397. *
  29398. * @static
  29399. * @memberOf _
  29400. * @since 0.5.0
  29401. * @category Object
  29402. * @param {Object} object The destination object.
  29403. * @param {...Object} [sources] The source objects.
  29404. * @returns {Object} Returns `object`.
  29405. * @example
  29406. *
  29407. * var object = {
  29408. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29409. * };
  29410. *
  29411. * var other = {
  29412. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29413. * };
  29414. *
  29415. * _.merge(object, other);
  29416. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29417. */
  29418. var merge = createAssigner(function(object, source, srcIndex) {
  29419. baseMerge(object, source, srcIndex);
  29420. });
  29421. /**
  29422. * This method is like `_.merge` except that it accepts `customizer` which
  29423. * is invoked to produce the merged values of the destination and source
  29424. * properties. If `customizer` returns `undefined`, merging is handled by the
  29425. * method instead. The `customizer` is invoked with six arguments:
  29426. * (objValue, srcValue, key, object, source, stack).
  29427. *
  29428. * **Note:** This method mutates `object`.
  29429. *
  29430. * @static
  29431. * @memberOf _
  29432. * @since 4.0.0
  29433. * @category Object
  29434. * @param {Object} object The destination object.
  29435. * @param {...Object} sources The source objects.
  29436. * @param {Function} customizer The function to customize assigned values.
  29437. * @returns {Object} Returns `object`.
  29438. * @example
  29439. *
  29440. * function customizer(objValue, srcValue) {
  29441. * if (_.isArray(objValue)) {
  29442. * return objValue.concat(srcValue);
  29443. * }
  29444. * }
  29445. *
  29446. * var object = { 'a': [1], 'b': [2] };
  29447. * var other = { 'a': [3], 'b': [4] };
  29448. *
  29449. * _.mergeWith(object, other, customizer);
  29450. * // => { 'a': [1, 3], 'b': [2, 4] }
  29451. */
  29452. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29453. baseMerge(object, source, srcIndex, customizer);
  29454. });
  29455. /**
  29456. * The opposite of `_.pick`; this method creates an object composed of the
  29457. * own and inherited enumerable property paths of `object` that are not omitted.
  29458. *
  29459. * **Note:** This method is considerably slower than `_.pick`.
  29460. *
  29461. * @static
  29462. * @since 0.1.0
  29463. * @memberOf _
  29464. * @category Object
  29465. * @param {Object} object The source object.
  29466. * @param {...(string|string[])} [paths] The property paths to omit.
  29467. * @returns {Object} Returns the new object.
  29468. * @example
  29469. *
  29470. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29471. *
  29472. * _.omit(object, ['a', 'c']);
  29473. * // => { 'b': '2' }
  29474. */
  29475. var omit = flatRest(function(object, paths) {
  29476. var result = {};
  29477. if (object == null) {
  29478. return result;
  29479. }
  29480. var isDeep = false;
  29481. paths = arrayMap(paths, function(path) {
  29482. path = castPath(path, object);
  29483. isDeep || (isDeep = path.length > 1);
  29484. return path;
  29485. });
  29486. copyObject(object, getAllKeysIn(object), result);
  29487. if (isDeep) {
  29488. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29489. }
  29490. var length = paths.length;
  29491. while (length--) {
  29492. baseUnset(result, paths[length]);
  29493. }
  29494. return result;
  29495. });
  29496. /**
  29497. * The opposite of `_.pickBy`; this method creates an object composed of
  29498. * the own and inherited enumerable string keyed properties of `object` that
  29499. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29500. * arguments: (value, key).
  29501. *
  29502. * @static
  29503. * @memberOf _
  29504. * @since 4.0.0
  29505. * @category Object
  29506. * @param {Object} object The source object.
  29507. * @param {Function} [predicate=_.identity] The function invoked per property.
  29508. * @returns {Object} Returns the new object.
  29509. * @example
  29510. *
  29511. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29512. *
  29513. * _.omitBy(object, _.isNumber);
  29514. * // => { 'b': '2' }
  29515. */
  29516. function omitBy(object, predicate) {
  29517. return pickBy(object, negate(getIteratee(predicate)));
  29518. }
  29519. /**
  29520. * Creates an object composed of the picked `object` properties.
  29521. *
  29522. * @static
  29523. * @since 0.1.0
  29524. * @memberOf _
  29525. * @category Object
  29526. * @param {Object} object The source object.
  29527. * @param {...(string|string[])} [paths] The property paths to pick.
  29528. * @returns {Object} Returns the new object.
  29529. * @example
  29530. *
  29531. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29532. *
  29533. * _.pick(object, ['a', 'c']);
  29534. * // => { 'a': 1, 'c': 3 }
  29535. */
  29536. var pick = flatRest(function(object, paths) {
  29537. return object == null ? {} : basePick(object, paths);
  29538. });
  29539. /**
  29540. * Creates an object composed of the `object` properties `predicate` returns
  29541. * truthy for. The predicate is invoked with two arguments: (value, key).
  29542. *
  29543. * @static
  29544. * @memberOf _
  29545. * @since 4.0.0
  29546. * @category Object
  29547. * @param {Object} object The source object.
  29548. * @param {Function} [predicate=_.identity] The function invoked per property.
  29549. * @returns {Object} Returns the new object.
  29550. * @example
  29551. *
  29552. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29553. *
  29554. * _.pickBy(object, _.isNumber);
  29555. * // => { 'a': 1, 'c': 3 }
  29556. */
  29557. function pickBy(object, predicate) {
  29558. if (object == null) {
  29559. return {};
  29560. }
  29561. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29562. return [prop];
  29563. });
  29564. predicate = getIteratee(predicate);
  29565. return basePickBy(object, props, function(value, path) {
  29566. return predicate(value, path[0]);
  29567. });
  29568. }
  29569. /**
  29570. * This method is like `_.get` except that if the resolved value is a
  29571. * function it's invoked with the `this` binding of its parent object and
  29572. * its result is returned.
  29573. *
  29574. * @static
  29575. * @since 0.1.0
  29576. * @memberOf _
  29577. * @category Object
  29578. * @param {Object} object The object to query.
  29579. * @param {Array|string} path The path of the property to resolve.
  29580. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29581. * @returns {*} Returns the resolved value.
  29582. * @example
  29583. *
  29584. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29585. *
  29586. * _.result(object, 'a[0].b.c1');
  29587. * // => 3
  29588. *
  29589. * _.result(object, 'a[0].b.c2');
  29590. * // => 4
  29591. *
  29592. * _.result(object, 'a[0].b.c3', 'default');
  29593. * // => 'default'
  29594. *
  29595. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29596. * // => 'default'
  29597. */
  29598. function result(object, path, defaultValue) {
  29599. path = castPath(path, object);
  29600. var index = -1,
  29601. length = path.length;
  29602. // Ensure the loop is entered when path is empty.
  29603. if (!length) {
  29604. length = 1;
  29605. object = undefined;
  29606. }
  29607. while (++index < length) {
  29608. var value = object == null ? undefined : object[toKey(path[index])];
  29609. if (value === undefined) {
  29610. index = length;
  29611. value = defaultValue;
  29612. }
  29613. object = isFunction(value) ? value.call(object) : value;
  29614. }
  29615. return object;
  29616. }
  29617. /**
  29618. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29619. * it's created. Arrays are created for missing index properties while objects
  29620. * are created for all other missing properties. Use `_.setWith` to customize
  29621. * `path` creation.
  29622. *
  29623. * **Note:** This method mutates `object`.
  29624. *
  29625. * @static
  29626. * @memberOf _
  29627. * @since 3.7.0
  29628. * @category Object
  29629. * @param {Object} object The object to modify.
  29630. * @param {Array|string} path The path of the property to set.
  29631. * @param {*} value The value to set.
  29632. * @returns {Object} Returns `object`.
  29633. * @example
  29634. *
  29635. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29636. *
  29637. * _.set(object, 'a[0].b.c', 4);
  29638. * console.log(object.a[0].b.c);
  29639. * // => 4
  29640. *
  29641. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29642. * console.log(object.x[0].y.z);
  29643. * // => 5
  29644. */
  29645. function set(object, path, value) {
  29646. return object == null ? object : baseSet(object, path, value);
  29647. }
  29648. /**
  29649. * This method is like `_.set` except that it accepts `customizer` which is
  29650. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29651. * path creation is handled by the method instead. The `customizer` is invoked
  29652. * with three arguments: (nsValue, key, nsObject).
  29653. *
  29654. * **Note:** This method mutates `object`.
  29655. *
  29656. * @static
  29657. * @memberOf _
  29658. * @since 4.0.0
  29659. * @category Object
  29660. * @param {Object} object The object to modify.
  29661. * @param {Array|string} path The path of the property to set.
  29662. * @param {*} value The value to set.
  29663. * @param {Function} [customizer] The function to customize assigned values.
  29664. * @returns {Object} Returns `object`.
  29665. * @example
  29666. *
  29667. * var object = {};
  29668. *
  29669. * _.setWith(object, '[0][1]', 'a', Object);
  29670. * // => { '0': { '1': 'a' } }
  29671. */
  29672. function setWith(object, path, value, customizer) {
  29673. customizer = typeof customizer == 'function' ? customizer : undefined;
  29674. return object == null ? object : baseSet(object, path, value, customizer);
  29675. }
  29676. /**
  29677. * Creates an array of own enumerable string keyed-value pairs for `object`
  29678. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29679. * entries are returned.
  29680. *
  29681. * @static
  29682. * @memberOf _
  29683. * @since 4.0.0
  29684. * @alias entries
  29685. * @category Object
  29686. * @param {Object} object The object to query.
  29687. * @returns {Array} Returns the key-value pairs.
  29688. * @example
  29689. *
  29690. * function Foo() {
  29691. * this.a = 1;
  29692. * this.b = 2;
  29693. * }
  29694. *
  29695. * Foo.prototype.c = 3;
  29696. *
  29697. * _.toPairs(new Foo);
  29698. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29699. */
  29700. var toPairs = createToPairs(keys);
  29701. /**
  29702. * Creates an array of own and inherited enumerable string keyed-value pairs
  29703. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29704. * or set, its entries are returned.
  29705. *
  29706. * @static
  29707. * @memberOf _
  29708. * @since 4.0.0
  29709. * @alias entriesIn
  29710. * @category Object
  29711. * @param {Object} object The object to query.
  29712. * @returns {Array} Returns the key-value pairs.
  29713. * @example
  29714. *
  29715. * function Foo() {
  29716. * this.a = 1;
  29717. * this.b = 2;
  29718. * }
  29719. *
  29720. * Foo.prototype.c = 3;
  29721. *
  29722. * _.toPairsIn(new Foo);
  29723. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29724. */
  29725. var toPairsIn = createToPairs(keysIn);
  29726. /**
  29727. * An alternative to `_.reduce`; this method transforms `object` to a new
  29728. * `accumulator` object which is the result of running each of its own
  29729. * enumerable string keyed properties thru `iteratee`, with each invocation
  29730. * potentially mutating the `accumulator` object. If `accumulator` is not
  29731. * provided, a new object with the same `[[Prototype]]` will be used. The
  29732. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29733. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29734. *
  29735. * @static
  29736. * @memberOf _
  29737. * @since 1.3.0
  29738. * @category Object
  29739. * @param {Object} object The object to iterate over.
  29740. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29741. * @param {*} [accumulator] The custom accumulator value.
  29742. * @returns {*} Returns the accumulated value.
  29743. * @example
  29744. *
  29745. * _.transform([2, 3, 4], function(result, n) {
  29746. * result.push(n *= n);
  29747. * return n % 2 == 0;
  29748. * }, []);
  29749. * // => [4, 9]
  29750. *
  29751. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29752. * (result[value] || (result[value] = [])).push(key);
  29753. * }, {});
  29754. * // => { '1': ['a', 'c'], '2': ['b'] }
  29755. */
  29756. function transform(object, iteratee, accumulator) {
  29757. var isArr = isArray(object),
  29758. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29759. iteratee = getIteratee(iteratee, 4);
  29760. if (accumulator == null) {
  29761. var Ctor = object && object.constructor;
  29762. if (isArrLike) {
  29763. accumulator = isArr ? new Ctor : [];
  29764. }
  29765. else if (isObject(object)) {
  29766. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29767. }
  29768. else {
  29769. accumulator = {};
  29770. }
  29771. }
  29772. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29773. return iteratee(accumulator, value, index, object);
  29774. });
  29775. return accumulator;
  29776. }
  29777. /**
  29778. * Removes the property at `path` of `object`.
  29779. *
  29780. * **Note:** This method mutates `object`.
  29781. *
  29782. * @static
  29783. * @memberOf _
  29784. * @since 4.0.0
  29785. * @category Object
  29786. * @param {Object} object The object to modify.
  29787. * @param {Array|string} path The path of the property to unset.
  29788. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29789. * @example
  29790. *
  29791. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29792. * _.unset(object, 'a[0].b.c');
  29793. * // => true
  29794. *
  29795. * console.log(object);
  29796. * // => { 'a': [{ 'b': {} }] };
  29797. *
  29798. * _.unset(object, ['a', '0', 'b', 'c']);
  29799. * // => true
  29800. *
  29801. * console.log(object);
  29802. * // => { 'a': [{ 'b': {} }] };
  29803. */
  29804. function unset(object, path) {
  29805. return object == null ? true : baseUnset(object, path);
  29806. }
  29807. /**
  29808. * This method is like `_.set` except that accepts `updater` to produce the
  29809. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29810. * is invoked with one argument: (value).
  29811. *
  29812. * **Note:** This method mutates `object`.
  29813. *
  29814. * @static
  29815. * @memberOf _
  29816. * @since 4.6.0
  29817. * @category Object
  29818. * @param {Object} object The object to modify.
  29819. * @param {Array|string} path The path of the property to set.
  29820. * @param {Function} updater The function to produce the updated value.
  29821. * @returns {Object} Returns `object`.
  29822. * @example
  29823. *
  29824. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29825. *
  29826. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29827. * console.log(object.a[0].b.c);
  29828. * // => 9
  29829. *
  29830. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29831. * console.log(object.x[0].y.z);
  29832. * // => 0
  29833. */
  29834. function update(object, path, updater) {
  29835. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29836. }
  29837. /**
  29838. * This method is like `_.update` except that it accepts `customizer` which is
  29839. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29840. * path creation is handled by the method instead. The `customizer` is invoked
  29841. * with three arguments: (nsValue, key, nsObject).
  29842. *
  29843. * **Note:** This method mutates `object`.
  29844. *
  29845. * @static
  29846. * @memberOf _
  29847. * @since 4.6.0
  29848. * @category Object
  29849. * @param {Object} object The object to modify.
  29850. * @param {Array|string} path The path of the property to set.
  29851. * @param {Function} updater The function to produce the updated value.
  29852. * @param {Function} [customizer] The function to customize assigned values.
  29853. * @returns {Object} Returns `object`.
  29854. * @example
  29855. *
  29856. * var object = {};
  29857. *
  29858. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29859. * // => { '0': { '1': 'a' } }
  29860. */
  29861. function updateWith(object, path, updater, customizer) {
  29862. customizer = typeof customizer == 'function' ? customizer : undefined;
  29863. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29864. }
  29865. /**
  29866. * Creates an array of the own enumerable string keyed property values of `object`.
  29867. *
  29868. * **Note:** Non-object values are coerced to objects.
  29869. *
  29870. * @static
  29871. * @since 0.1.0
  29872. * @memberOf _
  29873. * @category Object
  29874. * @param {Object} object The object to query.
  29875. * @returns {Array} Returns the array of property values.
  29876. * @example
  29877. *
  29878. * function Foo() {
  29879. * this.a = 1;
  29880. * this.b = 2;
  29881. * }
  29882. *
  29883. * Foo.prototype.c = 3;
  29884. *
  29885. * _.values(new Foo);
  29886. * // => [1, 2] (iteration order is not guaranteed)
  29887. *
  29888. * _.values('hi');
  29889. * // => ['h', 'i']
  29890. */
  29891. function values(object) {
  29892. return object == null ? [] : baseValues(object, keys(object));
  29893. }
  29894. /**
  29895. * Creates an array of the own and inherited enumerable string keyed property
  29896. * values of `object`.
  29897. *
  29898. * **Note:** Non-object values are coerced to objects.
  29899. *
  29900. * @static
  29901. * @memberOf _
  29902. * @since 3.0.0
  29903. * @category Object
  29904. * @param {Object} object The object to query.
  29905. * @returns {Array} Returns the array of property values.
  29906. * @example
  29907. *
  29908. * function Foo() {
  29909. * this.a = 1;
  29910. * this.b = 2;
  29911. * }
  29912. *
  29913. * Foo.prototype.c = 3;
  29914. *
  29915. * _.valuesIn(new Foo);
  29916. * // => [1, 2, 3] (iteration order is not guaranteed)
  29917. */
  29918. function valuesIn(object) {
  29919. return object == null ? [] : baseValues(object, keysIn(object));
  29920. }
  29921. /*------------------------------------------------------------------------*/
  29922. /**
  29923. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29924. *
  29925. * @static
  29926. * @memberOf _
  29927. * @since 4.0.0
  29928. * @category Number
  29929. * @param {number} number The number to clamp.
  29930. * @param {number} [lower] The lower bound.
  29931. * @param {number} upper The upper bound.
  29932. * @returns {number} Returns the clamped number.
  29933. * @example
  29934. *
  29935. * _.clamp(-10, -5, 5);
  29936. * // => -5
  29937. *
  29938. * _.clamp(10, -5, 5);
  29939. * // => 5
  29940. */
  29941. function clamp(number, lower, upper) {
  29942. if (upper === undefined) {
  29943. upper = lower;
  29944. lower = undefined;
  29945. }
  29946. if (upper !== undefined) {
  29947. upper = toNumber(upper);
  29948. upper = upper === upper ? upper : 0;
  29949. }
  29950. if (lower !== undefined) {
  29951. lower = toNumber(lower);
  29952. lower = lower === lower ? lower : 0;
  29953. }
  29954. return baseClamp(toNumber(number), lower, upper);
  29955. }
  29956. /**
  29957. * Checks if `n` is between `start` and up to, but not including, `end`. If
  29958. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  29959. * If `start` is greater than `end` the params are swapped to support
  29960. * negative ranges.
  29961. *
  29962. * @static
  29963. * @memberOf _
  29964. * @since 3.3.0
  29965. * @category Number
  29966. * @param {number} number The number to check.
  29967. * @param {number} [start=0] The start of the range.
  29968. * @param {number} end The end of the range.
  29969. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  29970. * @see _.range, _.rangeRight
  29971. * @example
  29972. *
  29973. * _.inRange(3, 2, 4);
  29974. * // => true
  29975. *
  29976. * _.inRange(4, 8);
  29977. * // => true
  29978. *
  29979. * _.inRange(4, 2);
  29980. * // => false
  29981. *
  29982. * _.inRange(2, 2);
  29983. * // => false
  29984. *
  29985. * _.inRange(1.2, 2);
  29986. * // => true
  29987. *
  29988. * _.inRange(5.2, 4);
  29989. * // => false
  29990. *
  29991. * _.inRange(-3, -2, -6);
  29992. * // => true
  29993. */
  29994. function inRange(number, start, end) {
  29995. start = toFinite(start);
  29996. if (end === undefined) {
  29997. end = start;
  29998. start = 0;
  29999. } else {
  30000. end = toFinite(end);
  30001. }
  30002. number = toNumber(number);
  30003. return baseInRange(number, start, end);
  30004. }
  30005. /**
  30006. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30007. * If only one argument is provided a number between `0` and the given number
  30008. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30009. * floats, a floating-point number is returned instead of an integer.
  30010. *
  30011. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30012. * floating-point values which can produce unexpected results.
  30013. *
  30014. * @static
  30015. * @memberOf _
  30016. * @since 0.7.0
  30017. * @category Number
  30018. * @param {number} [lower=0] The lower bound.
  30019. * @param {number} [upper=1] The upper bound.
  30020. * @param {boolean} [floating] Specify returning a floating-point number.
  30021. * @returns {number} Returns the random number.
  30022. * @example
  30023. *
  30024. * _.random(0, 5);
  30025. * // => an integer between 0 and 5
  30026. *
  30027. * _.random(5);
  30028. * // => also an integer between 0 and 5
  30029. *
  30030. * _.random(5, true);
  30031. * // => a floating-point number between 0 and 5
  30032. *
  30033. * _.random(1.2, 5.2);
  30034. * // => a floating-point number between 1.2 and 5.2
  30035. */
  30036. function random(lower, upper, floating) {
  30037. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30038. upper = floating = undefined;
  30039. }
  30040. if (floating === undefined) {
  30041. if (typeof upper == 'boolean') {
  30042. floating = upper;
  30043. upper = undefined;
  30044. }
  30045. else if (typeof lower == 'boolean') {
  30046. floating = lower;
  30047. lower = undefined;
  30048. }
  30049. }
  30050. if (lower === undefined && upper === undefined) {
  30051. lower = 0;
  30052. upper = 1;
  30053. }
  30054. else {
  30055. lower = toFinite(lower);
  30056. if (upper === undefined) {
  30057. upper = lower;
  30058. lower = 0;
  30059. } else {
  30060. upper = toFinite(upper);
  30061. }
  30062. }
  30063. if (lower > upper) {
  30064. var temp = lower;
  30065. lower = upper;
  30066. upper = temp;
  30067. }
  30068. if (floating || lower % 1 || upper % 1) {
  30069. var rand = nativeRandom();
  30070. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30071. }
  30072. return baseRandom(lower, upper);
  30073. }
  30074. /*------------------------------------------------------------------------*/
  30075. /**
  30076. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30077. *
  30078. * @static
  30079. * @memberOf _
  30080. * @since 3.0.0
  30081. * @category String
  30082. * @param {string} [string=''] The string to convert.
  30083. * @returns {string} Returns the camel cased string.
  30084. * @example
  30085. *
  30086. * _.camelCase('Foo Bar');
  30087. * // => 'fooBar'
  30088. *
  30089. * _.camelCase('--foo-bar--');
  30090. * // => 'fooBar'
  30091. *
  30092. * _.camelCase('__FOO_BAR__');
  30093. * // => 'fooBar'
  30094. */
  30095. var camelCase = createCompounder(function(result, word, index) {
  30096. word = word.toLowerCase();
  30097. return result + (index ? capitalize(word) : word);
  30098. });
  30099. /**
  30100. * Converts the first character of `string` to upper case and the remaining
  30101. * to lower case.
  30102. *
  30103. * @static
  30104. * @memberOf _
  30105. * @since 3.0.0
  30106. * @category String
  30107. * @param {string} [string=''] The string to capitalize.
  30108. * @returns {string} Returns the capitalized string.
  30109. * @example
  30110. *
  30111. * _.capitalize('FRED');
  30112. * // => 'Fred'
  30113. */
  30114. function capitalize(string) {
  30115. return upperFirst(toString(string).toLowerCase());
  30116. }
  30117. /**
  30118. * Deburrs `string` by converting
  30119. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30120. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30121. * letters to basic Latin letters and removing
  30122. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30123. *
  30124. * @static
  30125. * @memberOf _
  30126. * @since 3.0.0
  30127. * @category String
  30128. * @param {string} [string=''] The string to deburr.
  30129. * @returns {string} Returns the deburred string.
  30130. * @example
  30131. *
  30132. * _.deburr('déjà vu');
  30133. * // => 'deja vu'
  30134. */
  30135. function deburr(string) {
  30136. string = toString(string);
  30137. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30138. }
  30139. /**
  30140. * Checks if `string` ends with the given target string.
  30141. *
  30142. * @static
  30143. * @memberOf _
  30144. * @since 3.0.0
  30145. * @category String
  30146. * @param {string} [string=''] The string to inspect.
  30147. * @param {string} [target] The string to search for.
  30148. * @param {number} [position=string.length] The position to search up to.
  30149. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30150. * else `false`.
  30151. * @example
  30152. *
  30153. * _.endsWith('abc', 'c');
  30154. * // => true
  30155. *
  30156. * _.endsWith('abc', 'b');
  30157. * // => false
  30158. *
  30159. * _.endsWith('abc', 'b', 2);
  30160. * // => true
  30161. */
  30162. function endsWith(string, target, position) {
  30163. string = toString(string);
  30164. target = baseToString(target);
  30165. var length = string.length;
  30166. position = position === undefined
  30167. ? length
  30168. : baseClamp(toInteger(position), 0, length);
  30169. var end = position;
  30170. position -= target.length;
  30171. return position >= 0 && string.slice(position, end) == target;
  30172. }
  30173. /**
  30174. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30175. * corresponding HTML entities.
  30176. *
  30177. * **Note:** No other characters are escaped. To escape additional
  30178. * characters use a third-party library like [_he_](https://mths.be/he).
  30179. *
  30180. * Though the ">" character is escaped for symmetry, characters like
  30181. * ">" and "/" don't need escaping in HTML and have no special meaning
  30182. * unless they're part of a tag or unquoted attribute value. See
  30183. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30184. * (under "semi-related fun fact") for more details.
  30185. *
  30186. * When working with HTML you should always
  30187. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30188. * XSS vectors.
  30189. *
  30190. * @static
  30191. * @since 0.1.0
  30192. * @memberOf _
  30193. * @category String
  30194. * @param {string} [string=''] The string to escape.
  30195. * @returns {string} Returns the escaped string.
  30196. * @example
  30197. *
  30198. * _.escape('fred, barney, & pebbles');
  30199. * // => 'fred, barney, &amp; pebbles'
  30200. */
  30201. function escape(string) {
  30202. string = toString(string);
  30203. return (string && reHasUnescapedHtml.test(string))
  30204. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30205. : string;
  30206. }
  30207. /**
  30208. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30209. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30210. *
  30211. * @static
  30212. * @memberOf _
  30213. * @since 3.0.0
  30214. * @category String
  30215. * @param {string} [string=''] The string to escape.
  30216. * @returns {string} Returns the escaped string.
  30217. * @example
  30218. *
  30219. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30220. * // => '\[lodash\]\(https://lodash\.com/\)'
  30221. */
  30222. function escapeRegExp(string) {
  30223. string = toString(string);
  30224. return (string && reHasRegExpChar.test(string))
  30225. ? string.replace(reRegExpChar, '\\$&')
  30226. : string;
  30227. }
  30228. /**
  30229. * Converts `string` to
  30230. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30231. *
  30232. * @static
  30233. * @memberOf _
  30234. * @since 3.0.0
  30235. * @category String
  30236. * @param {string} [string=''] The string to convert.
  30237. * @returns {string} Returns the kebab cased string.
  30238. * @example
  30239. *
  30240. * _.kebabCase('Foo Bar');
  30241. * // => 'foo-bar'
  30242. *
  30243. * _.kebabCase('fooBar');
  30244. * // => 'foo-bar'
  30245. *
  30246. * _.kebabCase('__FOO_BAR__');
  30247. * // => 'foo-bar'
  30248. */
  30249. var kebabCase = createCompounder(function(result, word, index) {
  30250. return result + (index ? '-' : '') + word.toLowerCase();
  30251. });
  30252. /**
  30253. * Converts `string`, as space separated words, to lower case.
  30254. *
  30255. * @static
  30256. * @memberOf _
  30257. * @since 4.0.0
  30258. * @category String
  30259. * @param {string} [string=''] The string to convert.
  30260. * @returns {string} Returns the lower cased string.
  30261. * @example
  30262. *
  30263. * _.lowerCase('--Foo-Bar--');
  30264. * // => 'foo bar'
  30265. *
  30266. * _.lowerCase('fooBar');
  30267. * // => 'foo bar'
  30268. *
  30269. * _.lowerCase('__FOO_BAR__');
  30270. * // => 'foo bar'
  30271. */
  30272. var lowerCase = createCompounder(function(result, word, index) {
  30273. return result + (index ? ' ' : '') + word.toLowerCase();
  30274. });
  30275. /**
  30276. * Converts the first character of `string` to lower case.
  30277. *
  30278. * @static
  30279. * @memberOf _
  30280. * @since 4.0.0
  30281. * @category String
  30282. * @param {string} [string=''] The string to convert.
  30283. * @returns {string} Returns the converted string.
  30284. * @example
  30285. *
  30286. * _.lowerFirst('Fred');
  30287. * // => 'fred'
  30288. *
  30289. * _.lowerFirst('FRED');
  30290. * // => 'fRED'
  30291. */
  30292. var lowerFirst = createCaseFirst('toLowerCase');
  30293. /**
  30294. * Pads `string` on the left and right sides if it's shorter than `length`.
  30295. * Padding characters are truncated if they can't be evenly divided by `length`.
  30296. *
  30297. * @static
  30298. * @memberOf _
  30299. * @since 3.0.0
  30300. * @category String
  30301. * @param {string} [string=''] The string to pad.
  30302. * @param {number} [length=0] The padding length.
  30303. * @param {string} [chars=' '] The string used as padding.
  30304. * @returns {string} Returns the padded string.
  30305. * @example
  30306. *
  30307. * _.pad('abc', 8);
  30308. * // => ' abc '
  30309. *
  30310. * _.pad('abc', 8, '_-');
  30311. * // => '_-abc_-_'
  30312. *
  30313. * _.pad('abc', 3);
  30314. * // => 'abc'
  30315. */
  30316. function pad(string, length, chars) {
  30317. string = toString(string);
  30318. length = toInteger(length);
  30319. var strLength = length ? stringSize(string) : 0;
  30320. if (!length || strLength >= length) {
  30321. return string;
  30322. }
  30323. var mid = (length - strLength) / 2;
  30324. return (
  30325. createPadding(nativeFloor(mid), chars) +
  30326. string +
  30327. createPadding(nativeCeil(mid), chars)
  30328. );
  30329. }
  30330. /**
  30331. * Pads `string` on the right side if it's shorter than `length`. Padding
  30332. * characters are truncated if they exceed `length`.
  30333. *
  30334. * @static
  30335. * @memberOf _
  30336. * @since 4.0.0
  30337. * @category String
  30338. * @param {string} [string=''] The string to pad.
  30339. * @param {number} [length=0] The padding length.
  30340. * @param {string} [chars=' '] The string used as padding.
  30341. * @returns {string} Returns the padded string.
  30342. * @example
  30343. *
  30344. * _.padEnd('abc', 6);
  30345. * // => 'abc '
  30346. *
  30347. * _.padEnd('abc', 6, '_-');
  30348. * // => 'abc_-_'
  30349. *
  30350. * _.padEnd('abc', 3);
  30351. * // => 'abc'
  30352. */
  30353. function padEnd(string, length, chars) {
  30354. string = toString(string);
  30355. length = toInteger(length);
  30356. var strLength = length ? stringSize(string) : 0;
  30357. return (length && strLength < length)
  30358. ? (string + createPadding(length - strLength, chars))
  30359. : string;
  30360. }
  30361. /**
  30362. * Pads `string` on the left side if it's shorter than `length`. Padding
  30363. * characters are truncated if they exceed `length`.
  30364. *
  30365. * @static
  30366. * @memberOf _
  30367. * @since 4.0.0
  30368. * @category String
  30369. * @param {string} [string=''] The string to pad.
  30370. * @param {number} [length=0] The padding length.
  30371. * @param {string} [chars=' '] The string used as padding.
  30372. * @returns {string} Returns the padded string.
  30373. * @example
  30374. *
  30375. * _.padStart('abc', 6);
  30376. * // => ' abc'
  30377. *
  30378. * _.padStart('abc', 6, '_-');
  30379. * // => '_-_abc'
  30380. *
  30381. * _.padStart('abc', 3);
  30382. * // => 'abc'
  30383. */
  30384. function padStart(string, length, chars) {
  30385. string = toString(string);
  30386. length = toInteger(length);
  30387. var strLength = length ? stringSize(string) : 0;
  30388. return (length && strLength < length)
  30389. ? (createPadding(length - strLength, chars) + string)
  30390. : string;
  30391. }
  30392. /**
  30393. * Converts `string` to an integer of the specified radix. If `radix` is
  30394. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30395. * hexadecimal, in which case a `radix` of `16` is used.
  30396. *
  30397. * **Note:** This method aligns with the
  30398. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30399. *
  30400. * @static
  30401. * @memberOf _
  30402. * @since 1.1.0
  30403. * @category String
  30404. * @param {string} string The string to convert.
  30405. * @param {number} [radix=10] The radix to interpret `value` by.
  30406. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30407. * @returns {number} Returns the converted integer.
  30408. * @example
  30409. *
  30410. * _.parseInt('08');
  30411. * // => 8
  30412. *
  30413. * _.map(['6', '08', '10'], _.parseInt);
  30414. * // => [6, 8, 10]
  30415. */
  30416. function parseInt(string, radix, guard) {
  30417. if (guard || radix == null) {
  30418. radix = 0;
  30419. } else if (radix) {
  30420. radix = +radix;
  30421. }
  30422. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30423. }
  30424. /**
  30425. * Repeats the given string `n` times.
  30426. *
  30427. * @static
  30428. * @memberOf _
  30429. * @since 3.0.0
  30430. * @category String
  30431. * @param {string} [string=''] The string to repeat.
  30432. * @param {number} [n=1] The number of times to repeat the string.
  30433. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30434. * @returns {string} Returns the repeated string.
  30435. * @example
  30436. *
  30437. * _.repeat('*', 3);
  30438. * // => '***'
  30439. *
  30440. * _.repeat('abc', 2);
  30441. * // => 'abcabc'
  30442. *
  30443. * _.repeat('abc', 0);
  30444. * // => ''
  30445. */
  30446. function repeat(string, n, guard) {
  30447. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30448. n = 1;
  30449. } else {
  30450. n = toInteger(n);
  30451. }
  30452. return baseRepeat(toString(string), n);
  30453. }
  30454. /**
  30455. * Replaces matches for `pattern` in `string` with `replacement`.
  30456. *
  30457. * **Note:** This method is based on
  30458. * [`String#replace`](https://mdn.io/String/replace).
  30459. *
  30460. * @static
  30461. * @memberOf _
  30462. * @since 4.0.0
  30463. * @category String
  30464. * @param {string} [string=''] The string to modify.
  30465. * @param {RegExp|string} pattern The pattern to replace.
  30466. * @param {Function|string} replacement The match replacement.
  30467. * @returns {string} Returns the modified string.
  30468. * @example
  30469. *
  30470. * _.replace('Hi Fred', 'Fred', 'Barney');
  30471. * // => 'Hi Barney'
  30472. */
  30473. function replace() {
  30474. var args = arguments,
  30475. string = toString(args[0]);
  30476. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30477. }
  30478. /**
  30479. * Converts `string` to
  30480. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30481. *
  30482. * @static
  30483. * @memberOf _
  30484. * @since 3.0.0
  30485. * @category String
  30486. * @param {string} [string=''] The string to convert.
  30487. * @returns {string} Returns the snake cased string.
  30488. * @example
  30489. *
  30490. * _.snakeCase('Foo Bar');
  30491. * // => 'foo_bar'
  30492. *
  30493. * _.snakeCase('fooBar');
  30494. * // => 'foo_bar'
  30495. *
  30496. * _.snakeCase('--FOO-BAR--');
  30497. * // => 'foo_bar'
  30498. */
  30499. var snakeCase = createCompounder(function(result, word, index) {
  30500. return result + (index ? '_' : '') + word.toLowerCase();
  30501. });
  30502. /**
  30503. * Splits `string` by `separator`.
  30504. *
  30505. * **Note:** This method is based on
  30506. * [`String#split`](https://mdn.io/String/split).
  30507. *
  30508. * @static
  30509. * @memberOf _
  30510. * @since 4.0.0
  30511. * @category String
  30512. * @param {string} [string=''] The string to split.
  30513. * @param {RegExp|string} separator The separator pattern to split by.
  30514. * @param {number} [limit] The length to truncate results to.
  30515. * @returns {Array} Returns the string segments.
  30516. * @example
  30517. *
  30518. * _.split('a-b-c', '-', 2);
  30519. * // => ['a', 'b']
  30520. */
  30521. function split(string, separator, limit) {
  30522. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30523. separator = limit = undefined;
  30524. }
  30525. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30526. if (!limit) {
  30527. return [];
  30528. }
  30529. string = toString(string);
  30530. if (string && (
  30531. typeof separator == 'string' ||
  30532. (separator != null && !isRegExp(separator))
  30533. )) {
  30534. separator = baseToString(separator);
  30535. if (!separator && hasUnicode(string)) {
  30536. return castSlice(stringToArray(string), 0, limit);
  30537. }
  30538. }
  30539. return string.split(separator, limit);
  30540. }
  30541. /**
  30542. * Converts `string` to
  30543. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30544. *
  30545. * @static
  30546. * @memberOf _
  30547. * @since 3.1.0
  30548. * @category String
  30549. * @param {string} [string=''] The string to convert.
  30550. * @returns {string} Returns the start cased string.
  30551. * @example
  30552. *
  30553. * _.startCase('--foo-bar--');
  30554. * // => 'Foo Bar'
  30555. *
  30556. * _.startCase('fooBar');
  30557. * // => 'Foo Bar'
  30558. *
  30559. * _.startCase('__FOO_BAR__');
  30560. * // => 'FOO BAR'
  30561. */
  30562. var startCase = createCompounder(function(result, word, index) {
  30563. return result + (index ? ' ' : '') + upperFirst(word);
  30564. });
  30565. /**
  30566. * Checks if `string` starts with the given target string.
  30567. *
  30568. * @static
  30569. * @memberOf _
  30570. * @since 3.0.0
  30571. * @category String
  30572. * @param {string} [string=''] The string to inspect.
  30573. * @param {string} [target] The string to search for.
  30574. * @param {number} [position=0] The position to search from.
  30575. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30576. * else `false`.
  30577. * @example
  30578. *
  30579. * _.startsWith('abc', 'a');
  30580. * // => true
  30581. *
  30582. * _.startsWith('abc', 'b');
  30583. * // => false
  30584. *
  30585. * _.startsWith('abc', 'b', 1);
  30586. * // => true
  30587. */
  30588. function startsWith(string, target, position) {
  30589. string = toString(string);
  30590. position = position == null
  30591. ? 0
  30592. : baseClamp(toInteger(position), 0, string.length);
  30593. target = baseToString(target);
  30594. return string.slice(position, position + target.length) == target;
  30595. }
  30596. /**
  30597. * Creates a compiled template function that can interpolate data properties
  30598. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30599. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30600. * properties may be accessed as free variables in the template. If a setting
  30601. * object is given, it takes precedence over `_.templateSettings` values.
  30602. *
  30603. * **Note:** In the development build `_.template` utilizes
  30604. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30605. * for easier debugging.
  30606. *
  30607. * For more information on precompiling templates see
  30608. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30609. *
  30610. * For more information on Chrome extension sandboxes see
  30611. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30612. *
  30613. * @static
  30614. * @since 0.1.0
  30615. * @memberOf _
  30616. * @category String
  30617. * @param {string} [string=''] The template string.
  30618. * @param {Object} [options={}] The options object.
  30619. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30620. * The HTML "escape" delimiter.
  30621. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30622. * The "evaluate" delimiter.
  30623. * @param {Object} [options.imports=_.templateSettings.imports]
  30624. * An object to import into the template as free variables.
  30625. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30626. * The "interpolate" delimiter.
  30627. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30628. * The sourceURL of the compiled template.
  30629. * @param {string} [options.variable='obj']
  30630. * The data object variable name.
  30631. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30632. * @returns {Function} Returns the compiled template function.
  30633. * @example
  30634. *
  30635. * // Use the "interpolate" delimiter to create a compiled template.
  30636. * var compiled = _.template('hello <%= user %>!');
  30637. * compiled({ 'user': 'fred' });
  30638. * // => 'hello fred!'
  30639. *
  30640. * // Use the HTML "escape" delimiter to escape data property values.
  30641. * var compiled = _.template('<b><%- value %></b>');
  30642. * compiled({ 'value': '<script>' });
  30643. * // => '<b>&lt;script&gt;</b>'
  30644. *
  30645. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30646. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30647. * compiled({ 'users': ['fred', 'barney'] });
  30648. * // => '<li>fred</li><li>barney</li>'
  30649. *
  30650. * // Use the internal `print` function in "evaluate" delimiters.
  30651. * var compiled = _.template('<% print("hello " + user); %>!');
  30652. * compiled({ 'user': 'barney' });
  30653. * // => 'hello barney!'
  30654. *
  30655. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30656. * // Disable support by replacing the "interpolate" delimiter.
  30657. * var compiled = _.template('hello ${ user }!');
  30658. * compiled({ 'user': 'pebbles' });
  30659. * // => 'hello pebbles!'
  30660. *
  30661. * // Use backslashes to treat delimiters as plain text.
  30662. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30663. * compiled({ 'value': 'ignored' });
  30664. * // => '<%- value %>'
  30665. *
  30666. * // Use the `imports` option to import `jQuery` as `jq`.
  30667. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30668. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30669. * compiled({ 'users': ['fred', 'barney'] });
  30670. * // => '<li>fred</li><li>barney</li>'
  30671. *
  30672. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30673. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30674. * compiled(data);
  30675. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30676. *
  30677. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30678. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30679. * compiled.source;
  30680. * // => function(data) {
  30681. * // var __t, __p = '';
  30682. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30683. * // return __p;
  30684. * // }
  30685. *
  30686. * // Use custom template delimiters.
  30687. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30688. * var compiled = _.template('hello {{ user }}!');
  30689. * compiled({ 'user': 'mustache' });
  30690. * // => 'hello mustache!'
  30691. *
  30692. * // Use the `source` property to inline compiled templates for meaningful
  30693. * // line numbers in error messages and stack traces.
  30694. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30695. * var JST = {\
  30696. * "main": ' + _.template(mainText).source + '\
  30697. * };\
  30698. * ');
  30699. */
  30700. function template(string, options, guard) {
  30701. // Based on John Resig's `tmpl` implementation
  30702. // (http://ejohn.org/blog/javascript-micro-templating/)
  30703. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30704. var settings = lodash.templateSettings;
  30705. if (guard && isIterateeCall(string, options, guard)) {
  30706. options = undefined;
  30707. }
  30708. string = toString(string);
  30709. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30710. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30711. importsKeys = keys(imports),
  30712. importsValues = baseValues(imports, importsKeys);
  30713. var isEscaping,
  30714. isEvaluating,
  30715. index = 0,
  30716. interpolate = options.interpolate || reNoMatch,
  30717. source = "__p += '";
  30718. // Compile the regexp to match each delimiter.
  30719. var reDelimiters = RegExp(
  30720. (options.escape || reNoMatch).source + '|' +
  30721. interpolate.source + '|' +
  30722. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30723. (options.evaluate || reNoMatch).source + '|$'
  30724. , 'g');
  30725. // Use a sourceURL for easier debugging.
  30726. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30727. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30728. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30729. var sourceURL = '//# sourceURL=' +
  30730. (hasOwnProperty.call(options, 'sourceURL')
  30731. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30732. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30733. ) + '\n';
  30734. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30735. interpolateValue || (interpolateValue = esTemplateValue);
  30736. // Escape characters that can't be included in string literals.
  30737. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30738. // Replace delimiters with snippets.
  30739. if (escapeValue) {
  30740. isEscaping = true;
  30741. source += "' +\n__e(" + escapeValue + ") +\n'";
  30742. }
  30743. if (evaluateValue) {
  30744. isEvaluating = true;
  30745. source += "';\n" + evaluateValue + ";\n__p += '";
  30746. }
  30747. if (interpolateValue) {
  30748. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30749. }
  30750. index = offset + match.length;
  30751. // The JS engine embedded in Adobe products needs `match` returned in
  30752. // order to produce the correct `offset` value.
  30753. return match;
  30754. });
  30755. source += "';\n";
  30756. // If `variable` is not specified wrap a with-statement around the generated
  30757. // code to add the data object to the top of the scope chain.
  30758. // Like with sourceURL, we take care to not check the option's prototype,
  30759. // as this configuration is a code injection vector.
  30760. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30761. if (!variable) {
  30762. source = 'with (obj) {\n' + source + '\n}\n';
  30763. }
  30764. // Cleanup code by stripping empty strings.
  30765. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30766. .replace(reEmptyStringMiddle, '$1')
  30767. .replace(reEmptyStringTrailing, '$1;');
  30768. // Frame code as the function body.
  30769. source = 'function(' + (variable || 'obj') + ') {\n' +
  30770. (variable
  30771. ? ''
  30772. : 'obj || (obj = {});\n'
  30773. ) +
  30774. "var __t, __p = ''" +
  30775. (isEscaping
  30776. ? ', __e = _.escape'
  30777. : ''
  30778. ) +
  30779. (isEvaluating
  30780. ? ', __j = Array.prototype.join;\n' +
  30781. "function print() { __p += __j.call(arguments, '') }\n"
  30782. : ';\n'
  30783. ) +
  30784. source +
  30785. 'return __p\n}';
  30786. var result = attempt(function() {
  30787. return Function(importsKeys, sourceURL + 'return ' + source)
  30788. .apply(undefined, importsValues);
  30789. });
  30790. // Provide the compiled function's source by its `toString` method or
  30791. // the `source` property as a convenience for inlining compiled templates.
  30792. result.source = source;
  30793. if (isError(result)) {
  30794. throw result;
  30795. }
  30796. return result;
  30797. }
  30798. /**
  30799. * Converts `string`, as a whole, to lower case just like
  30800. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30801. *
  30802. * @static
  30803. * @memberOf _
  30804. * @since 4.0.0
  30805. * @category String
  30806. * @param {string} [string=''] The string to convert.
  30807. * @returns {string} Returns the lower cased string.
  30808. * @example
  30809. *
  30810. * _.toLower('--Foo-Bar--');
  30811. * // => '--foo-bar--'
  30812. *
  30813. * _.toLower('fooBar');
  30814. * // => 'foobar'
  30815. *
  30816. * _.toLower('__FOO_BAR__');
  30817. * // => '__foo_bar__'
  30818. */
  30819. function toLower(value) {
  30820. return toString(value).toLowerCase();
  30821. }
  30822. /**
  30823. * Converts `string`, as a whole, to upper case just like
  30824. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30825. *
  30826. * @static
  30827. * @memberOf _
  30828. * @since 4.0.0
  30829. * @category String
  30830. * @param {string} [string=''] The string to convert.
  30831. * @returns {string} Returns the upper cased string.
  30832. * @example
  30833. *
  30834. * _.toUpper('--foo-bar--');
  30835. * // => '--FOO-BAR--'
  30836. *
  30837. * _.toUpper('fooBar');
  30838. * // => 'FOOBAR'
  30839. *
  30840. * _.toUpper('__foo_bar__');
  30841. * // => '__FOO_BAR__'
  30842. */
  30843. function toUpper(value) {
  30844. return toString(value).toUpperCase();
  30845. }
  30846. /**
  30847. * Removes leading and trailing whitespace or specified characters from `string`.
  30848. *
  30849. * @static
  30850. * @memberOf _
  30851. * @since 3.0.0
  30852. * @category String
  30853. * @param {string} [string=''] The string to trim.
  30854. * @param {string} [chars=whitespace] The characters to trim.
  30855. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30856. * @returns {string} Returns the trimmed string.
  30857. * @example
  30858. *
  30859. * _.trim(' abc ');
  30860. * // => 'abc'
  30861. *
  30862. * _.trim('-_-abc-_-', '_-');
  30863. * // => 'abc'
  30864. *
  30865. * _.map([' foo ', ' bar '], _.trim);
  30866. * // => ['foo', 'bar']
  30867. */
  30868. function trim(string, chars, guard) {
  30869. string = toString(string);
  30870. if (string && (guard || chars === undefined)) {
  30871. return string.replace(reTrim, '');
  30872. }
  30873. if (!string || !(chars = baseToString(chars))) {
  30874. return string;
  30875. }
  30876. var strSymbols = stringToArray(string),
  30877. chrSymbols = stringToArray(chars),
  30878. start = charsStartIndex(strSymbols, chrSymbols),
  30879. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30880. return castSlice(strSymbols, start, end).join('');
  30881. }
  30882. /**
  30883. * Removes trailing whitespace or specified characters from `string`.
  30884. *
  30885. * @static
  30886. * @memberOf _
  30887. * @since 4.0.0
  30888. * @category String
  30889. * @param {string} [string=''] The string to trim.
  30890. * @param {string} [chars=whitespace] The characters to trim.
  30891. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30892. * @returns {string} Returns the trimmed string.
  30893. * @example
  30894. *
  30895. * _.trimEnd(' abc ');
  30896. * // => ' abc'
  30897. *
  30898. * _.trimEnd('-_-abc-_-', '_-');
  30899. * // => '-_-abc'
  30900. */
  30901. function trimEnd(string, chars, guard) {
  30902. string = toString(string);
  30903. if (string && (guard || chars === undefined)) {
  30904. return string.replace(reTrimEnd, '');
  30905. }
  30906. if (!string || !(chars = baseToString(chars))) {
  30907. return string;
  30908. }
  30909. var strSymbols = stringToArray(string),
  30910. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30911. return castSlice(strSymbols, 0, end).join('');
  30912. }
  30913. /**
  30914. * Removes leading whitespace or specified characters from `string`.
  30915. *
  30916. * @static
  30917. * @memberOf _
  30918. * @since 4.0.0
  30919. * @category String
  30920. * @param {string} [string=''] The string to trim.
  30921. * @param {string} [chars=whitespace] The characters to trim.
  30922. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30923. * @returns {string} Returns the trimmed string.
  30924. * @example
  30925. *
  30926. * _.trimStart(' abc ');
  30927. * // => 'abc '
  30928. *
  30929. * _.trimStart('-_-abc-_-', '_-');
  30930. * // => 'abc-_-'
  30931. */
  30932. function trimStart(string, chars, guard) {
  30933. string = toString(string);
  30934. if (string && (guard || chars === undefined)) {
  30935. return string.replace(reTrimStart, '');
  30936. }
  30937. if (!string || !(chars = baseToString(chars))) {
  30938. return string;
  30939. }
  30940. var strSymbols = stringToArray(string),
  30941. start = charsStartIndex(strSymbols, stringToArray(chars));
  30942. return castSlice(strSymbols, start).join('');
  30943. }
  30944. /**
  30945. * Truncates `string` if it's longer than the given maximum string length.
  30946. * The last characters of the truncated string are replaced with the omission
  30947. * string which defaults to "...".
  30948. *
  30949. * @static
  30950. * @memberOf _
  30951. * @since 4.0.0
  30952. * @category String
  30953. * @param {string} [string=''] The string to truncate.
  30954. * @param {Object} [options={}] The options object.
  30955. * @param {number} [options.length=30] The maximum string length.
  30956. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  30957. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  30958. * @returns {string} Returns the truncated string.
  30959. * @example
  30960. *
  30961. * _.truncate('hi-diddly-ho there, neighborino');
  30962. * // => 'hi-diddly-ho there, neighbo...'
  30963. *
  30964. * _.truncate('hi-diddly-ho there, neighborino', {
  30965. * 'length': 24,
  30966. * 'separator': ' '
  30967. * });
  30968. * // => 'hi-diddly-ho there,...'
  30969. *
  30970. * _.truncate('hi-diddly-ho there, neighborino', {
  30971. * 'length': 24,
  30972. * 'separator': /,? +/
  30973. * });
  30974. * // => 'hi-diddly-ho there...'
  30975. *
  30976. * _.truncate('hi-diddly-ho there, neighborino', {
  30977. * 'omission': ' [...]'
  30978. * });
  30979. * // => 'hi-diddly-ho there, neig [...]'
  30980. */
  30981. function truncate(string, options) {
  30982. var length = DEFAULT_TRUNC_LENGTH,
  30983. omission = DEFAULT_TRUNC_OMISSION;
  30984. if (isObject(options)) {
  30985. var separator = 'separator' in options ? options.separator : separator;
  30986. length = 'length' in options ? toInteger(options.length) : length;
  30987. omission = 'omission' in options ? baseToString(options.omission) : omission;
  30988. }
  30989. string = toString(string);
  30990. var strLength = string.length;
  30991. if (hasUnicode(string)) {
  30992. var strSymbols = stringToArray(string);
  30993. strLength = strSymbols.length;
  30994. }
  30995. if (length >= strLength) {
  30996. return string;
  30997. }
  30998. var end = length - stringSize(omission);
  30999. if (end < 1) {
  31000. return omission;
  31001. }
  31002. var result = strSymbols
  31003. ? castSlice(strSymbols, 0, end).join('')
  31004. : string.slice(0, end);
  31005. if (separator === undefined) {
  31006. return result + omission;
  31007. }
  31008. if (strSymbols) {
  31009. end += (result.length - end);
  31010. }
  31011. if (isRegExp(separator)) {
  31012. if (string.slice(end).search(separator)) {
  31013. var match,
  31014. substring = result;
  31015. if (!separator.global) {
  31016. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31017. }
  31018. separator.lastIndex = 0;
  31019. while ((match = separator.exec(substring))) {
  31020. var newEnd = match.index;
  31021. }
  31022. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31023. }
  31024. } else if (string.indexOf(baseToString(separator), end) != end) {
  31025. var index = result.lastIndexOf(separator);
  31026. if (index > -1) {
  31027. result = result.slice(0, index);
  31028. }
  31029. }
  31030. return result + omission;
  31031. }
  31032. /**
  31033. * The inverse of `_.escape`; this method converts the HTML entities
  31034. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31035. * their corresponding characters.
  31036. *
  31037. * **Note:** No other HTML entities are unescaped. To unescape additional
  31038. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31039. *
  31040. * @static
  31041. * @memberOf _
  31042. * @since 0.6.0
  31043. * @category String
  31044. * @param {string} [string=''] The string to unescape.
  31045. * @returns {string} Returns the unescaped string.
  31046. * @example
  31047. *
  31048. * _.unescape('fred, barney, &amp; pebbles');
  31049. * // => 'fred, barney, & pebbles'
  31050. */
  31051. function unescape(string) {
  31052. string = toString(string);
  31053. return (string && reHasEscapedHtml.test(string))
  31054. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31055. : string;
  31056. }
  31057. /**
  31058. * Converts `string`, as space separated words, to upper case.
  31059. *
  31060. * @static
  31061. * @memberOf _
  31062. * @since 4.0.0
  31063. * @category String
  31064. * @param {string} [string=''] The string to convert.
  31065. * @returns {string} Returns the upper cased string.
  31066. * @example
  31067. *
  31068. * _.upperCase('--foo-bar');
  31069. * // => 'FOO BAR'
  31070. *
  31071. * _.upperCase('fooBar');
  31072. * // => 'FOO BAR'
  31073. *
  31074. * _.upperCase('__foo_bar__');
  31075. * // => 'FOO BAR'
  31076. */
  31077. var upperCase = createCompounder(function(result, word, index) {
  31078. return result + (index ? ' ' : '') + word.toUpperCase();
  31079. });
  31080. /**
  31081. * Converts the first character of `string` to upper case.
  31082. *
  31083. * @static
  31084. * @memberOf _
  31085. * @since 4.0.0
  31086. * @category String
  31087. * @param {string} [string=''] The string to convert.
  31088. * @returns {string} Returns the converted string.
  31089. * @example
  31090. *
  31091. * _.upperFirst('fred');
  31092. * // => 'Fred'
  31093. *
  31094. * _.upperFirst('FRED');
  31095. * // => 'FRED'
  31096. */
  31097. var upperFirst = createCaseFirst('toUpperCase');
  31098. /**
  31099. * Splits `string` into an array of its words.
  31100. *
  31101. * @static
  31102. * @memberOf _
  31103. * @since 3.0.0
  31104. * @category String
  31105. * @param {string} [string=''] The string to inspect.
  31106. * @param {RegExp|string} [pattern] The pattern to match words.
  31107. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31108. * @returns {Array} Returns the words of `string`.
  31109. * @example
  31110. *
  31111. * _.words('fred, barney, & pebbles');
  31112. * // => ['fred', 'barney', 'pebbles']
  31113. *
  31114. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31115. * // => ['fred', 'barney', '&', 'pebbles']
  31116. */
  31117. function words(string, pattern, guard) {
  31118. string = toString(string);
  31119. pattern = guard ? undefined : pattern;
  31120. if (pattern === undefined) {
  31121. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31122. }
  31123. return string.match(pattern) || [];
  31124. }
  31125. /*------------------------------------------------------------------------*/
  31126. /**
  31127. * Attempts to invoke `func`, returning either the result or the caught error
  31128. * object. Any additional arguments are provided to `func` when it's invoked.
  31129. *
  31130. * @static
  31131. * @memberOf _
  31132. * @since 3.0.0
  31133. * @category Util
  31134. * @param {Function} func The function to attempt.
  31135. * @param {...*} [args] The arguments to invoke `func` with.
  31136. * @returns {*} Returns the `func` result or error object.
  31137. * @example
  31138. *
  31139. * // Avoid throwing errors for invalid selectors.
  31140. * var elements = _.attempt(function(selector) {
  31141. * return document.querySelectorAll(selector);
  31142. * }, '>_>');
  31143. *
  31144. * if (_.isError(elements)) {
  31145. * elements = [];
  31146. * }
  31147. */
  31148. var attempt = baseRest(function(func, args) {
  31149. try {
  31150. return apply(func, undefined, args);
  31151. } catch (e) {
  31152. return isError(e) ? e : new Error(e);
  31153. }
  31154. });
  31155. /**
  31156. * Binds methods of an object to the object itself, overwriting the existing
  31157. * method.
  31158. *
  31159. * **Note:** This method doesn't set the "length" property of bound functions.
  31160. *
  31161. * @static
  31162. * @since 0.1.0
  31163. * @memberOf _
  31164. * @category Util
  31165. * @param {Object} object The object to bind and assign the bound methods to.
  31166. * @param {...(string|string[])} methodNames The object method names to bind.
  31167. * @returns {Object} Returns `object`.
  31168. * @example
  31169. *
  31170. * var view = {
  31171. * 'label': 'docs',
  31172. * 'click': function() {
  31173. * console.log('clicked ' + this.label);
  31174. * }
  31175. * };
  31176. *
  31177. * _.bindAll(view, ['click']);
  31178. * jQuery(element).on('click', view.click);
  31179. * // => Logs 'clicked docs' when clicked.
  31180. */
  31181. var bindAll = flatRest(function(object, methodNames) {
  31182. arrayEach(methodNames, function(key) {
  31183. key = toKey(key);
  31184. baseAssignValue(object, key, bind(object[key], object));
  31185. });
  31186. return object;
  31187. });
  31188. /**
  31189. * Creates a function that iterates over `pairs` and invokes the corresponding
  31190. * function of the first predicate to return truthy. The predicate-function
  31191. * pairs are invoked with the `this` binding and arguments of the created
  31192. * function.
  31193. *
  31194. * @static
  31195. * @memberOf _
  31196. * @since 4.0.0
  31197. * @category Util
  31198. * @param {Array} pairs The predicate-function pairs.
  31199. * @returns {Function} Returns the new composite function.
  31200. * @example
  31201. *
  31202. * var func = _.cond([
  31203. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31204. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31205. * [_.stubTrue, _.constant('no match')]
  31206. * ]);
  31207. *
  31208. * func({ 'a': 1, 'b': 2 });
  31209. * // => 'matches A'
  31210. *
  31211. * func({ 'a': 0, 'b': 1 });
  31212. * // => 'matches B'
  31213. *
  31214. * func({ 'a': '1', 'b': '2' });
  31215. * // => 'no match'
  31216. */
  31217. function cond(pairs) {
  31218. var length = pairs == null ? 0 : pairs.length,
  31219. toIteratee = getIteratee();
  31220. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31221. if (typeof pair[1] != 'function') {
  31222. throw new TypeError(FUNC_ERROR_TEXT);
  31223. }
  31224. return [toIteratee(pair[0]), pair[1]];
  31225. });
  31226. return baseRest(function(args) {
  31227. var index = -1;
  31228. while (++index < length) {
  31229. var pair = pairs[index];
  31230. if (apply(pair[0], this, args)) {
  31231. return apply(pair[1], this, args);
  31232. }
  31233. }
  31234. });
  31235. }
  31236. /**
  31237. * Creates a function that invokes the predicate properties of `source` with
  31238. * the corresponding property values of a given object, returning `true` if
  31239. * all predicates return truthy, else `false`.
  31240. *
  31241. * **Note:** The created function is equivalent to `_.conformsTo` with
  31242. * `source` partially applied.
  31243. *
  31244. * @static
  31245. * @memberOf _
  31246. * @since 4.0.0
  31247. * @category Util
  31248. * @param {Object} source The object of property predicates to conform to.
  31249. * @returns {Function} Returns the new spec function.
  31250. * @example
  31251. *
  31252. * var objects = [
  31253. * { 'a': 2, 'b': 1 },
  31254. * { 'a': 1, 'b': 2 }
  31255. * ];
  31256. *
  31257. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31258. * // => [{ 'a': 1, 'b': 2 }]
  31259. */
  31260. function conforms(source) {
  31261. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31262. }
  31263. /**
  31264. * Creates a function that returns `value`.
  31265. *
  31266. * @static
  31267. * @memberOf _
  31268. * @since 2.4.0
  31269. * @category Util
  31270. * @param {*} value The value to return from the new function.
  31271. * @returns {Function} Returns the new constant function.
  31272. * @example
  31273. *
  31274. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31275. *
  31276. * console.log(objects);
  31277. * // => [{ 'a': 1 }, { 'a': 1 }]
  31278. *
  31279. * console.log(objects[0] === objects[1]);
  31280. * // => true
  31281. */
  31282. function constant(value) {
  31283. return function() {
  31284. return value;
  31285. };
  31286. }
  31287. /**
  31288. * Checks `value` to determine whether a default value should be returned in
  31289. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31290. * or `undefined`.
  31291. *
  31292. * @static
  31293. * @memberOf _
  31294. * @since 4.14.0
  31295. * @category Util
  31296. * @param {*} value The value to check.
  31297. * @param {*} defaultValue The default value.
  31298. * @returns {*} Returns the resolved value.
  31299. * @example
  31300. *
  31301. * _.defaultTo(1, 10);
  31302. * // => 1
  31303. *
  31304. * _.defaultTo(undefined, 10);
  31305. * // => 10
  31306. */
  31307. function defaultTo(value, defaultValue) {
  31308. return (value == null || value !== value) ? defaultValue : value;
  31309. }
  31310. /**
  31311. * Creates a function that returns the result of invoking the given functions
  31312. * with the `this` binding of the created function, where each successive
  31313. * invocation is supplied the return value of the previous.
  31314. *
  31315. * @static
  31316. * @memberOf _
  31317. * @since 3.0.0
  31318. * @category Util
  31319. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31320. * @returns {Function} Returns the new composite function.
  31321. * @see _.flowRight
  31322. * @example
  31323. *
  31324. * function square(n) {
  31325. * return n * n;
  31326. * }
  31327. *
  31328. * var addSquare = _.flow([_.add, square]);
  31329. * addSquare(1, 2);
  31330. * // => 9
  31331. */
  31332. var flow = createFlow();
  31333. /**
  31334. * This method is like `_.flow` except that it creates a function that
  31335. * invokes the given functions from right to left.
  31336. *
  31337. * @static
  31338. * @since 3.0.0
  31339. * @memberOf _
  31340. * @category Util
  31341. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31342. * @returns {Function} Returns the new composite function.
  31343. * @see _.flow
  31344. * @example
  31345. *
  31346. * function square(n) {
  31347. * return n * n;
  31348. * }
  31349. *
  31350. * var addSquare = _.flowRight([square, _.add]);
  31351. * addSquare(1, 2);
  31352. * // => 9
  31353. */
  31354. var flowRight = createFlow(true);
  31355. /**
  31356. * This method returns the first argument it receives.
  31357. *
  31358. * @static
  31359. * @since 0.1.0
  31360. * @memberOf _
  31361. * @category Util
  31362. * @param {*} value Any value.
  31363. * @returns {*} Returns `value`.
  31364. * @example
  31365. *
  31366. * var object = { 'a': 1 };
  31367. *
  31368. * console.log(_.identity(object) === object);
  31369. * // => true
  31370. */
  31371. function identity(value) {
  31372. return value;
  31373. }
  31374. /**
  31375. * Creates a function that invokes `func` with the arguments of the created
  31376. * function. If `func` is a property name, the created function returns the
  31377. * property value for a given element. If `func` is an array or object, the
  31378. * created function returns `true` for elements that contain the equivalent
  31379. * source properties, otherwise it returns `false`.
  31380. *
  31381. * @static
  31382. * @since 4.0.0
  31383. * @memberOf _
  31384. * @category Util
  31385. * @param {*} [func=_.identity] The value to convert to a callback.
  31386. * @returns {Function} Returns the callback.
  31387. * @example
  31388. *
  31389. * var users = [
  31390. * { 'user': 'barney', 'age': 36, 'active': true },
  31391. * { 'user': 'fred', 'age': 40, 'active': false }
  31392. * ];
  31393. *
  31394. * // The `_.matches` iteratee shorthand.
  31395. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31396. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31397. *
  31398. * // The `_.matchesProperty` iteratee shorthand.
  31399. * _.filter(users, _.iteratee(['user', 'fred']));
  31400. * // => [{ 'user': 'fred', 'age': 40 }]
  31401. *
  31402. * // The `_.property` iteratee shorthand.
  31403. * _.map(users, _.iteratee('user'));
  31404. * // => ['barney', 'fred']
  31405. *
  31406. * // Create custom iteratee shorthands.
  31407. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31408. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31409. * return func.test(string);
  31410. * };
  31411. * });
  31412. *
  31413. * _.filter(['abc', 'def'], /ef/);
  31414. * // => ['def']
  31415. */
  31416. function iteratee(func) {
  31417. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31418. }
  31419. /**
  31420. * Creates a function that performs a partial deep comparison between a given
  31421. * object and `source`, returning `true` if the given object has equivalent
  31422. * property values, else `false`.
  31423. *
  31424. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31425. * partially applied.
  31426. *
  31427. * Partial comparisons will match empty array and empty object `source`
  31428. * values against any array or object value, respectively. See `_.isEqual`
  31429. * for a list of supported value comparisons.
  31430. *
  31431. * @static
  31432. * @memberOf _
  31433. * @since 3.0.0
  31434. * @category Util
  31435. * @param {Object} source The object of property values to match.
  31436. * @returns {Function} Returns the new spec function.
  31437. * @example
  31438. *
  31439. * var objects = [
  31440. * { 'a': 1, 'b': 2, 'c': 3 },
  31441. * { 'a': 4, 'b': 5, 'c': 6 }
  31442. * ];
  31443. *
  31444. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31445. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31446. */
  31447. function matches(source) {
  31448. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31449. }
  31450. /**
  31451. * Creates a function that performs a partial deep comparison between the
  31452. * value at `path` of a given object to `srcValue`, returning `true` if the
  31453. * object value is equivalent, else `false`.
  31454. *
  31455. * **Note:** Partial comparisons will match empty array and empty object
  31456. * `srcValue` values against any array or object value, respectively. See
  31457. * `_.isEqual` for a list of supported value comparisons.
  31458. *
  31459. * @static
  31460. * @memberOf _
  31461. * @since 3.2.0
  31462. * @category Util
  31463. * @param {Array|string} path The path of the property to get.
  31464. * @param {*} srcValue The value to match.
  31465. * @returns {Function} Returns the new spec function.
  31466. * @example
  31467. *
  31468. * var objects = [
  31469. * { 'a': 1, 'b': 2, 'c': 3 },
  31470. * { 'a': 4, 'b': 5, 'c': 6 }
  31471. * ];
  31472. *
  31473. * _.find(objects, _.matchesProperty('a', 4));
  31474. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31475. */
  31476. function matchesProperty(path, srcValue) {
  31477. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31478. }
  31479. /**
  31480. * Creates a function that invokes the method at `path` of a given object.
  31481. * Any additional arguments are provided to the invoked method.
  31482. *
  31483. * @static
  31484. * @memberOf _
  31485. * @since 3.7.0
  31486. * @category Util
  31487. * @param {Array|string} path The path of the method to invoke.
  31488. * @param {...*} [args] The arguments to invoke the method with.
  31489. * @returns {Function} Returns the new invoker function.
  31490. * @example
  31491. *
  31492. * var objects = [
  31493. * { 'a': { 'b': _.constant(2) } },
  31494. * { 'a': { 'b': _.constant(1) } }
  31495. * ];
  31496. *
  31497. * _.map(objects, _.method('a.b'));
  31498. * // => [2, 1]
  31499. *
  31500. * _.map(objects, _.method(['a', 'b']));
  31501. * // => [2, 1]
  31502. */
  31503. var method = baseRest(function(path, args) {
  31504. return function(object) {
  31505. return baseInvoke(object, path, args);
  31506. };
  31507. });
  31508. /**
  31509. * The opposite of `_.method`; this method creates a function that invokes
  31510. * the method at a given path of `object`. Any additional arguments are
  31511. * provided to the invoked method.
  31512. *
  31513. * @static
  31514. * @memberOf _
  31515. * @since 3.7.0
  31516. * @category Util
  31517. * @param {Object} object The object to query.
  31518. * @param {...*} [args] The arguments to invoke the method with.
  31519. * @returns {Function} Returns the new invoker function.
  31520. * @example
  31521. *
  31522. * var array = _.times(3, _.constant),
  31523. * object = { 'a': array, 'b': array, 'c': array };
  31524. *
  31525. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31526. * // => [2, 0]
  31527. *
  31528. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31529. * // => [2, 0]
  31530. */
  31531. var methodOf = baseRest(function(object, args) {
  31532. return function(path) {
  31533. return baseInvoke(object, path, args);
  31534. };
  31535. });
  31536. /**
  31537. * Adds all own enumerable string keyed function properties of a source
  31538. * object to the destination object. If `object` is a function, then methods
  31539. * are added to its prototype as well.
  31540. *
  31541. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31542. * avoid conflicts caused by modifying the original.
  31543. *
  31544. * @static
  31545. * @since 0.1.0
  31546. * @memberOf _
  31547. * @category Util
  31548. * @param {Function|Object} [object=lodash] The destination object.
  31549. * @param {Object} source The object of functions to add.
  31550. * @param {Object} [options={}] The options object.
  31551. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31552. * @returns {Function|Object} Returns `object`.
  31553. * @example
  31554. *
  31555. * function vowels(string) {
  31556. * return _.filter(string, function(v) {
  31557. * return /[aeiou]/i.test(v);
  31558. * });
  31559. * }
  31560. *
  31561. * _.mixin({ 'vowels': vowels });
  31562. * _.vowels('fred');
  31563. * // => ['e']
  31564. *
  31565. * _('fred').vowels().value();
  31566. * // => ['e']
  31567. *
  31568. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31569. * _('fred').vowels();
  31570. * // => ['e']
  31571. */
  31572. function mixin(object, source, options) {
  31573. var props = keys(source),
  31574. methodNames = baseFunctions(source, props);
  31575. if (options == null &&
  31576. !(isObject(source) && (methodNames.length || !props.length))) {
  31577. options = source;
  31578. source = object;
  31579. object = this;
  31580. methodNames = baseFunctions(source, keys(source));
  31581. }
  31582. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31583. isFunc = isFunction(object);
  31584. arrayEach(methodNames, function(methodName) {
  31585. var func = source[methodName];
  31586. object[methodName] = func;
  31587. if (isFunc) {
  31588. object.prototype[methodName] = function() {
  31589. var chainAll = this.__chain__;
  31590. if (chain || chainAll) {
  31591. var result = object(this.__wrapped__),
  31592. actions = result.__actions__ = copyArray(this.__actions__);
  31593. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31594. result.__chain__ = chainAll;
  31595. return result;
  31596. }
  31597. return func.apply(object, arrayPush([this.value()], arguments));
  31598. };
  31599. }
  31600. });
  31601. return object;
  31602. }
  31603. /**
  31604. * Reverts the `_` variable to its previous value and returns a reference to
  31605. * the `lodash` function.
  31606. *
  31607. * @static
  31608. * @since 0.1.0
  31609. * @memberOf _
  31610. * @category Util
  31611. * @returns {Function} Returns the `lodash` function.
  31612. * @example
  31613. *
  31614. * var lodash = _.noConflict();
  31615. */
  31616. function noConflict() {
  31617. if (root._ === this) {
  31618. root._ = oldDash;
  31619. }
  31620. return this;
  31621. }
  31622. /**
  31623. * This method returns `undefined`.
  31624. *
  31625. * @static
  31626. * @memberOf _
  31627. * @since 2.3.0
  31628. * @category Util
  31629. * @example
  31630. *
  31631. * _.times(2, _.noop);
  31632. * // => [undefined, undefined]
  31633. */
  31634. function noop() {
  31635. // No operation performed.
  31636. }
  31637. /**
  31638. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31639. * the nth argument from the end is returned.
  31640. *
  31641. * @static
  31642. * @memberOf _
  31643. * @since 4.0.0
  31644. * @category Util
  31645. * @param {number} [n=0] The index of the argument to return.
  31646. * @returns {Function} Returns the new pass-thru function.
  31647. * @example
  31648. *
  31649. * var func = _.nthArg(1);
  31650. * func('a', 'b', 'c', 'd');
  31651. * // => 'b'
  31652. *
  31653. * var func = _.nthArg(-2);
  31654. * func('a', 'b', 'c', 'd');
  31655. * // => 'c'
  31656. */
  31657. function nthArg(n) {
  31658. n = toInteger(n);
  31659. return baseRest(function(args) {
  31660. return baseNth(args, n);
  31661. });
  31662. }
  31663. /**
  31664. * Creates a function that invokes `iteratees` with the arguments it receives
  31665. * and returns their results.
  31666. *
  31667. * @static
  31668. * @memberOf _
  31669. * @since 4.0.0
  31670. * @category Util
  31671. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31672. * The iteratees to invoke.
  31673. * @returns {Function} Returns the new function.
  31674. * @example
  31675. *
  31676. * var func = _.over([Math.max, Math.min]);
  31677. *
  31678. * func(1, 2, 3, 4);
  31679. * // => [4, 1]
  31680. */
  31681. var over = createOver(arrayMap);
  31682. /**
  31683. * Creates a function that checks if **all** of the `predicates` return
  31684. * truthy when invoked with the arguments it receives.
  31685. *
  31686. * @static
  31687. * @memberOf _
  31688. * @since 4.0.0
  31689. * @category Util
  31690. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31691. * The predicates to check.
  31692. * @returns {Function} Returns the new function.
  31693. * @example
  31694. *
  31695. * var func = _.overEvery([Boolean, isFinite]);
  31696. *
  31697. * func('1');
  31698. * // => true
  31699. *
  31700. * func(null);
  31701. * // => false
  31702. *
  31703. * func(NaN);
  31704. * // => false
  31705. */
  31706. var overEvery = createOver(arrayEvery);
  31707. /**
  31708. * Creates a function that checks if **any** of the `predicates` return
  31709. * truthy when invoked with the arguments it receives.
  31710. *
  31711. * @static
  31712. * @memberOf _
  31713. * @since 4.0.0
  31714. * @category Util
  31715. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31716. * The predicates to check.
  31717. * @returns {Function} Returns the new function.
  31718. * @example
  31719. *
  31720. * var func = _.overSome([Boolean, isFinite]);
  31721. *
  31722. * func('1');
  31723. * // => true
  31724. *
  31725. * func(null);
  31726. * // => true
  31727. *
  31728. * func(NaN);
  31729. * // => false
  31730. */
  31731. var overSome = createOver(arraySome);
  31732. /**
  31733. * Creates a function that returns the value at `path` of a given object.
  31734. *
  31735. * @static
  31736. * @memberOf _
  31737. * @since 2.4.0
  31738. * @category Util
  31739. * @param {Array|string} path The path of the property to get.
  31740. * @returns {Function} Returns the new accessor function.
  31741. * @example
  31742. *
  31743. * var objects = [
  31744. * { 'a': { 'b': 2 } },
  31745. * { 'a': { 'b': 1 } }
  31746. * ];
  31747. *
  31748. * _.map(objects, _.property('a.b'));
  31749. * // => [2, 1]
  31750. *
  31751. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31752. * // => [1, 2]
  31753. */
  31754. function property(path) {
  31755. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31756. }
  31757. /**
  31758. * The opposite of `_.property`; this method creates a function that returns
  31759. * the value at a given path of `object`.
  31760. *
  31761. * @static
  31762. * @memberOf _
  31763. * @since 3.0.0
  31764. * @category Util
  31765. * @param {Object} object The object to query.
  31766. * @returns {Function} Returns the new accessor function.
  31767. * @example
  31768. *
  31769. * var array = [0, 1, 2],
  31770. * object = { 'a': array, 'b': array, 'c': array };
  31771. *
  31772. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31773. * // => [2, 0]
  31774. *
  31775. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31776. * // => [2, 0]
  31777. */
  31778. function propertyOf(object) {
  31779. return function(path) {
  31780. return object == null ? undefined : baseGet(object, path);
  31781. };
  31782. }
  31783. /**
  31784. * Creates an array of numbers (positive and/or negative) progressing from
  31785. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31786. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31787. * it's set to `start` with `start` then set to `0`.
  31788. *
  31789. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31790. * floating-point values which can produce unexpected results.
  31791. *
  31792. * @static
  31793. * @since 0.1.0
  31794. * @memberOf _
  31795. * @category Util
  31796. * @param {number} [start=0] The start of the range.
  31797. * @param {number} end The end of the range.
  31798. * @param {number} [step=1] The value to increment or decrement by.
  31799. * @returns {Array} Returns the range of numbers.
  31800. * @see _.inRange, _.rangeRight
  31801. * @example
  31802. *
  31803. * _.range(4);
  31804. * // => [0, 1, 2, 3]
  31805. *
  31806. * _.range(-4);
  31807. * // => [0, -1, -2, -3]
  31808. *
  31809. * _.range(1, 5);
  31810. * // => [1, 2, 3, 4]
  31811. *
  31812. * _.range(0, 20, 5);
  31813. * // => [0, 5, 10, 15]
  31814. *
  31815. * _.range(0, -4, -1);
  31816. * // => [0, -1, -2, -3]
  31817. *
  31818. * _.range(1, 4, 0);
  31819. * // => [1, 1, 1]
  31820. *
  31821. * _.range(0);
  31822. * // => []
  31823. */
  31824. var range = createRange();
  31825. /**
  31826. * This method is like `_.range` except that it populates values in
  31827. * descending order.
  31828. *
  31829. * @static
  31830. * @memberOf _
  31831. * @since 4.0.0
  31832. * @category Util
  31833. * @param {number} [start=0] The start of the range.
  31834. * @param {number} end The end of the range.
  31835. * @param {number} [step=1] The value to increment or decrement by.
  31836. * @returns {Array} Returns the range of numbers.
  31837. * @see _.inRange, _.range
  31838. * @example
  31839. *
  31840. * _.rangeRight(4);
  31841. * // => [3, 2, 1, 0]
  31842. *
  31843. * _.rangeRight(-4);
  31844. * // => [-3, -2, -1, 0]
  31845. *
  31846. * _.rangeRight(1, 5);
  31847. * // => [4, 3, 2, 1]
  31848. *
  31849. * _.rangeRight(0, 20, 5);
  31850. * // => [15, 10, 5, 0]
  31851. *
  31852. * _.rangeRight(0, -4, -1);
  31853. * // => [-3, -2, -1, 0]
  31854. *
  31855. * _.rangeRight(1, 4, 0);
  31856. * // => [1, 1, 1]
  31857. *
  31858. * _.rangeRight(0);
  31859. * // => []
  31860. */
  31861. var rangeRight = createRange(true);
  31862. /**
  31863. * This method returns a new empty array.
  31864. *
  31865. * @static
  31866. * @memberOf _
  31867. * @since 4.13.0
  31868. * @category Util
  31869. * @returns {Array} Returns the new empty array.
  31870. * @example
  31871. *
  31872. * var arrays = _.times(2, _.stubArray);
  31873. *
  31874. * console.log(arrays);
  31875. * // => [[], []]
  31876. *
  31877. * console.log(arrays[0] === arrays[1]);
  31878. * // => false
  31879. */
  31880. function stubArray() {
  31881. return [];
  31882. }
  31883. /**
  31884. * This method returns `false`.
  31885. *
  31886. * @static
  31887. * @memberOf _
  31888. * @since 4.13.0
  31889. * @category Util
  31890. * @returns {boolean} Returns `false`.
  31891. * @example
  31892. *
  31893. * _.times(2, _.stubFalse);
  31894. * // => [false, false]
  31895. */
  31896. function stubFalse() {
  31897. return false;
  31898. }
  31899. /**
  31900. * This method returns a new empty object.
  31901. *
  31902. * @static
  31903. * @memberOf _
  31904. * @since 4.13.0
  31905. * @category Util
  31906. * @returns {Object} Returns the new empty object.
  31907. * @example
  31908. *
  31909. * var objects = _.times(2, _.stubObject);
  31910. *
  31911. * console.log(objects);
  31912. * // => [{}, {}]
  31913. *
  31914. * console.log(objects[0] === objects[1]);
  31915. * // => false
  31916. */
  31917. function stubObject() {
  31918. return {};
  31919. }
  31920. /**
  31921. * This method returns an empty string.
  31922. *
  31923. * @static
  31924. * @memberOf _
  31925. * @since 4.13.0
  31926. * @category Util
  31927. * @returns {string} Returns the empty string.
  31928. * @example
  31929. *
  31930. * _.times(2, _.stubString);
  31931. * // => ['', '']
  31932. */
  31933. function stubString() {
  31934. return '';
  31935. }
  31936. /**
  31937. * This method returns `true`.
  31938. *
  31939. * @static
  31940. * @memberOf _
  31941. * @since 4.13.0
  31942. * @category Util
  31943. * @returns {boolean} Returns `true`.
  31944. * @example
  31945. *
  31946. * _.times(2, _.stubTrue);
  31947. * // => [true, true]
  31948. */
  31949. function stubTrue() {
  31950. return true;
  31951. }
  31952. /**
  31953. * Invokes the iteratee `n` times, returning an array of the results of
  31954. * each invocation. The iteratee is invoked with one argument; (index).
  31955. *
  31956. * @static
  31957. * @since 0.1.0
  31958. * @memberOf _
  31959. * @category Util
  31960. * @param {number} n The number of times to invoke `iteratee`.
  31961. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  31962. * @returns {Array} Returns the array of results.
  31963. * @example
  31964. *
  31965. * _.times(3, String);
  31966. * // => ['0', '1', '2']
  31967. *
  31968. * _.times(4, _.constant(0));
  31969. * // => [0, 0, 0, 0]
  31970. */
  31971. function times(n, iteratee) {
  31972. n = toInteger(n);
  31973. if (n < 1 || n > MAX_SAFE_INTEGER) {
  31974. return [];
  31975. }
  31976. var index = MAX_ARRAY_LENGTH,
  31977. length = nativeMin(n, MAX_ARRAY_LENGTH);
  31978. iteratee = getIteratee(iteratee);
  31979. n -= MAX_ARRAY_LENGTH;
  31980. var result = baseTimes(length, iteratee);
  31981. while (++index < n) {
  31982. iteratee(index);
  31983. }
  31984. return result;
  31985. }
  31986. /**
  31987. * Converts `value` to a property path array.
  31988. *
  31989. * @static
  31990. * @memberOf _
  31991. * @since 4.0.0
  31992. * @category Util
  31993. * @param {*} value The value to convert.
  31994. * @returns {Array} Returns the new property path array.
  31995. * @example
  31996. *
  31997. * _.toPath('a.b.c');
  31998. * // => ['a', 'b', 'c']
  31999. *
  32000. * _.toPath('a[0].b.c');
  32001. * // => ['a', '0', 'b', 'c']
  32002. */
  32003. function toPath(value) {
  32004. if (isArray(value)) {
  32005. return arrayMap(value, toKey);
  32006. }
  32007. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32008. }
  32009. /**
  32010. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32011. *
  32012. * @static
  32013. * @since 0.1.0
  32014. * @memberOf _
  32015. * @category Util
  32016. * @param {string} [prefix=''] The value to prefix the ID with.
  32017. * @returns {string} Returns the unique ID.
  32018. * @example
  32019. *
  32020. * _.uniqueId('contact_');
  32021. * // => 'contact_104'
  32022. *
  32023. * _.uniqueId();
  32024. * // => '105'
  32025. */
  32026. function uniqueId(prefix) {
  32027. var id = ++idCounter;
  32028. return toString(prefix) + id;
  32029. }
  32030. /*------------------------------------------------------------------------*/
  32031. /**
  32032. * Adds two numbers.
  32033. *
  32034. * @static
  32035. * @memberOf _
  32036. * @since 3.4.0
  32037. * @category Math
  32038. * @param {number} augend The first number in an addition.
  32039. * @param {number} addend The second number in an addition.
  32040. * @returns {number} Returns the total.
  32041. * @example
  32042. *
  32043. * _.add(6, 4);
  32044. * // => 10
  32045. */
  32046. var add = createMathOperation(function(augend, addend) {
  32047. return augend + addend;
  32048. }, 0);
  32049. /**
  32050. * Computes `number` rounded up to `precision`.
  32051. *
  32052. * @static
  32053. * @memberOf _
  32054. * @since 3.10.0
  32055. * @category Math
  32056. * @param {number} number The number to round up.
  32057. * @param {number} [precision=0] The precision to round up to.
  32058. * @returns {number} Returns the rounded up number.
  32059. * @example
  32060. *
  32061. * _.ceil(4.006);
  32062. * // => 5
  32063. *
  32064. * _.ceil(6.004, 2);
  32065. * // => 6.01
  32066. *
  32067. * _.ceil(6040, -2);
  32068. * // => 6100
  32069. */
  32070. var ceil = createRound('ceil');
  32071. /**
  32072. * Divide two numbers.
  32073. *
  32074. * @static
  32075. * @memberOf _
  32076. * @since 4.7.0
  32077. * @category Math
  32078. * @param {number} dividend The first number in a division.
  32079. * @param {number} divisor The second number in a division.
  32080. * @returns {number} Returns the quotient.
  32081. * @example
  32082. *
  32083. * _.divide(6, 4);
  32084. * // => 1.5
  32085. */
  32086. var divide = createMathOperation(function(dividend, divisor) {
  32087. return dividend / divisor;
  32088. }, 1);
  32089. /**
  32090. * Computes `number` rounded down to `precision`.
  32091. *
  32092. * @static
  32093. * @memberOf _
  32094. * @since 3.10.0
  32095. * @category Math
  32096. * @param {number} number The number to round down.
  32097. * @param {number} [precision=0] The precision to round down to.
  32098. * @returns {number} Returns the rounded down number.
  32099. * @example
  32100. *
  32101. * _.floor(4.006);
  32102. * // => 4
  32103. *
  32104. * _.floor(0.046, 2);
  32105. * // => 0.04
  32106. *
  32107. * _.floor(4060, -2);
  32108. * // => 4000
  32109. */
  32110. var floor = createRound('floor');
  32111. /**
  32112. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32113. * `undefined` is returned.
  32114. *
  32115. * @static
  32116. * @since 0.1.0
  32117. * @memberOf _
  32118. * @category Math
  32119. * @param {Array} array The array to iterate over.
  32120. * @returns {*} Returns the maximum value.
  32121. * @example
  32122. *
  32123. * _.max([4, 2, 8, 6]);
  32124. * // => 8
  32125. *
  32126. * _.max([]);
  32127. * // => undefined
  32128. */
  32129. function max(array) {
  32130. return (array && array.length)
  32131. ? baseExtremum(array, identity, baseGt)
  32132. : undefined;
  32133. }
  32134. /**
  32135. * This method is like `_.max` except that it accepts `iteratee` which is
  32136. * invoked for each element in `array` to generate the criterion by which
  32137. * the value is ranked. The iteratee is invoked with one argument: (value).
  32138. *
  32139. * @static
  32140. * @memberOf _
  32141. * @since 4.0.0
  32142. * @category Math
  32143. * @param {Array} array The array to iterate over.
  32144. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32145. * @returns {*} Returns the maximum value.
  32146. * @example
  32147. *
  32148. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32149. *
  32150. * _.maxBy(objects, function(o) { return o.n; });
  32151. * // => { 'n': 2 }
  32152. *
  32153. * // The `_.property` iteratee shorthand.
  32154. * _.maxBy(objects, 'n');
  32155. * // => { 'n': 2 }
  32156. */
  32157. function maxBy(array, iteratee) {
  32158. return (array && array.length)
  32159. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32160. : undefined;
  32161. }
  32162. /**
  32163. * Computes the mean of the values in `array`.
  32164. *
  32165. * @static
  32166. * @memberOf _
  32167. * @since 4.0.0
  32168. * @category Math
  32169. * @param {Array} array The array to iterate over.
  32170. * @returns {number} Returns the mean.
  32171. * @example
  32172. *
  32173. * _.mean([4, 2, 8, 6]);
  32174. * // => 5
  32175. */
  32176. function mean(array) {
  32177. return baseMean(array, identity);
  32178. }
  32179. /**
  32180. * This method is like `_.mean` except that it accepts `iteratee` which is
  32181. * invoked for each element in `array` to generate the value to be averaged.
  32182. * The iteratee is invoked with one argument: (value).
  32183. *
  32184. * @static
  32185. * @memberOf _
  32186. * @since 4.7.0
  32187. * @category Math
  32188. * @param {Array} array The array to iterate over.
  32189. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32190. * @returns {number} Returns the mean.
  32191. * @example
  32192. *
  32193. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32194. *
  32195. * _.meanBy(objects, function(o) { return o.n; });
  32196. * // => 5
  32197. *
  32198. * // The `_.property` iteratee shorthand.
  32199. * _.meanBy(objects, 'n');
  32200. * // => 5
  32201. */
  32202. function meanBy(array, iteratee) {
  32203. return baseMean(array, getIteratee(iteratee, 2));
  32204. }
  32205. /**
  32206. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32207. * `undefined` is returned.
  32208. *
  32209. * @static
  32210. * @since 0.1.0
  32211. * @memberOf _
  32212. * @category Math
  32213. * @param {Array} array The array to iterate over.
  32214. * @returns {*} Returns the minimum value.
  32215. * @example
  32216. *
  32217. * _.min([4, 2, 8, 6]);
  32218. * // => 2
  32219. *
  32220. * _.min([]);
  32221. * // => undefined
  32222. */
  32223. function min(array) {
  32224. return (array && array.length)
  32225. ? baseExtremum(array, identity, baseLt)
  32226. : undefined;
  32227. }
  32228. /**
  32229. * This method is like `_.min` except that it accepts `iteratee` which is
  32230. * invoked for each element in `array` to generate the criterion by which
  32231. * the value is ranked. The iteratee is invoked with one argument: (value).
  32232. *
  32233. * @static
  32234. * @memberOf _
  32235. * @since 4.0.0
  32236. * @category Math
  32237. * @param {Array} array The array to iterate over.
  32238. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32239. * @returns {*} Returns the minimum value.
  32240. * @example
  32241. *
  32242. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32243. *
  32244. * _.minBy(objects, function(o) { return o.n; });
  32245. * // => { 'n': 1 }
  32246. *
  32247. * // The `_.property` iteratee shorthand.
  32248. * _.minBy(objects, 'n');
  32249. * // => { 'n': 1 }
  32250. */
  32251. function minBy(array, iteratee) {
  32252. return (array && array.length)
  32253. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32254. : undefined;
  32255. }
  32256. /**
  32257. * Multiply two numbers.
  32258. *
  32259. * @static
  32260. * @memberOf _
  32261. * @since 4.7.0
  32262. * @category Math
  32263. * @param {number} multiplier The first number in a multiplication.
  32264. * @param {number} multiplicand The second number in a multiplication.
  32265. * @returns {number} Returns the product.
  32266. * @example
  32267. *
  32268. * _.multiply(6, 4);
  32269. * // => 24
  32270. */
  32271. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32272. return multiplier * multiplicand;
  32273. }, 1);
  32274. /**
  32275. * Computes `number` rounded to `precision`.
  32276. *
  32277. * @static
  32278. * @memberOf _
  32279. * @since 3.10.0
  32280. * @category Math
  32281. * @param {number} number The number to round.
  32282. * @param {number} [precision=0] The precision to round to.
  32283. * @returns {number} Returns the rounded number.
  32284. * @example
  32285. *
  32286. * _.round(4.006);
  32287. * // => 4
  32288. *
  32289. * _.round(4.006, 2);
  32290. * // => 4.01
  32291. *
  32292. * _.round(4060, -2);
  32293. * // => 4100
  32294. */
  32295. var round = createRound('round');
  32296. /**
  32297. * Subtract two numbers.
  32298. *
  32299. * @static
  32300. * @memberOf _
  32301. * @since 4.0.0
  32302. * @category Math
  32303. * @param {number} minuend The first number in a subtraction.
  32304. * @param {number} subtrahend The second number in a subtraction.
  32305. * @returns {number} Returns the difference.
  32306. * @example
  32307. *
  32308. * _.subtract(6, 4);
  32309. * // => 2
  32310. */
  32311. var subtract = createMathOperation(function(minuend, subtrahend) {
  32312. return minuend - subtrahend;
  32313. }, 0);
  32314. /**
  32315. * Computes the sum of the values in `array`.
  32316. *
  32317. * @static
  32318. * @memberOf _
  32319. * @since 3.4.0
  32320. * @category Math
  32321. * @param {Array} array The array to iterate over.
  32322. * @returns {number} Returns the sum.
  32323. * @example
  32324. *
  32325. * _.sum([4, 2, 8, 6]);
  32326. * // => 20
  32327. */
  32328. function sum(array) {
  32329. return (array && array.length)
  32330. ? baseSum(array, identity)
  32331. : 0;
  32332. }
  32333. /**
  32334. * This method is like `_.sum` except that it accepts `iteratee` which is
  32335. * invoked for each element in `array` to generate the value to be summed.
  32336. * The iteratee is invoked with one argument: (value).
  32337. *
  32338. * @static
  32339. * @memberOf _
  32340. * @since 4.0.0
  32341. * @category Math
  32342. * @param {Array} array The array to iterate over.
  32343. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32344. * @returns {number} Returns the sum.
  32345. * @example
  32346. *
  32347. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32348. *
  32349. * _.sumBy(objects, function(o) { return o.n; });
  32350. * // => 20
  32351. *
  32352. * // The `_.property` iteratee shorthand.
  32353. * _.sumBy(objects, 'n');
  32354. * // => 20
  32355. */
  32356. function sumBy(array, iteratee) {
  32357. return (array && array.length)
  32358. ? baseSum(array, getIteratee(iteratee, 2))
  32359. : 0;
  32360. }
  32361. /*------------------------------------------------------------------------*/
  32362. // Add methods that return wrapped values in chain sequences.
  32363. lodash.after = after;
  32364. lodash.ary = ary;
  32365. lodash.assign = assign;
  32366. lodash.assignIn = assignIn;
  32367. lodash.assignInWith = assignInWith;
  32368. lodash.assignWith = assignWith;
  32369. lodash.at = at;
  32370. lodash.before = before;
  32371. lodash.bind = bind;
  32372. lodash.bindAll = bindAll;
  32373. lodash.bindKey = bindKey;
  32374. lodash.castArray = castArray;
  32375. lodash.chain = chain;
  32376. lodash.chunk = chunk;
  32377. lodash.compact = compact;
  32378. lodash.concat = concat;
  32379. lodash.cond = cond;
  32380. lodash.conforms = conforms;
  32381. lodash.constant = constant;
  32382. lodash.countBy = countBy;
  32383. lodash.create = create;
  32384. lodash.curry = curry;
  32385. lodash.curryRight = curryRight;
  32386. lodash.debounce = debounce;
  32387. lodash.defaults = defaults;
  32388. lodash.defaultsDeep = defaultsDeep;
  32389. lodash.defer = defer;
  32390. lodash.delay = delay;
  32391. lodash.difference = difference;
  32392. lodash.differenceBy = differenceBy;
  32393. lodash.differenceWith = differenceWith;
  32394. lodash.drop = drop;
  32395. lodash.dropRight = dropRight;
  32396. lodash.dropRightWhile = dropRightWhile;
  32397. lodash.dropWhile = dropWhile;
  32398. lodash.fill = fill;
  32399. lodash.filter = filter;
  32400. lodash.flatMap = flatMap;
  32401. lodash.flatMapDeep = flatMapDeep;
  32402. lodash.flatMapDepth = flatMapDepth;
  32403. lodash.flatten = flatten;
  32404. lodash.flattenDeep = flattenDeep;
  32405. lodash.flattenDepth = flattenDepth;
  32406. lodash.flip = flip;
  32407. lodash.flow = flow;
  32408. lodash.flowRight = flowRight;
  32409. lodash.fromPairs = fromPairs;
  32410. lodash.functions = functions;
  32411. lodash.functionsIn = functionsIn;
  32412. lodash.groupBy = groupBy;
  32413. lodash.initial = initial;
  32414. lodash.intersection = intersection;
  32415. lodash.intersectionBy = intersectionBy;
  32416. lodash.intersectionWith = intersectionWith;
  32417. lodash.invert = invert;
  32418. lodash.invertBy = invertBy;
  32419. lodash.invokeMap = invokeMap;
  32420. lodash.iteratee = iteratee;
  32421. lodash.keyBy = keyBy;
  32422. lodash.keys = keys;
  32423. lodash.keysIn = keysIn;
  32424. lodash.map = map;
  32425. lodash.mapKeys = mapKeys;
  32426. lodash.mapValues = mapValues;
  32427. lodash.matches = matches;
  32428. lodash.matchesProperty = matchesProperty;
  32429. lodash.memoize = memoize;
  32430. lodash.merge = merge;
  32431. lodash.mergeWith = mergeWith;
  32432. lodash.method = method;
  32433. lodash.methodOf = methodOf;
  32434. lodash.mixin = mixin;
  32435. lodash.negate = negate;
  32436. lodash.nthArg = nthArg;
  32437. lodash.omit = omit;
  32438. lodash.omitBy = omitBy;
  32439. lodash.once = once;
  32440. lodash.orderBy = orderBy;
  32441. lodash.over = over;
  32442. lodash.overArgs = overArgs;
  32443. lodash.overEvery = overEvery;
  32444. lodash.overSome = overSome;
  32445. lodash.partial = partial;
  32446. lodash.partialRight = partialRight;
  32447. lodash.partition = partition;
  32448. lodash.pick = pick;
  32449. lodash.pickBy = pickBy;
  32450. lodash.property = property;
  32451. lodash.propertyOf = propertyOf;
  32452. lodash.pull = pull;
  32453. lodash.pullAll = pullAll;
  32454. lodash.pullAllBy = pullAllBy;
  32455. lodash.pullAllWith = pullAllWith;
  32456. lodash.pullAt = pullAt;
  32457. lodash.range = range;
  32458. lodash.rangeRight = rangeRight;
  32459. lodash.rearg = rearg;
  32460. lodash.reject = reject;
  32461. lodash.remove = remove;
  32462. lodash.rest = rest;
  32463. lodash.reverse = reverse;
  32464. lodash.sampleSize = sampleSize;
  32465. lodash.set = set;
  32466. lodash.setWith = setWith;
  32467. lodash.shuffle = shuffle;
  32468. lodash.slice = slice;
  32469. lodash.sortBy = sortBy;
  32470. lodash.sortedUniq = sortedUniq;
  32471. lodash.sortedUniqBy = sortedUniqBy;
  32472. lodash.split = split;
  32473. lodash.spread = spread;
  32474. lodash.tail = tail;
  32475. lodash.take = take;
  32476. lodash.takeRight = takeRight;
  32477. lodash.takeRightWhile = takeRightWhile;
  32478. lodash.takeWhile = takeWhile;
  32479. lodash.tap = tap;
  32480. lodash.throttle = throttle;
  32481. lodash.thru = thru;
  32482. lodash.toArray = toArray;
  32483. lodash.toPairs = toPairs;
  32484. lodash.toPairsIn = toPairsIn;
  32485. lodash.toPath = toPath;
  32486. lodash.toPlainObject = toPlainObject;
  32487. lodash.transform = transform;
  32488. lodash.unary = unary;
  32489. lodash.union = union;
  32490. lodash.unionBy = unionBy;
  32491. lodash.unionWith = unionWith;
  32492. lodash.uniq = uniq;
  32493. lodash.uniqBy = uniqBy;
  32494. lodash.uniqWith = uniqWith;
  32495. lodash.unset = unset;
  32496. lodash.unzip = unzip;
  32497. lodash.unzipWith = unzipWith;
  32498. lodash.update = update;
  32499. lodash.updateWith = updateWith;
  32500. lodash.values = values;
  32501. lodash.valuesIn = valuesIn;
  32502. lodash.without = without;
  32503. lodash.words = words;
  32504. lodash.wrap = wrap;
  32505. lodash.xor = xor;
  32506. lodash.xorBy = xorBy;
  32507. lodash.xorWith = xorWith;
  32508. lodash.zip = zip;
  32509. lodash.zipObject = zipObject;
  32510. lodash.zipObjectDeep = zipObjectDeep;
  32511. lodash.zipWith = zipWith;
  32512. // Add aliases.
  32513. lodash.entries = toPairs;
  32514. lodash.entriesIn = toPairsIn;
  32515. lodash.extend = assignIn;
  32516. lodash.extendWith = assignInWith;
  32517. // Add methods to `lodash.prototype`.
  32518. mixin(lodash, lodash);
  32519. /*------------------------------------------------------------------------*/
  32520. // Add methods that return unwrapped values in chain sequences.
  32521. lodash.add = add;
  32522. lodash.attempt = attempt;
  32523. lodash.camelCase = camelCase;
  32524. lodash.capitalize = capitalize;
  32525. lodash.ceil = ceil;
  32526. lodash.clamp = clamp;
  32527. lodash.clone = clone;
  32528. lodash.cloneDeep = cloneDeep;
  32529. lodash.cloneDeepWith = cloneDeepWith;
  32530. lodash.cloneWith = cloneWith;
  32531. lodash.conformsTo = conformsTo;
  32532. lodash.deburr = deburr;
  32533. lodash.defaultTo = defaultTo;
  32534. lodash.divide = divide;
  32535. lodash.endsWith = endsWith;
  32536. lodash.eq = eq;
  32537. lodash.escape = escape;
  32538. lodash.escapeRegExp = escapeRegExp;
  32539. lodash.every = every;
  32540. lodash.find = find;
  32541. lodash.findIndex = findIndex;
  32542. lodash.findKey = findKey;
  32543. lodash.findLast = findLast;
  32544. lodash.findLastIndex = findLastIndex;
  32545. lodash.findLastKey = findLastKey;
  32546. lodash.floor = floor;
  32547. lodash.forEach = forEach;
  32548. lodash.forEachRight = forEachRight;
  32549. lodash.forIn = forIn;
  32550. lodash.forInRight = forInRight;
  32551. lodash.forOwn = forOwn;
  32552. lodash.forOwnRight = forOwnRight;
  32553. lodash.get = get;
  32554. lodash.gt = gt;
  32555. lodash.gte = gte;
  32556. lodash.has = has;
  32557. lodash.hasIn = hasIn;
  32558. lodash.head = head;
  32559. lodash.identity = identity;
  32560. lodash.includes = includes;
  32561. lodash.indexOf = indexOf;
  32562. lodash.inRange = inRange;
  32563. lodash.invoke = invoke;
  32564. lodash.isArguments = isArguments;
  32565. lodash.isArray = isArray;
  32566. lodash.isArrayBuffer = isArrayBuffer;
  32567. lodash.isArrayLike = isArrayLike;
  32568. lodash.isArrayLikeObject = isArrayLikeObject;
  32569. lodash.isBoolean = isBoolean;
  32570. lodash.isBuffer = isBuffer;
  32571. lodash.isDate = isDate;
  32572. lodash.isElement = isElement;
  32573. lodash.isEmpty = isEmpty;
  32574. lodash.isEqual = isEqual;
  32575. lodash.isEqualWith = isEqualWith;
  32576. lodash.isError = isError;
  32577. lodash.isFinite = isFinite;
  32578. lodash.isFunction = isFunction;
  32579. lodash.isInteger = isInteger;
  32580. lodash.isLength = isLength;
  32581. lodash.isMap = isMap;
  32582. lodash.isMatch = isMatch;
  32583. lodash.isMatchWith = isMatchWith;
  32584. lodash.isNaN = isNaN;
  32585. lodash.isNative = isNative;
  32586. lodash.isNil = isNil;
  32587. lodash.isNull = isNull;
  32588. lodash.isNumber = isNumber;
  32589. lodash.isObject = isObject;
  32590. lodash.isObjectLike = isObjectLike;
  32591. lodash.isPlainObject = isPlainObject;
  32592. lodash.isRegExp = isRegExp;
  32593. lodash.isSafeInteger = isSafeInteger;
  32594. lodash.isSet = isSet;
  32595. lodash.isString = isString;
  32596. lodash.isSymbol = isSymbol;
  32597. lodash.isTypedArray = isTypedArray;
  32598. lodash.isUndefined = isUndefined;
  32599. lodash.isWeakMap = isWeakMap;
  32600. lodash.isWeakSet = isWeakSet;
  32601. lodash.join = join;
  32602. lodash.kebabCase = kebabCase;
  32603. lodash.last = last;
  32604. lodash.lastIndexOf = lastIndexOf;
  32605. lodash.lowerCase = lowerCase;
  32606. lodash.lowerFirst = lowerFirst;
  32607. lodash.lt = lt;
  32608. lodash.lte = lte;
  32609. lodash.max = max;
  32610. lodash.maxBy = maxBy;
  32611. lodash.mean = mean;
  32612. lodash.meanBy = meanBy;
  32613. lodash.min = min;
  32614. lodash.minBy = minBy;
  32615. lodash.stubArray = stubArray;
  32616. lodash.stubFalse = stubFalse;
  32617. lodash.stubObject = stubObject;
  32618. lodash.stubString = stubString;
  32619. lodash.stubTrue = stubTrue;
  32620. lodash.multiply = multiply;
  32621. lodash.nth = nth;
  32622. lodash.noConflict = noConflict;
  32623. lodash.noop = noop;
  32624. lodash.now = now;
  32625. lodash.pad = pad;
  32626. lodash.padEnd = padEnd;
  32627. lodash.padStart = padStart;
  32628. lodash.parseInt = parseInt;
  32629. lodash.random = random;
  32630. lodash.reduce = reduce;
  32631. lodash.reduceRight = reduceRight;
  32632. lodash.repeat = repeat;
  32633. lodash.replace = replace;
  32634. lodash.result = result;
  32635. lodash.round = round;
  32636. lodash.runInContext = runInContext;
  32637. lodash.sample = sample;
  32638. lodash.size = size;
  32639. lodash.snakeCase = snakeCase;
  32640. lodash.some = some;
  32641. lodash.sortedIndex = sortedIndex;
  32642. lodash.sortedIndexBy = sortedIndexBy;
  32643. lodash.sortedIndexOf = sortedIndexOf;
  32644. lodash.sortedLastIndex = sortedLastIndex;
  32645. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32646. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32647. lodash.startCase = startCase;
  32648. lodash.startsWith = startsWith;
  32649. lodash.subtract = subtract;
  32650. lodash.sum = sum;
  32651. lodash.sumBy = sumBy;
  32652. lodash.template = template;
  32653. lodash.times = times;
  32654. lodash.toFinite = toFinite;
  32655. lodash.toInteger = toInteger;
  32656. lodash.toLength = toLength;
  32657. lodash.toLower = toLower;
  32658. lodash.toNumber = toNumber;
  32659. lodash.toSafeInteger = toSafeInteger;
  32660. lodash.toString = toString;
  32661. lodash.toUpper = toUpper;
  32662. lodash.trim = trim;
  32663. lodash.trimEnd = trimEnd;
  32664. lodash.trimStart = trimStart;
  32665. lodash.truncate = truncate;
  32666. lodash.unescape = unescape;
  32667. lodash.uniqueId = uniqueId;
  32668. lodash.upperCase = upperCase;
  32669. lodash.upperFirst = upperFirst;
  32670. // Add aliases.
  32671. lodash.each = forEach;
  32672. lodash.eachRight = forEachRight;
  32673. lodash.first = head;
  32674. mixin(lodash, (function() {
  32675. var source = {};
  32676. baseForOwn(lodash, function(func, methodName) {
  32677. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32678. source[methodName] = func;
  32679. }
  32680. });
  32681. return source;
  32682. }()), { 'chain': false });
  32683. /*------------------------------------------------------------------------*/
  32684. /**
  32685. * The semantic version number.
  32686. *
  32687. * @static
  32688. * @memberOf _
  32689. * @type {string}
  32690. */
  32691. lodash.VERSION = VERSION;
  32692. // Assign default placeholders.
  32693. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32694. lodash[methodName].placeholder = lodash;
  32695. });
  32696. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32697. arrayEach(['drop', 'take'], function(methodName, index) {
  32698. LazyWrapper.prototype[methodName] = function(n) {
  32699. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32700. var result = (this.__filtered__ && !index)
  32701. ? new LazyWrapper(this)
  32702. : this.clone();
  32703. if (result.__filtered__) {
  32704. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32705. } else {
  32706. result.__views__.push({
  32707. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32708. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32709. });
  32710. }
  32711. return result;
  32712. };
  32713. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32714. return this.reverse()[methodName](n).reverse();
  32715. };
  32716. });
  32717. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32718. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32719. var type = index + 1,
  32720. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32721. LazyWrapper.prototype[methodName] = function(iteratee) {
  32722. var result = this.clone();
  32723. result.__iteratees__.push({
  32724. 'iteratee': getIteratee(iteratee, 3),
  32725. 'type': type
  32726. });
  32727. result.__filtered__ = result.__filtered__ || isFilter;
  32728. return result;
  32729. };
  32730. });
  32731. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32732. arrayEach(['head', 'last'], function(methodName, index) {
  32733. var takeName = 'take' + (index ? 'Right' : '');
  32734. LazyWrapper.prototype[methodName] = function() {
  32735. return this[takeName](1).value()[0];
  32736. };
  32737. });
  32738. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32739. arrayEach(['initial', 'tail'], function(methodName, index) {
  32740. var dropName = 'drop' + (index ? '' : 'Right');
  32741. LazyWrapper.prototype[methodName] = function() {
  32742. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32743. };
  32744. });
  32745. LazyWrapper.prototype.compact = function() {
  32746. return this.filter(identity);
  32747. };
  32748. LazyWrapper.prototype.find = function(predicate) {
  32749. return this.filter(predicate).head();
  32750. };
  32751. LazyWrapper.prototype.findLast = function(predicate) {
  32752. return this.reverse().find(predicate);
  32753. };
  32754. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32755. if (typeof path == 'function') {
  32756. return new LazyWrapper(this);
  32757. }
  32758. return this.map(function(value) {
  32759. return baseInvoke(value, path, args);
  32760. });
  32761. });
  32762. LazyWrapper.prototype.reject = function(predicate) {
  32763. return this.filter(negate(getIteratee(predicate)));
  32764. };
  32765. LazyWrapper.prototype.slice = function(start, end) {
  32766. start = toInteger(start);
  32767. var result = this;
  32768. if (result.__filtered__ && (start > 0 || end < 0)) {
  32769. return new LazyWrapper(result);
  32770. }
  32771. if (start < 0) {
  32772. result = result.takeRight(-start);
  32773. } else if (start) {
  32774. result = result.drop(start);
  32775. }
  32776. if (end !== undefined) {
  32777. end = toInteger(end);
  32778. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32779. }
  32780. return result;
  32781. };
  32782. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32783. return this.reverse().takeWhile(predicate).reverse();
  32784. };
  32785. LazyWrapper.prototype.toArray = function() {
  32786. return this.take(MAX_ARRAY_LENGTH);
  32787. };
  32788. // Add `LazyWrapper` methods to `lodash.prototype`.
  32789. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32790. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32791. isTaker = /^(?:head|last)$/.test(methodName),
  32792. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32793. retUnwrapped = isTaker || /^find/.test(methodName);
  32794. if (!lodashFunc) {
  32795. return;
  32796. }
  32797. lodash.prototype[methodName] = function() {
  32798. var value = this.__wrapped__,
  32799. args = isTaker ? [1] : arguments,
  32800. isLazy = value instanceof LazyWrapper,
  32801. iteratee = args[0],
  32802. useLazy = isLazy || isArray(value);
  32803. var interceptor = function(value) {
  32804. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32805. return (isTaker && chainAll) ? result[0] : result;
  32806. };
  32807. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32808. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32809. isLazy = useLazy = false;
  32810. }
  32811. var chainAll = this.__chain__,
  32812. isHybrid = !!this.__actions__.length,
  32813. isUnwrapped = retUnwrapped && !chainAll,
  32814. onlyLazy = isLazy && !isHybrid;
  32815. if (!retUnwrapped && useLazy) {
  32816. value = onlyLazy ? value : new LazyWrapper(this);
  32817. var result = func.apply(value, args);
  32818. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32819. return new LodashWrapper(result, chainAll);
  32820. }
  32821. if (isUnwrapped && onlyLazy) {
  32822. return func.apply(this, args);
  32823. }
  32824. result = this.thru(interceptor);
  32825. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32826. };
  32827. });
  32828. // Add `Array` methods to `lodash.prototype`.
  32829. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32830. var func = arrayProto[methodName],
  32831. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32832. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32833. lodash.prototype[methodName] = function() {
  32834. var args = arguments;
  32835. if (retUnwrapped && !this.__chain__) {
  32836. var value = this.value();
  32837. return func.apply(isArray(value) ? value : [], args);
  32838. }
  32839. return this[chainName](function(value) {
  32840. return func.apply(isArray(value) ? value : [], args);
  32841. });
  32842. };
  32843. });
  32844. // Map minified method names to their real names.
  32845. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32846. var lodashFunc = lodash[methodName];
  32847. if (lodashFunc) {
  32848. var key = lodashFunc.name + '';
  32849. if (!hasOwnProperty.call(realNames, key)) {
  32850. realNames[key] = [];
  32851. }
  32852. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32853. }
  32854. });
  32855. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32856. 'name': 'wrapper',
  32857. 'func': undefined
  32858. }];
  32859. // Add methods to `LazyWrapper`.
  32860. LazyWrapper.prototype.clone = lazyClone;
  32861. LazyWrapper.prototype.reverse = lazyReverse;
  32862. LazyWrapper.prototype.value = lazyValue;
  32863. // Add chain sequence methods to the `lodash` wrapper.
  32864. lodash.prototype.at = wrapperAt;
  32865. lodash.prototype.chain = wrapperChain;
  32866. lodash.prototype.commit = wrapperCommit;
  32867. lodash.prototype.next = wrapperNext;
  32868. lodash.prototype.plant = wrapperPlant;
  32869. lodash.prototype.reverse = wrapperReverse;
  32870. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32871. // Add lazy aliases.
  32872. lodash.prototype.first = lodash.prototype.head;
  32873. if (symIterator) {
  32874. lodash.prototype[symIterator] = wrapperToIterator;
  32875. }
  32876. return lodash;
  32877. });
  32878. /*--------------------------------------------------------------------------*/
  32879. // Export lodash.
  32880. var _ = runInContext();
  32881. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32882. if (true) {
  32883. // Expose Lodash on the global object to prevent errors when Lodash is
  32884. // loaded by a script tag in the presence of an AMD loader.
  32885. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32886. // Use `_.noConflict` to remove Lodash from the global object.
  32887. root._ = _;
  32888. // Define as an anonymous module so, through path mapping, it can be
  32889. // referenced as the "underscore" module.
  32890. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32891. return _;
  32892. }).call(exports, __webpack_require__, exports, module),
  32893. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32894. }
  32895. // Check for `exports` after `define` in case a build optimizer adds it.
  32896. else {}
  32897. }.call(this));
  32898. /* 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)))
  32899. /***/ }),
  32900. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32901. /*!***************************************************!*\
  32902. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32903. \***************************************************/
  32904. /*! exports provided: default */
  32905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32906. "use strict";
  32907. __webpack_require__.r(__webpack_exports__);
  32908. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32909. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32910. * @version 1.16.1
  32911. * @license
  32912. * Copyright (c) 2016 Federico Zivolo and contributors
  32913. *
  32914. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32915. * of this software and associated documentation files (the "Software"), to deal
  32916. * in the Software without restriction, including without limitation the rights
  32917. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32918. * copies of the Software, and to permit persons to whom the Software is
  32919. * furnished to do so, subject to the following conditions:
  32920. *
  32921. * The above copyright notice and this permission notice shall be included in all
  32922. * copies or substantial portions of the Software.
  32923. *
  32924. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32925. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32926. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32927. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32928. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32929. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32930. * SOFTWARE.
  32931. */
  32932. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32933. var timeoutDuration = function () {
  32934. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32935. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32936. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32937. return 1;
  32938. }
  32939. }
  32940. return 0;
  32941. }();
  32942. function microtaskDebounce(fn) {
  32943. var called = false;
  32944. return function () {
  32945. if (called) {
  32946. return;
  32947. }
  32948. called = true;
  32949. window.Promise.resolve().then(function () {
  32950. called = false;
  32951. fn();
  32952. });
  32953. };
  32954. }
  32955. function taskDebounce(fn) {
  32956. var scheduled = false;
  32957. return function () {
  32958. if (!scheduled) {
  32959. scheduled = true;
  32960. setTimeout(function () {
  32961. scheduled = false;
  32962. fn();
  32963. }, timeoutDuration);
  32964. }
  32965. };
  32966. }
  32967. var supportsMicroTasks = isBrowser && window.Promise;
  32968. /**
  32969. * Create a debounced version of a method, that's asynchronously deferred
  32970. * but called in the minimum time possible.
  32971. *
  32972. * @method
  32973. * @memberof Popper.Utils
  32974. * @argument {Function} fn
  32975. * @returns {Function}
  32976. */
  32977. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  32978. /**
  32979. * Check if the given variable is a function
  32980. * @method
  32981. * @memberof Popper.Utils
  32982. * @argument {Any} functionToCheck - variable to check
  32983. * @returns {Boolean} answer to: is a function?
  32984. */
  32985. function isFunction(functionToCheck) {
  32986. var getType = {};
  32987. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  32988. }
  32989. /**
  32990. * Get CSS computed property of the given element
  32991. * @method
  32992. * @memberof Popper.Utils
  32993. * @argument {Eement} element
  32994. * @argument {String} property
  32995. */
  32996. function getStyleComputedProperty(element, property) {
  32997. if (element.nodeType !== 1) {
  32998. return [];
  32999. }
  33000. // NOTE: 1 DOM access here
  33001. var window = element.ownerDocument.defaultView;
  33002. var css = window.getComputedStyle(element, null);
  33003. return property ? css[property] : css;
  33004. }
  33005. /**
  33006. * Returns the parentNode or the host of the element
  33007. * @method
  33008. * @memberof Popper.Utils
  33009. * @argument {Element} element
  33010. * @returns {Element} parent
  33011. */
  33012. function getParentNode(element) {
  33013. if (element.nodeName === 'HTML') {
  33014. return element;
  33015. }
  33016. return element.parentNode || element.host;
  33017. }
  33018. /**
  33019. * Returns the scrolling parent of the given element
  33020. * @method
  33021. * @memberof Popper.Utils
  33022. * @argument {Element} element
  33023. * @returns {Element} scroll parent
  33024. */
  33025. function getScrollParent(element) {
  33026. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33027. if (!element) {
  33028. return document.body;
  33029. }
  33030. switch (element.nodeName) {
  33031. case 'HTML':
  33032. case 'BODY':
  33033. return element.ownerDocument.body;
  33034. case '#document':
  33035. return element.body;
  33036. }
  33037. // Firefox want us to check `-x` and `-y` variations as well
  33038. var _getStyleComputedProp = getStyleComputedProperty(element),
  33039. overflow = _getStyleComputedProp.overflow,
  33040. overflowX = _getStyleComputedProp.overflowX,
  33041. overflowY = _getStyleComputedProp.overflowY;
  33042. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33043. return element;
  33044. }
  33045. return getScrollParent(getParentNode(element));
  33046. }
  33047. /**
  33048. * Returns the reference node of the reference object, or the reference object itself.
  33049. * @method
  33050. * @memberof Popper.Utils
  33051. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33052. * @returns {Element} parent
  33053. */
  33054. function getReferenceNode(reference) {
  33055. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33056. }
  33057. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33058. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33059. /**
  33060. * Determines if the browser is Internet Explorer
  33061. * @method
  33062. * @memberof Popper.Utils
  33063. * @param {Number} version to check
  33064. * @returns {Boolean} isIE
  33065. */
  33066. function isIE(version) {
  33067. if (version === 11) {
  33068. return isIE11;
  33069. }
  33070. if (version === 10) {
  33071. return isIE10;
  33072. }
  33073. return isIE11 || isIE10;
  33074. }
  33075. /**
  33076. * Returns the offset parent of the given element
  33077. * @method
  33078. * @memberof Popper.Utils
  33079. * @argument {Element} element
  33080. * @returns {Element} offset parent
  33081. */
  33082. function getOffsetParent(element) {
  33083. if (!element) {
  33084. return document.documentElement;
  33085. }
  33086. var noOffsetParent = isIE(10) ? document.body : null;
  33087. // NOTE: 1 DOM access here
  33088. var offsetParent = element.offsetParent || null;
  33089. // Skip hidden elements which don't have an offsetParent
  33090. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33091. offsetParent = (element = element.nextElementSibling).offsetParent;
  33092. }
  33093. var nodeName = offsetParent && offsetParent.nodeName;
  33094. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33095. return element ? element.ownerDocument.documentElement : document.documentElement;
  33096. }
  33097. // .offsetParent will return the closest TH, TD or TABLE in case
  33098. // no offsetParent is present, I hate this job...
  33099. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33100. return getOffsetParent(offsetParent);
  33101. }
  33102. return offsetParent;
  33103. }
  33104. function isOffsetContainer(element) {
  33105. var nodeName = element.nodeName;
  33106. if (nodeName === 'BODY') {
  33107. return false;
  33108. }
  33109. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33110. }
  33111. /**
  33112. * Finds the root node (document, shadowDOM root) of the given element
  33113. * @method
  33114. * @memberof Popper.Utils
  33115. * @argument {Element} node
  33116. * @returns {Element} root node
  33117. */
  33118. function getRoot(node) {
  33119. if (node.parentNode !== null) {
  33120. return getRoot(node.parentNode);
  33121. }
  33122. return node;
  33123. }
  33124. /**
  33125. * Finds the offset parent common to the two provided nodes
  33126. * @method
  33127. * @memberof Popper.Utils
  33128. * @argument {Element} element1
  33129. * @argument {Element} element2
  33130. * @returns {Element} common offset parent
  33131. */
  33132. function findCommonOffsetParent(element1, element2) {
  33133. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33134. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33135. return document.documentElement;
  33136. }
  33137. // Here we make sure to give as "start" the element that comes first in the DOM
  33138. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33139. var start = order ? element1 : element2;
  33140. var end = order ? element2 : element1;
  33141. // Get common ancestor container
  33142. var range = document.createRange();
  33143. range.setStart(start, 0);
  33144. range.setEnd(end, 0);
  33145. var commonAncestorContainer = range.commonAncestorContainer;
  33146. // Both nodes are inside #document
  33147. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33148. if (isOffsetContainer(commonAncestorContainer)) {
  33149. return commonAncestorContainer;
  33150. }
  33151. return getOffsetParent(commonAncestorContainer);
  33152. }
  33153. // one of the nodes is inside shadowDOM, find which one
  33154. var element1root = getRoot(element1);
  33155. if (element1root.host) {
  33156. return findCommonOffsetParent(element1root.host, element2);
  33157. } else {
  33158. return findCommonOffsetParent(element1, getRoot(element2).host);
  33159. }
  33160. }
  33161. /**
  33162. * Gets the scroll value of the given element in the given side (top and left)
  33163. * @method
  33164. * @memberof Popper.Utils
  33165. * @argument {Element} element
  33166. * @argument {String} side `top` or `left`
  33167. * @returns {number} amount of scrolled pixels
  33168. */
  33169. function getScroll(element) {
  33170. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33171. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33172. var nodeName = element.nodeName;
  33173. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33174. var html = element.ownerDocument.documentElement;
  33175. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33176. return scrollingElement[upperSide];
  33177. }
  33178. return element[upperSide];
  33179. }
  33180. /*
  33181. * Sum or subtract the element scroll values (left and top) from a given rect object
  33182. * @method
  33183. * @memberof Popper.Utils
  33184. * @param {Object} rect - Rect object you want to change
  33185. * @param {HTMLElement} element - The element from the function reads the scroll values
  33186. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33187. * @return {Object} rect - The modifier rect object
  33188. */
  33189. function includeScroll(rect, element) {
  33190. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33191. var scrollTop = getScroll(element, 'top');
  33192. var scrollLeft = getScroll(element, 'left');
  33193. var modifier = subtract ? -1 : 1;
  33194. rect.top += scrollTop * modifier;
  33195. rect.bottom += scrollTop * modifier;
  33196. rect.left += scrollLeft * modifier;
  33197. rect.right += scrollLeft * modifier;
  33198. return rect;
  33199. }
  33200. /*
  33201. * Helper to detect borders of a given element
  33202. * @method
  33203. * @memberof Popper.Utils
  33204. * @param {CSSStyleDeclaration} styles
  33205. * Result of `getStyleComputedProperty` on the given element
  33206. * @param {String} axis - `x` or `y`
  33207. * @return {number} borders - The borders size of the given axis
  33208. */
  33209. function getBordersSize(styles, axis) {
  33210. var sideA = axis === 'x' ? 'Left' : 'Top';
  33211. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33212. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33213. }
  33214. function getSize(axis, body, html, computedStyle) {
  33215. 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);
  33216. }
  33217. function getWindowSizes(document) {
  33218. var body = document.body;
  33219. var html = document.documentElement;
  33220. var computedStyle = isIE(10) && getComputedStyle(html);
  33221. return {
  33222. height: getSize('Height', body, html, computedStyle),
  33223. width: getSize('Width', body, html, computedStyle)
  33224. };
  33225. }
  33226. var classCallCheck = function (instance, Constructor) {
  33227. if (!(instance instanceof Constructor)) {
  33228. throw new TypeError("Cannot call a class as a function");
  33229. }
  33230. };
  33231. var createClass = function () {
  33232. function defineProperties(target, props) {
  33233. for (var i = 0; i < props.length; i++) {
  33234. var descriptor = props[i];
  33235. descriptor.enumerable = descriptor.enumerable || false;
  33236. descriptor.configurable = true;
  33237. if ("value" in descriptor) descriptor.writable = true;
  33238. Object.defineProperty(target, descriptor.key, descriptor);
  33239. }
  33240. }
  33241. return function (Constructor, protoProps, staticProps) {
  33242. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33243. if (staticProps) defineProperties(Constructor, staticProps);
  33244. return Constructor;
  33245. };
  33246. }();
  33247. var defineProperty = function (obj, key, value) {
  33248. if (key in obj) {
  33249. Object.defineProperty(obj, key, {
  33250. value: value,
  33251. enumerable: true,
  33252. configurable: true,
  33253. writable: true
  33254. });
  33255. } else {
  33256. obj[key] = value;
  33257. }
  33258. return obj;
  33259. };
  33260. var _extends = Object.assign || function (target) {
  33261. for (var i = 1; i < arguments.length; i++) {
  33262. var source = arguments[i];
  33263. for (var key in source) {
  33264. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33265. target[key] = source[key];
  33266. }
  33267. }
  33268. }
  33269. return target;
  33270. };
  33271. /**
  33272. * Given element offsets, generate an output similar to getBoundingClientRect
  33273. * @method
  33274. * @memberof Popper.Utils
  33275. * @argument {Object} offsets
  33276. * @returns {Object} ClientRect like output
  33277. */
  33278. function getClientRect(offsets) {
  33279. return _extends({}, offsets, {
  33280. right: offsets.left + offsets.width,
  33281. bottom: offsets.top + offsets.height
  33282. });
  33283. }
  33284. /**
  33285. * Get bounding client rect of given element
  33286. * @method
  33287. * @memberof Popper.Utils
  33288. * @param {HTMLElement} element
  33289. * @return {Object} client rect
  33290. */
  33291. function getBoundingClientRect(element) {
  33292. var rect = {};
  33293. // IE10 10 FIX: Please, don't ask, the element isn't
  33294. // considered in DOM in some circumstances...
  33295. // This isn't reproducible in IE10 compatibility mode of IE11
  33296. try {
  33297. if (isIE(10)) {
  33298. rect = element.getBoundingClientRect();
  33299. var scrollTop = getScroll(element, 'top');
  33300. var scrollLeft = getScroll(element, 'left');
  33301. rect.top += scrollTop;
  33302. rect.left += scrollLeft;
  33303. rect.bottom += scrollTop;
  33304. rect.right += scrollLeft;
  33305. } else {
  33306. rect = element.getBoundingClientRect();
  33307. }
  33308. } catch (e) {}
  33309. var result = {
  33310. left: rect.left,
  33311. top: rect.top,
  33312. width: rect.right - rect.left,
  33313. height: rect.bottom - rect.top
  33314. };
  33315. // subtract scrollbar size from sizes
  33316. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33317. var width = sizes.width || element.clientWidth || result.width;
  33318. var height = sizes.height || element.clientHeight || result.height;
  33319. var horizScrollbar = element.offsetWidth - width;
  33320. var vertScrollbar = element.offsetHeight - height;
  33321. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33322. // we make this check conditional for performance reasons
  33323. if (horizScrollbar || vertScrollbar) {
  33324. var styles = getStyleComputedProperty(element);
  33325. horizScrollbar -= getBordersSize(styles, 'x');
  33326. vertScrollbar -= getBordersSize(styles, 'y');
  33327. result.width -= horizScrollbar;
  33328. result.height -= vertScrollbar;
  33329. }
  33330. return getClientRect(result);
  33331. }
  33332. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33333. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33334. var isIE10 = isIE(10);
  33335. var isHTML = parent.nodeName === 'HTML';
  33336. var childrenRect = getBoundingClientRect(children);
  33337. var parentRect = getBoundingClientRect(parent);
  33338. var scrollParent = getScrollParent(children);
  33339. var styles = getStyleComputedProperty(parent);
  33340. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33341. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33342. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33343. if (fixedPosition && isHTML) {
  33344. parentRect.top = Math.max(parentRect.top, 0);
  33345. parentRect.left = Math.max(parentRect.left, 0);
  33346. }
  33347. var offsets = getClientRect({
  33348. top: childrenRect.top - parentRect.top - borderTopWidth,
  33349. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33350. width: childrenRect.width,
  33351. height: childrenRect.height
  33352. });
  33353. offsets.marginTop = 0;
  33354. offsets.marginLeft = 0;
  33355. // Subtract margins of documentElement in case it's being used as parent
  33356. // we do this only on HTML because it's the only element that behaves
  33357. // differently when margins are applied to it. The margins are included in
  33358. // the box of the documentElement, in the other cases not.
  33359. if (!isIE10 && isHTML) {
  33360. var marginTop = parseFloat(styles.marginTop);
  33361. var marginLeft = parseFloat(styles.marginLeft);
  33362. offsets.top -= borderTopWidth - marginTop;
  33363. offsets.bottom -= borderTopWidth - marginTop;
  33364. offsets.left -= borderLeftWidth - marginLeft;
  33365. offsets.right -= borderLeftWidth - marginLeft;
  33366. // Attach marginTop and marginLeft because in some circumstances we may need them
  33367. offsets.marginTop = marginTop;
  33368. offsets.marginLeft = marginLeft;
  33369. }
  33370. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33371. offsets = includeScroll(offsets, parent);
  33372. }
  33373. return offsets;
  33374. }
  33375. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33376. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33377. var html = element.ownerDocument.documentElement;
  33378. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33379. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33380. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33381. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33382. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33383. var offset = {
  33384. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33385. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33386. width: width,
  33387. height: height
  33388. };
  33389. return getClientRect(offset);
  33390. }
  33391. /**
  33392. * Check if the given element is fixed or is inside a fixed parent
  33393. * @method
  33394. * @memberof Popper.Utils
  33395. * @argument {Element} element
  33396. * @argument {Element} customContainer
  33397. * @returns {Boolean} answer to "isFixed?"
  33398. */
  33399. function isFixed(element) {
  33400. var nodeName = element.nodeName;
  33401. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33402. return false;
  33403. }
  33404. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33405. return true;
  33406. }
  33407. var parentNode = getParentNode(element);
  33408. if (!parentNode) {
  33409. return false;
  33410. }
  33411. return isFixed(parentNode);
  33412. }
  33413. /**
  33414. * Finds the first parent of an element that has a transformed property defined
  33415. * @method
  33416. * @memberof Popper.Utils
  33417. * @argument {Element} element
  33418. * @returns {Element} first transformed parent or documentElement
  33419. */
  33420. function getFixedPositionOffsetParent(element) {
  33421. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33422. if (!element || !element.parentElement || isIE()) {
  33423. return document.documentElement;
  33424. }
  33425. var el = element.parentElement;
  33426. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33427. el = el.parentElement;
  33428. }
  33429. return el || document.documentElement;
  33430. }
  33431. /**
  33432. * Computed the boundaries limits and return them
  33433. * @method
  33434. * @memberof Popper.Utils
  33435. * @param {HTMLElement} popper
  33436. * @param {HTMLElement} reference
  33437. * @param {number} padding
  33438. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33439. * @param {Boolean} fixedPosition - Is in fixed position mode
  33440. * @returns {Object} Coordinates of the boundaries
  33441. */
  33442. function getBoundaries(popper, reference, padding, boundariesElement) {
  33443. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33444. // NOTE: 1 DOM access here
  33445. var boundaries = { top: 0, left: 0 };
  33446. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33447. // Handle viewport case
  33448. if (boundariesElement === 'viewport') {
  33449. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33450. } else {
  33451. // Handle other cases based on DOM element used as boundaries
  33452. var boundariesNode = void 0;
  33453. if (boundariesElement === 'scrollParent') {
  33454. boundariesNode = getScrollParent(getParentNode(reference));
  33455. if (boundariesNode.nodeName === 'BODY') {
  33456. boundariesNode = popper.ownerDocument.documentElement;
  33457. }
  33458. } else if (boundariesElement === 'window') {
  33459. boundariesNode = popper.ownerDocument.documentElement;
  33460. } else {
  33461. boundariesNode = boundariesElement;
  33462. }
  33463. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33464. // In case of HTML, we need a different computation
  33465. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33466. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33467. height = _getWindowSizes.height,
  33468. width = _getWindowSizes.width;
  33469. boundaries.top += offsets.top - offsets.marginTop;
  33470. boundaries.bottom = height + offsets.top;
  33471. boundaries.left += offsets.left - offsets.marginLeft;
  33472. boundaries.right = width + offsets.left;
  33473. } else {
  33474. // for all the other DOM elements, this one is good
  33475. boundaries = offsets;
  33476. }
  33477. }
  33478. // Add paddings
  33479. padding = padding || 0;
  33480. var isPaddingNumber = typeof padding === 'number';
  33481. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33482. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33483. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33484. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33485. return boundaries;
  33486. }
  33487. function getArea(_ref) {
  33488. var width = _ref.width,
  33489. height = _ref.height;
  33490. return width * height;
  33491. }
  33492. /**
  33493. * Utility used to transform the `auto` placement to the placement with more
  33494. * available space.
  33495. * @method
  33496. * @memberof Popper.Utils
  33497. * @argument {Object} data - The data object generated by update method
  33498. * @argument {Object} options - Modifiers configuration and options
  33499. * @returns {Object} The data object, properly modified
  33500. */
  33501. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33502. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33503. if (placement.indexOf('auto') === -1) {
  33504. return placement;
  33505. }
  33506. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33507. var rects = {
  33508. top: {
  33509. width: boundaries.width,
  33510. height: refRect.top - boundaries.top
  33511. },
  33512. right: {
  33513. width: boundaries.right - refRect.right,
  33514. height: boundaries.height
  33515. },
  33516. bottom: {
  33517. width: boundaries.width,
  33518. height: boundaries.bottom - refRect.bottom
  33519. },
  33520. left: {
  33521. width: refRect.left - boundaries.left,
  33522. height: boundaries.height
  33523. }
  33524. };
  33525. var sortedAreas = Object.keys(rects).map(function (key) {
  33526. return _extends({
  33527. key: key
  33528. }, rects[key], {
  33529. area: getArea(rects[key])
  33530. });
  33531. }).sort(function (a, b) {
  33532. return b.area - a.area;
  33533. });
  33534. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33535. var width = _ref2.width,
  33536. height = _ref2.height;
  33537. return width >= popper.clientWidth && height >= popper.clientHeight;
  33538. });
  33539. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33540. var variation = placement.split('-')[1];
  33541. return computedPlacement + (variation ? '-' + variation : '');
  33542. }
  33543. /**
  33544. * Get offsets to the reference element
  33545. * @method
  33546. * @memberof Popper.Utils
  33547. * @param {Object} state
  33548. * @param {Element} popper - the popper element
  33549. * @param {Element} reference - the reference element (the popper will be relative to this)
  33550. * @param {Element} fixedPosition - is in fixed position mode
  33551. * @returns {Object} An object containing the offsets which will be applied to the popper
  33552. */
  33553. function getReferenceOffsets(state, popper, reference) {
  33554. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33555. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33556. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33557. }
  33558. /**
  33559. * Get the outer sizes of the given element (offset size + margins)
  33560. * @method
  33561. * @memberof Popper.Utils
  33562. * @argument {Element} element
  33563. * @returns {Object} object containing width and height properties
  33564. */
  33565. function getOuterSizes(element) {
  33566. var window = element.ownerDocument.defaultView;
  33567. var styles = window.getComputedStyle(element);
  33568. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33569. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33570. var result = {
  33571. width: element.offsetWidth + y,
  33572. height: element.offsetHeight + x
  33573. };
  33574. return result;
  33575. }
  33576. /**
  33577. * Get the opposite placement of the given one
  33578. * @method
  33579. * @memberof Popper.Utils
  33580. * @argument {String} placement
  33581. * @returns {String} flipped placement
  33582. */
  33583. function getOppositePlacement(placement) {
  33584. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33585. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33586. return hash[matched];
  33587. });
  33588. }
  33589. /**
  33590. * Get offsets to the popper
  33591. * @method
  33592. * @memberof Popper.Utils
  33593. * @param {Object} position - CSS position the Popper will get applied
  33594. * @param {HTMLElement} popper - the popper element
  33595. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33596. * @param {String} placement - one of the valid placement options
  33597. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33598. */
  33599. function getPopperOffsets(popper, referenceOffsets, placement) {
  33600. placement = placement.split('-')[0];
  33601. // Get popper node sizes
  33602. var popperRect = getOuterSizes(popper);
  33603. // Add position, width and height to our offsets object
  33604. var popperOffsets = {
  33605. width: popperRect.width,
  33606. height: popperRect.height
  33607. };
  33608. // depending by the popper placement we have to compute its offsets slightly differently
  33609. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33610. var mainSide = isHoriz ? 'top' : 'left';
  33611. var secondarySide = isHoriz ? 'left' : 'top';
  33612. var measurement = isHoriz ? 'height' : 'width';
  33613. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33614. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33615. if (placement === secondarySide) {
  33616. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33617. } else {
  33618. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33619. }
  33620. return popperOffsets;
  33621. }
  33622. /**
  33623. * Mimics the `find` method of Array
  33624. * @method
  33625. * @memberof Popper.Utils
  33626. * @argument {Array} arr
  33627. * @argument prop
  33628. * @argument value
  33629. * @returns index or -1
  33630. */
  33631. function find(arr, check) {
  33632. // use native find if supported
  33633. if (Array.prototype.find) {
  33634. return arr.find(check);
  33635. }
  33636. // use `filter` to obtain the same behavior of `find`
  33637. return arr.filter(check)[0];
  33638. }
  33639. /**
  33640. * Return the index of the matching object
  33641. * @method
  33642. * @memberof Popper.Utils
  33643. * @argument {Array} arr
  33644. * @argument prop
  33645. * @argument value
  33646. * @returns index or -1
  33647. */
  33648. function findIndex(arr, prop, value) {
  33649. // use native findIndex if supported
  33650. if (Array.prototype.findIndex) {
  33651. return arr.findIndex(function (cur) {
  33652. return cur[prop] === value;
  33653. });
  33654. }
  33655. // use `find` + `indexOf` if `findIndex` isn't supported
  33656. var match = find(arr, function (obj) {
  33657. return obj[prop] === value;
  33658. });
  33659. return arr.indexOf(match);
  33660. }
  33661. /**
  33662. * Loop trough the list of modifiers and run them in order,
  33663. * each of them will then edit the data object.
  33664. * @method
  33665. * @memberof Popper.Utils
  33666. * @param {dataObject} data
  33667. * @param {Array} modifiers
  33668. * @param {String} ends - Optional modifier name used as stopper
  33669. * @returns {dataObject}
  33670. */
  33671. function runModifiers(modifiers, data, ends) {
  33672. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33673. modifiersToRun.forEach(function (modifier) {
  33674. if (modifier['function']) {
  33675. // eslint-disable-line dot-notation
  33676. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33677. }
  33678. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33679. if (modifier.enabled && isFunction(fn)) {
  33680. // Add properties to offsets to make them a complete clientRect object
  33681. // we do this before each modifier to make sure the previous one doesn't
  33682. // mess with these values
  33683. data.offsets.popper = getClientRect(data.offsets.popper);
  33684. data.offsets.reference = getClientRect(data.offsets.reference);
  33685. data = fn(data, modifier);
  33686. }
  33687. });
  33688. return data;
  33689. }
  33690. /**
  33691. * Updates the position of the popper, computing the new offsets and applying
  33692. * the new style.<br />
  33693. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33694. * @method
  33695. * @memberof Popper
  33696. */
  33697. function update() {
  33698. // if popper is destroyed, don't perform any further update
  33699. if (this.state.isDestroyed) {
  33700. return;
  33701. }
  33702. var data = {
  33703. instance: this,
  33704. styles: {},
  33705. arrowStyles: {},
  33706. attributes: {},
  33707. flipped: false,
  33708. offsets: {}
  33709. };
  33710. // compute reference element offsets
  33711. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33712. // compute auto placement, store placement inside the data object,
  33713. // modifiers will be able to edit `placement` if needed
  33714. // and refer to originalPlacement to know the original value
  33715. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33716. // store the computed placement inside `originalPlacement`
  33717. data.originalPlacement = data.placement;
  33718. data.positionFixed = this.options.positionFixed;
  33719. // compute the popper offsets
  33720. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33721. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33722. // run the modifiers
  33723. data = runModifiers(this.modifiers, data);
  33724. // the first `update` will call `onCreate` callback
  33725. // the other ones will call `onUpdate` callback
  33726. if (!this.state.isCreated) {
  33727. this.state.isCreated = true;
  33728. this.options.onCreate(data);
  33729. } else {
  33730. this.options.onUpdate(data);
  33731. }
  33732. }
  33733. /**
  33734. * Helper used to know if the given modifier is enabled.
  33735. * @method
  33736. * @memberof Popper.Utils
  33737. * @returns {Boolean}
  33738. */
  33739. function isModifierEnabled(modifiers, modifierName) {
  33740. return modifiers.some(function (_ref) {
  33741. var name = _ref.name,
  33742. enabled = _ref.enabled;
  33743. return enabled && name === modifierName;
  33744. });
  33745. }
  33746. /**
  33747. * Get the prefixed supported property name
  33748. * @method
  33749. * @memberof Popper.Utils
  33750. * @argument {String} property (camelCase)
  33751. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33752. */
  33753. function getSupportedPropertyName(property) {
  33754. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33755. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33756. for (var i = 0; i < prefixes.length; i++) {
  33757. var prefix = prefixes[i];
  33758. var toCheck = prefix ? '' + prefix + upperProp : property;
  33759. if (typeof document.body.style[toCheck] !== 'undefined') {
  33760. return toCheck;
  33761. }
  33762. }
  33763. return null;
  33764. }
  33765. /**
  33766. * Destroys the popper.
  33767. * @method
  33768. * @memberof Popper
  33769. */
  33770. function destroy() {
  33771. this.state.isDestroyed = true;
  33772. // touch DOM only if `applyStyle` modifier is enabled
  33773. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33774. this.popper.removeAttribute('x-placement');
  33775. this.popper.style.position = '';
  33776. this.popper.style.top = '';
  33777. this.popper.style.left = '';
  33778. this.popper.style.right = '';
  33779. this.popper.style.bottom = '';
  33780. this.popper.style.willChange = '';
  33781. this.popper.style[getSupportedPropertyName('transform')] = '';
  33782. }
  33783. this.disableEventListeners();
  33784. // remove the popper if user explicitly asked for the deletion on destroy
  33785. // do not use `remove` because IE11 doesn't support it
  33786. if (this.options.removeOnDestroy) {
  33787. this.popper.parentNode.removeChild(this.popper);
  33788. }
  33789. return this;
  33790. }
  33791. /**
  33792. * Get the window associated with the element
  33793. * @argument {Element} element
  33794. * @returns {Window}
  33795. */
  33796. function getWindow(element) {
  33797. var ownerDocument = element.ownerDocument;
  33798. return ownerDocument ? ownerDocument.defaultView : window;
  33799. }
  33800. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33801. var isBody = scrollParent.nodeName === 'BODY';
  33802. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33803. target.addEventListener(event, callback, { passive: true });
  33804. if (!isBody) {
  33805. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33806. }
  33807. scrollParents.push(target);
  33808. }
  33809. /**
  33810. * Setup needed event listeners used to update the popper position
  33811. * @method
  33812. * @memberof Popper.Utils
  33813. * @private
  33814. */
  33815. function setupEventListeners(reference, options, state, updateBound) {
  33816. // Resize event listener on window
  33817. state.updateBound = updateBound;
  33818. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33819. // Scroll event listener on scroll parents
  33820. var scrollElement = getScrollParent(reference);
  33821. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33822. state.scrollElement = scrollElement;
  33823. state.eventsEnabled = true;
  33824. return state;
  33825. }
  33826. /**
  33827. * It will add resize/scroll events and start recalculating
  33828. * position of the popper element when they are triggered.
  33829. * @method
  33830. * @memberof Popper
  33831. */
  33832. function enableEventListeners() {
  33833. if (!this.state.eventsEnabled) {
  33834. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33835. }
  33836. }
  33837. /**
  33838. * Remove event listeners used to update the popper position
  33839. * @method
  33840. * @memberof Popper.Utils
  33841. * @private
  33842. */
  33843. function removeEventListeners(reference, state) {
  33844. // Remove resize event listener on window
  33845. getWindow(reference).removeEventListener('resize', state.updateBound);
  33846. // Remove scroll event listener on scroll parents
  33847. state.scrollParents.forEach(function (target) {
  33848. target.removeEventListener('scroll', state.updateBound);
  33849. });
  33850. // Reset state
  33851. state.updateBound = null;
  33852. state.scrollParents = [];
  33853. state.scrollElement = null;
  33854. state.eventsEnabled = false;
  33855. return state;
  33856. }
  33857. /**
  33858. * It will remove resize/scroll events and won't recalculate popper position
  33859. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33860. * unless you call `update` method manually.
  33861. * @method
  33862. * @memberof Popper
  33863. */
  33864. function disableEventListeners() {
  33865. if (this.state.eventsEnabled) {
  33866. cancelAnimationFrame(this.scheduleUpdate);
  33867. this.state = removeEventListeners(this.reference, this.state);
  33868. }
  33869. }
  33870. /**
  33871. * Tells if a given input is a number
  33872. * @method
  33873. * @memberof Popper.Utils
  33874. * @param {*} input to check
  33875. * @return {Boolean}
  33876. */
  33877. function isNumeric(n) {
  33878. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33879. }
  33880. /**
  33881. * Set the style to the given popper
  33882. * @method
  33883. * @memberof Popper.Utils
  33884. * @argument {Element} element - Element to apply the style to
  33885. * @argument {Object} styles
  33886. * Object with a list of properties and values which will be applied to the element
  33887. */
  33888. function setStyles(element, styles) {
  33889. Object.keys(styles).forEach(function (prop) {
  33890. var unit = '';
  33891. // add unit if the value is numeric and is one of the following
  33892. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33893. unit = 'px';
  33894. }
  33895. element.style[prop] = styles[prop] + unit;
  33896. });
  33897. }
  33898. /**
  33899. * Set the attributes to the given popper
  33900. * @method
  33901. * @memberof Popper.Utils
  33902. * @argument {Element} element - Element to apply the attributes to
  33903. * @argument {Object} styles
  33904. * Object with a list of properties and values which will be applied to the element
  33905. */
  33906. function setAttributes(element, attributes) {
  33907. Object.keys(attributes).forEach(function (prop) {
  33908. var value = attributes[prop];
  33909. if (value !== false) {
  33910. element.setAttribute(prop, attributes[prop]);
  33911. } else {
  33912. element.removeAttribute(prop);
  33913. }
  33914. });
  33915. }
  33916. /**
  33917. * @function
  33918. * @memberof Modifiers
  33919. * @argument {Object} data - The data object generated by `update` method
  33920. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33921. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33922. * @argument {Object} options - Modifiers configuration and options
  33923. * @returns {Object} The same data object
  33924. */
  33925. function applyStyle(data) {
  33926. // any property present in `data.styles` will be applied to the popper,
  33927. // in this way we can make the 3rd party modifiers add custom styles to it
  33928. // Be aware, modifiers could override the properties defined in the previous
  33929. // lines of this modifier!
  33930. setStyles(data.instance.popper, data.styles);
  33931. // any property present in `data.attributes` will be applied to the popper,
  33932. // they will be set as HTML attributes of the element
  33933. setAttributes(data.instance.popper, data.attributes);
  33934. // if arrowElement is defined and arrowStyles has some properties
  33935. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33936. setStyles(data.arrowElement, data.arrowStyles);
  33937. }
  33938. return data;
  33939. }
  33940. /**
  33941. * Set the x-placement attribute before everything else because it could be used
  33942. * to add margins to the popper margins needs to be calculated to get the
  33943. * correct popper offsets.
  33944. * @method
  33945. * @memberof Popper.modifiers
  33946. * @param {HTMLElement} reference - The reference element used to position the popper
  33947. * @param {HTMLElement} popper - The HTML element used as popper
  33948. * @param {Object} options - Popper.js options
  33949. */
  33950. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33951. // compute reference element offsets
  33952. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33953. // compute auto placement, store placement inside the data object,
  33954. // modifiers will be able to edit `placement` if needed
  33955. // and refer to originalPlacement to know the original value
  33956. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  33957. popper.setAttribute('x-placement', placement);
  33958. // Apply `position` to popper before anything else because
  33959. // without the position applied we can't guarantee correct computations
  33960. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  33961. return options;
  33962. }
  33963. /**
  33964. * @function
  33965. * @memberof Popper.Utils
  33966. * @argument {Object} data - The data object generated by `update` method
  33967. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  33968. * @returns {Object} The popper's position offsets rounded
  33969. *
  33970. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  33971. * good as it can be within reason.
  33972. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  33973. *
  33974. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  33975. * as well on High DPI screens).
  33976. *
  33977. * Firefox prefers no rounding for positioning and does not have blurriness on
  33978. * high DPI screens.
  33979. *
  33980. * Only horizontal placement and left/right values need to be considered.
  33981. */
  33982. function getRoundedOffsets(data, shouldRound) {
  33983. var _data$offsets = data.offsets,
  33984. popper = _data$offsets.popper,
  33985. reference = _data$offsets.reference;
  33986. var round = Math.round,
  33987. floor = Math.floor;
  33988. var noRound = function noRound(v) {
  33989. return v;
  33990. };
  33991. var referenceWidth = round(reference.width);
  33992. var popperWidth = round(popper.width);
  33993. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  33994. var isVariation = data.placement.indexOf('-') !== -1;
  33995. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  33996. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  33997. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  33998. var verticalToInteger = !shouldRound ? noRound : round;
  33999. return {
  34000. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34001. top: verticalToInteger(popper.top),
  34002. bottom: verticalToInteger(popper.bottom),
  34003. right: horizontalToInteger(popper.right)
  34004. };
  34005. }
  34006. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34007. /**
  34008. * @function
  34009. * @memberof Modifiers
  34010. * @argument {Object} data - The data object generated by `update` method
  34011. * @argument {Object} options - Modifiers configuration and options
  34012. * @returns {Object} The data object, properly modified
  34013. */
  34014. function computeStyle(data, options) {
  34015. var x = options.x,
  34016. y = options.y;
  34017. var popper = data.offsets.popper;
  34018. // Remove this legacy support in Popper.js v2
  34019. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34020. return modifier.name === 'applyStyle';
  34021. }).gpuAcceleration;
  34022. if (legacyGpuAccelerationOption !== undefined) {
  34023. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34024. }
  34025. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34026. var offsetParent = getOffsetParent(data.instance.popper);
  34027. var offsetParentRect = getBoundingClientRect(offsetParent);
  34028. // Styles
  34029. var styles = {
  34030. position: popper.position
  34031. };
  34032. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34033. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34034. var sideB = y === 'right' ? 'left' : 'right';
  34035. // if gpuAcceleration is set to `true` and transform is supported,
  34036. // we use `translate3d` to apply the position to the popper we
  34037. // automatically use the supported prefixed version if needed
  34038. var prefixedProperty = getSupportedPropertyName('transform');
  34039. // now, let's make a step back and look at this code closely (wtf?)
  34040. // If the content of the popper grows once it's been positioned, it
  34041. // may happen that the popper gets misplaced because of the new content
  34042. // overflowing its reference element
  34043. // To avoid this problem, we provide two options (x and y), which allow
  34044. // the consumer to define the offset origin.
  34045. // If we position a popper on top of a reference element, we can set
  34046. // `x` to `top` to make the popper grow towards its top instead of
  34047. // its bottom.
  34048. var left = void 0,
  34049. top = void 0;
  34050. if (sideA === 'bottom') {
  34051. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34052. // and not the bottom of the html element
  34053. if (offsetParent.nodeName === 'HTML') {
  34054. top = -offsetParent.clientHeight + offsets.bottom;
  34055. } else {
  34056. top = -offsetParentRect.height + offsets.bottom;
  34057. }
  34058. } else {
  34059. top = offsets.top;
  34060. }
  34061. if (sideB === 'right') {
  34062. if (offsetParent.nodeName === 'HTML') {
  34063. left = -offsetParent.clientWidth + offsets.right;
  34064. } else {
  34065. left = -offsetParentRect.width + offsets.right;
  34066. }
  34067. } else {
  34068. left = offsets.left;
  34069. }
  34070. if (gpuAcceleration && prefixedProperty) {
  34071. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34072. styles[sideA] = 0;
  34073. styles[sideB] = 0;
  34074. styles.willChange = 'transform';
  34075. } else {
  34076. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34077. var invertTop = sideA === 'bottom' ? -1 : 1;
  34078. var invertLeft = sideB === 'right' ? -1 : 1;
  34079. styles[sideA] = top * invertTop;
  34080. styles[sideB] = left * invertLeft;
  34081. styles.willChange = sideA + ', ' + sideB;
  34082. }
  34083. // Attributes
  34084. var attributes = {
  34085. 'x-placement': data.placement
  34086. };
  34087. // Update `data` attributes, styles and arrowStyles
  34088. data.attributes = _extends({}, attributes, data.attributes);
  34089. data.styles = _extends({}, styles, data.styles);
  34090. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34091. return data;
  34092. }
  34093. /**
  34094. * Helper used to know if the given modifier depends from another one.<br />
  34095. * It checks if the needed modifier is listed and enabled.
  34096. * @method
  34097. * @memberof Popper.Utils
  34098. * @param {Array} modifiers - list of modifiers
  34099. * @param {String} requestingName - name of requesting modifier
  34100. * @param {String} requestedName - name of requested modifier
  34101. * @returns {Boolean}
  34102. */
  34103. function isModifierRequired(modifiers, requestingName, requestedName) {
  34104. var requesting = find(modifiers, function (_ref) {
  34105. var name = _ref.name;
  34106. return name === requestingName;
  34107. });
  34108. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34109. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34110. });
  34111. if (!isRequired) {
  34112. var _requesting = '`' + requestingName + '`';
  34113. var requested = '`' + requestedName + '`';
  34114. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34115. }
  34116. return isRequired;
  34117. }
  34118. /**
  34119. * @function
  34120. * @memberof Modifiers
  34121. * @argument {Object} data - The data object generated by update method
  34122. * @argument {Object} options - Modifiers configuration and options
  34123. * @returns {Object} The data object, properly modified
  34124. */
  34125. function arrow(data, options) {
  34126. var _data$offsets$arrow;
  34127. // arrow depends on keepTogether in order to work
  34128. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34129. return data;
  34130. }
  34131. var arrowElement = options.element;
  34132. // if arrowElement is a string, suppose it's a CSS selector
  34133. if (typeof arrowElement === 'string') {
  34134. arrowElement = data.instance.popper.querySelector(arrowElement);
  34135. // if arrowElement is not found, don't run the modifier
  34136. if (!arrowElement) {
  34137. return data;
  34138. }
  34139. } else {
  34140. // if the arrowElement isn't a query selector we must check that the
  34141. // provided DOM node is child of its popper node
  34142. if (!data.instance.popper.contains(arrowElement)) {
  34143. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34144. return data;
  34145. }
  34146. }
  34147. var placement = data.placement.split('-')[0];
  34148. var _data$offsets = data.offsets,
  34149. popper = _data$offsets.popper,
  34150. reference = _data$offsets.reference;
  34151. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34152. var len = isVertical ? 'height' : 'width';
  34153. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34154. var side = sideCapitalized.toLowerCase();
  34155. var altSide = isVertical ? 'left' : 'top';
  34156. var opSide = isVertical ? 'bottom' : 'right';
  34157. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34158. //
  34159. // extends keepTogether behavior making sure the popper and its
  34160. // reference have enough pixels in conjunction
  34161. //
  34162. // top/left side
  34163. if (reference[opSide] - arrowElementSize < popper[side]) {
  34164. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34165. }
  34166. // bottom/right side
  34167. if (reference[side] + arrowElementSize > popper[opSide]) {
  34168. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34169. }
  34170. data.offsets.popper = getClientRect(data.offsets.popper);
  34171. // compute center of the popper
  34172. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34173. // Compute the sideValue using the updated popper offsets
  34174. // take popper margin in account because we don't have this info available
  34175. var css = getStyleComputedProperty(data.instance.popper);
  34176. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34177. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34178. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34179. // prevent arrowElement from being placed not contiguously to its popper
  34180. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34181. data.arrowElement = arrowElement;
  34182. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34183. return data;
  34184. }
  34185. /**
  34186. * Get the opposite placement variation of the given one
  34187. * @method
  34188. * @memberof Popper.Utils
  34189. * @argument {String} placement variation
  34190. * @returns {String} flipped placement variation
  34191. */
  34192. function getOppositeVariation(variation) {
  34193. if (variation === 'end') {
  34194. return 'start';
  34195. } else if (variation === 'start') {
  34196. return 'end';
  34197. }
  34198. return variation;
  34199. }
  34200. /**
  34201. * List of accepted placements to use as values of the `placement` option.<br />
  34202. * Valid placements are:
  34203. * - `auto`
  34204. * - `top`
  34205. * - `right`
  34206. * - `bottom`
  34207. * - `left`
  34208. *
  34209. * Each placement can have a variation from this list:
  34210. * - `-start`
  34211. * - `-end`
  34212. *
  34213. * Variations are interpreted easily if you think of them as the left to right
  34214. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34215. * is right.<br />
  34216. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34217. *
  34218. * Some valid examples are:
  34219. * - `top-end` (on top of reference, right aligned)
  34220. * - `right-start` (on right of reference, top aligned)
  34221. * - `bottom` (on bottom, centered)
  34222. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34223. *
  34224. * @static
  34225. * @type {Array}
  34226. * @enum {String}
  34227. * @readonly
  34228. * @method placements
  34229. * @memberof Popper
  34230. */
  34231. 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'];
  34232. // Get rid of `auto` `auto-start` and `auto-end`
  34233. var validPlacements = placements.slice(3);
  34234. /**
  34235. * Given an initial placement, returns all the subsequent placements
  34236. * clockwise (or counter-clockwise).
  34237. *
  34238. * @method
  34239. * @memberof Popper.Utils
  34240. * @argument {String} placement - A valid placement (it accepts variations)
  34241. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34242. * @returns {Array} placements including their variations
  34243. */
  34244. function clockwise(placement) {
  34245. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34246. var index = validPlacements.indexOf(placement);
  34247. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34248. return counter ? arr.reverse() : arr;
  34249. }
  34250. var BEHAVIORS = {
  34251. FLIP: 'flip',
  34252. CLOCKWISE: 'clockwise',
  34253. COUNTERCLOCKWISE: 'counterclockwise'
  34254. };
  34255. /**
  34256. * @function
  34257. * @memberof Modifiers
  34258. * @argument {Object} data - The data object generated by update method
  34259. * @argument {Object} options - Modifiers configuration and options
  34260. * @returns {Object} The data object, properly modified
  34261. */
  34262. function flip(data, options) {
  34263. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34264. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34265. return data;
  34266. }
  34267. if (data.flipped && data.placement === data.originalPlacement) {
  34268. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34269. return data;
  34270. }
  34271. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34272. var placement = data.placement.split('-')[0];
  34273. var placementOpposite = getOppositePlacement(placement);
  34274. var variation = data.placement.split('-')[1] || '';
  34275. var flipOrder = [];
  34276. switch (options.behavior) {
  34277. case BEHAVIORS.FLIP:
  34278. flipOrder = [placement, placementOpposite];
  34279. break;
  34280. case BEHAVIORS.CLOCKWISE:
  34281. flipOrder = clockwise(placement);
  34282. break;
  34283. case BEHAVIORS.COUNTERCLOCKWISE:
  34284. flipOrder = clockwise(placement, true);
  34285. break;
  34286. default:
  34287. flipOrder = options.behavior;
  34288. }
  34289. flipOrder.forEach(function (step, index) {
  34290. if (placement !== step || flipOrder.length === index + 1) {
  34291. return data;
  34292. }
  34293. placement = data.placement.split('-')[0];
  34294. placementOpposite = getOppositePlacement(placement);
  34295. var popperOffsets = data.offsets.popper;
  34296. var refOffsets = data.offsets.reference;
  34297. // using floor because the reference offsets may contain decimals we are not going to consider here
  34298. var floor = Math.floor;
  34299. 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);
  34300. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34301. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34302. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34303. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34304. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34305. // flip the variation if required
  34306. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34307. // flips variation if reference element overflows boundaries
  34308. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34309. // flips variation if popper content overflows boundaries
  34310. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34311. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34312. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34313. // this boolean to detect any flip loop
  34314. data.flipped = true;
  34315. if (overlapsRef || overflowsBoundaries) {
  34316. placement = flipOrder[index + 1];
  34317. }
  34318. if (flippedVariation) {
  34319. variation = getOppositeVariation(variation);
  34320. }
  34321. data.placement = placement + (variation ? '-' + variation : '');
  34322. // this object contains `position`, we want to preserve it along with
  34323. // any additional property we may add in the future
  34324. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34325. data = runModifiers(data.instance.modifiers, data, 'flip');
  34326. }
  34327. });
  34328. return data;
  34329. }
  34330. /**
  34331. * @function
  34332. * @memberof Modifiers
  34333. * @argument {Object} data - The data object generated by update method
  34334. * @argument {Object} options - Modifiers configuration and options
  34335. * @returns {Object} The data object, properly modified
  34336. */
  34337. function keepTogether(data) {
  34338. var _data$offsets = data.offsets,
  34339. popper = _data$offsets.popper,
  34340. reference = _data$offsets.reference;
  34341. var placement = data.placement.split('-')[0];
  34342. var floor = Math.floor;
  34343. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34344. var side = isVertical ? 'right' : 'bottom';
  34345. var opSide = isVertical ? 'left' : 'top';
  34346. var measurement = isVertical ? 'width' : 'height';
  34347. if (popper[side] < floor(reference[opSide])) {
  34348. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34349. }
  34350. if (popper[opSide] > floor(reference[side])) {
  34351. data.offsets.popper[opSide] = floor(reference[side]);
  34352. }
  34353. return data;
  34354. }
  34355. /**
  34356. * Converts a string containing value + unit into a px value number
  34357. * @function
  34358. * @memberof {modifiers~offset}
  34359. * @private
  34360. * @argument {String} str - Value + unit string
  34361. * @argument {String} measurement - `height` or `width`
  34362. * @argument {Object} popperOffsets
  34363. * @argument {Object} referenceOffsets
  34364. * @returns {Number|String}
  34365. * Value in pixels, or original string if no values were extracted
  34366. */
  34367. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34368. // separate value from unit
  34369. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34370. var value = +split[1];
  34371. var unit = split[2];
  34372. // If it's not a number it's an operator, I guess
  34373. if (!value) {
  34374. return str;
  34375. }
  34376. if (unit.indexOf('%') === 0) {
  34377. var element = void 0;
  34378. switch (unit) {
  34379. case '%p':
  34380. element = popperOffsets;
  34381. break;
  34382. case '%':
  34383. case '%r':
  34384. default:
  34385. element = referenceOffsets;
  34386. }
  34387. var rect = getClientRect(element);
  34388. return rect[measurement] / 100 * value;
  34389. } else if (unit === 'vh' || unit === 'vw') {
  34390. // if is a vh or vw, we calculate the size based on the viewport
  34391. var size = void 0;
  34392. if (unit === 'vh') {
  34393. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34394. } else {
  34395. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34396. }
  34397. return size / 100 * value;
  34398. } else {
  34399. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34400. // if is an implicit unit, it's px, and we return just the value
  34401. return value;
  34402. }
  34403. }
  34404. /**
  34405. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34406. * @function
  34407. * @memberof {modifiers~offset}
  34408. * @private
  34409. * @argument {String} offset
  34410. * @argument {Object} popperOffsets
  34411. * @argument {Object} referenceOffsets
  34412. * @argument {String} basePlacement
  34413. * @returns {Array} a two cells array with x and y offsets in numbers
  34414. */
  34415. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34416. var offsets = [0, 0];
  34417. // Use height if placement is left or right and index is 0 otherwise use width
  34418. // in this way the first offset will use an axis and the second one
  34419. // will use the other one
  34420. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34421. // Split the offset string to obtain a list of values and operands
  34422. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34423. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34424. return frag.trim();
  34425. });
  34426. // Detect if the offset string contains a pair of values or a single one
  34427. // they could be separated by comma or space
  34428. var divider = fragments.indexOf(find(fragments, function (frag) {
  34429. return frag.search(/,|\s/) !== -1;
  34430. }));
  34431. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34432. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34433. }
  34434. // If divider is found, we divide the list of values and operands to divide
  34435. // them by ofset X and Y.
  34436. var splitRegex = /\s*,\s*|\s+/;
  34437. 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];
  34438. // Convert the values with units to absolute pixels to allow our computations
  34439. ops = ops.map(function (op, index) {
  34440. // Most of the units rely on the orientation of the popper
  34441. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34442. var mergeWithPrevious = false;
  34443. return op
  34444. // This aggregates any `+` or `-` sign that aren't considered operators
  34445. // e.g.: 10 + +5 => [10, +, +5]
  34446. .reduce(function (a, b) {
  34447. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34448. a[a.length - 1] = b;
  34449. mergeWithPrevious = true;
  34450. return a;
  34451. } else if (mergeWithPrevious) {
  34452. a[a.length - 1] += b;
  34453. mergeWithPrevious = false;
  34454. return a;
  34455. } else {
  34456. return a.concat(b);
  34457. }
  34458. }, [])
  34459. // Here we convert the string values into number values (in px)
  34460. .map(function (str) {
  34461. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34462. });
  34463. });
  34464. // Loop trough the offsets arrays and execute the operations
  34465. ops.forEach(function (op, index) {
  34466. op.forEach(function (frag, index2) {
  34467. if (isNumeric(frag)) {
  34468. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34469. }
  34470. });
  34471. });
  34472. return offsets;
  34473. }
  34474. /**
  34475. * @function
  34476. * @memberof Modifiers
  34477. * @argument {Object} data - The data object generated by update method
  34478. * @argument {Object} options - Modifiers configuration and options
  34479. * @argument {Number|String} options.offset=0
  34480. * The offset value as described in the modifier description
  34481. * @returns {Object} The data object, properly modified
  34482. */
  34483. function offset(data, _ref) {
  34484. var offset = _ref.offset;
  34485. var placement = data.placement,
  34486. _data$offsets = data.offsets,
  34487. popper = _data$offsets.popper,
  34488. reference = _data$offsets.reference;
  34489. var basePlacement = placement.split('-')[0];
  34490. var offsets = void 0;
  34491. if (isNumeric(+offset)) {
  34492. offsets = [+offset, 0];
  34493. } else {
  34494. offsets = parseOffset(offset, popper, reference, basePlacement);
  34495. }
  34496. if (basePlacement === 'left') {
  34497. popper.top += offsets[0];
  34498. popper.left -= offsets[1];
  34499. } else if (basePlacement === 'right') {
  34500. popper.top += offsets[0];
  34501. popper.left += offsets[1];
  34502. } else if (basePlacement === 'top') {
  34503. popper.left += offsets[0];
  34504. popper.top -= offsets[1];
  34505. } else if (basePlacement === 'bottom') {
  34506. popper.left += offsets[0];
  34507. popper.top += offsets[1];
  34508. }
  34509. data.popper = popper;
  34510. return data;
  34511. }
  34512. /**
  34513. * @function
  34514. * @memberof Modifiers
  34515. * @argument {Object} data - The data object generated by `update` method
  34516. * @argument {Object} options - Modifiers configuration and options
  34517. * @returns {Object} The data object, properly modified
  34518. */
  34519. function preventOverflow(data, options) {
  34520. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34521. // If offsetParent is the reference element, we really want to
  34522. // go one step up and use the next offsetParent as reference to
  34523. // avoid to make this modifier completely useless and look like broken
  34524. if (data.instance.reference === boundariesElement) {
  34525. boundariesElement = getOffsetParent(boundariesElement);
  34526. }
  34527. // NOTE: DOM access here
  34528. // resets the popper's position so that the document size can be calculated excluding
  34529. // the size of the popper element itself
  34530. var transformProp = getSupportedPropertyName('transform');
  34531. var popperStyles = data.instance.popper.style; // assignment to help minification
  34532. var top = popperStyles.top,
  34533. left = popperStyles.left,
  34534. transform = popperStyles[transformProp];
  34535. popperStyles.top = '';
  34536. popperStyles.left = '';
  34537. popperStyles[transformProp] = '';
  34538. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34539. // NOTE: DOM access here
  34540. // restores the original style properties after the offsets have been computed
  34541. popperStyles.top = top;
  34542. popperStyles.left = left;
  34543. popperStyles[transformProp] = transform;
  34544. options.boundaries = boundaries;
  34545. var order = options.priority;
  34546. var popper = data.offsets.popper;
  34547. var check = {
  34548. primary: function primary(placement) {
  34549. var value = popper[placement];
  34550. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34551. value = Math.max(popper[placement], boundaries[placement]);
  34552. }
  34553. return defineProperty({}, placement, value);
  34554. },
  34555. secondary: function secondary(placement) {
  34556. var mainSide = placement === 'right' ? 'left' : 'top';
  34557. var value = popper[mainSide];
  34558. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34559. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34560. }
  34561. return defineProperty({}, mainSide, value);
  34562. }
  34563. };
  34564. order.forEach(function (placement) {
  34565. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34566. popper = _extends({}, popper, check[side](placement));
  34567. });
  34568. data.offsets.popper = popper;
  34569. return data;
  34570. }
  34571. /**
  34572. * @function
  34573. * @memberof Modifiers
  34574. * @argument {Object} data - The data object generated by `update` method
  34575. * @argument {Object} options - Modifiers configuration and options
  34576. * @returns {Object} The data object, properly modified
  34577. */
  34578. function shift(data) {
  34579. var placement = data.placement;
  34580. var basePlacement = placement.split('-')[0];
  34581. var shiftvariation = placement.split('-')[1];
  34582. // if shift shiftvariation is specified, run the modifier
  34583. if (shiftvariation) {
  34584. var _data$offsets = data.offsets,
  34585. reference = _data$offsets.reference,
  34586. popper = _data$offsets.popper;
  34587. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34588. var side = isVertical ? 'left' : 'top';
  34589. var measurement = isVertical ? 'width' : 'height';
  34590. var shiftOffsets = {
  34591. start: defineProperty({}, side, reference[side]),
  34592. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34593. };
  34594. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  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 hide(data) {
  34606. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34607. return data;
  34608. }
  34609. var refRect = data.offsets.reference;
  34610. var bound = find(data.instance.modifiers, function (modifier) {
  34611. return modifier.name === 'preventOverflow';
  34612. }).boundaries;
  34613. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34614. // Avoid unnecessary DOM access if visibility hasn't changed
  34615. if (data.hide === true) {
  34616. return data;
  34617. }
  34618. data.hide = true;
  34619. data.attributes['x-out-of-boundaries'] = '';
  34620. } else {
  34621. // Avoid unnecessary DOM access if visibility hasn't changed
  34622. if (data.hide === false) {
  34623. return data;
  34624. }
  34625. data.hide = false;
  34626. data.attributes['x-out-of-boundaries'] = false;
  34627. }
  34628. return data;
  34629. }
  34630. /**
  34631. * @function
  34632. * @memberof Modifiers
  34633. * @argument {Object} data - The data object generated by `update` method
  34634. * @argument {Object} options - Modifiers configuration and options
  34635. * @returns {Object} The data object, properly modified
  34636. */
  34637. function inner(data) {
  34638. var placement = data.placement;
  34639. var basePlacement = placement.split('-')[0];
  34640. var _data$offsets = data.offsets,
  34641. popper = _data$offsets.popper,
  34642. reference = _data$offsets.reference;
  34643. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34644. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34645. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34646. data.placement = getOppositePlacement(placement);
  34647. data.offsets.popper = getClientRect(popper);
  34648. return data;
  34649. }
  34650. /**
  34651. * Modifier function, each modifier can have a function of this type assigned
  34652. * to its `fn` property.<br />
  34653. * These functions will be called on each update, this means that you must
  34654. * make sure they are performant enough to avoid performance bottlenecks.
  34655. *
  34656. * @function ModifierFn
  34657. * @argument {dataObject} data - The data object generated by `update` method
  34658. * @argument {Object} options - Modifiers configuration and options
  34659. * @returns {dataObject} The data object, properly modified
  34660. */
  34661. /**
  34662. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34663. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34664. * needed by the library.
  34665. *
  34666. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34667. * All the other properties are configurations that could be tweaked.
  34668. * @namespace modifiers
  34669. */
  34670. var modifiers = {
  34671. /**
  34672. * Modifier used to shift the popper on the start or end of its reference
  34673. * element.<br />
  34674. * It will read the variation of the `placement` property.<br />
  34675. * It can be one either `-end` or `-start`.
  34676. * @memberof modifiers
  34677. * @inner
  34678. */
  34679. shift: {
  34680. /** @prop {number} order=100 - Index used to define the order of execution */
  34681. order: 100,
  34682. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34683. enabled: true,
  34684. /** @prop {ModifierFn} */
  34685. fn: shift
  34686. },
  34687. /**
  34688. * The `offset` modifier can shift your popper on both its axis.
  34689. *
  34690. * It accepts the following units:
  34691. * - `px` or unit-less, interpreted as pixels
  34692. * - `%` or `%r`, percentage relative to the length of the reference element
  34693. * - `%p`, percentage relative to the length of the popper element
  34694. * - `vw`, CSS viewport width unit
  34695. * - `vh`, CSS viewport height unit
  34696. *
  34697. * For length is intended the main axis relative to the placement of the popper.<br />
  34698. * This means that if the placement is `top` or `bottom`, the length will be the
  34699. * `width`. In case of `left` or `right`, it will be the `height`.
  34700. *
  34701. * You can provide a single value (as `Number` or `String`), or a pair of values
  34702. * as `String` divided by a comma or one (or more) white spaces.<br />
  34703. * The latter is a deprecated method because it leads to confusion and will be
  34704. * removed in v2.<br />
  34705. * Additionally, it accepts additions and subtractions between different units.
  34706. * Note that multiplications and divisions aren't supported.
  34707. *
  34708. * Valid examples are:
  34709. * ```
  34710. * 10
  34711. * '10%'
  34712. * '10, 10'
  34713. * '10%, 10'
  34714. * '10 + 10%'
  34715. * '10 - 5vh + 3%'
  34716. * '-10px + 5vh, 5px - 6%'
  34717. * ```
  34718. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34719. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34720. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34721. *
  34722. * @memberof modifiers
  34723. * @inner
  34724. */
  34725. offset: {
  34726. /** @prop {number} order=200 - Index used to define the order of execution */
  34727. order: 200,
  34728. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34729. enabled: true,
  34730. /** @prop {ModifierFn} */
  34731. fn: offset,
  34732. /** @prop {Number|String} offset=0
  34733. * The offset value as described in the modifier description
  34734. */
  34735. offset: 0
  34736. },
  34737. /**
  34738. * Modifier used to prevent the popper from being positioned outside the boundary.
  34739. *
  34740. * A scenario exists where the reference itself is not within the boundaries.<br />
  34741. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34742. * In this case we need to decide whether the popper should either:
  34743. *
  34744. * - detach from the reference and remain "trapped" in the boundaries, or
  34745. * - if it should ignore the boundary and "escape with its reference"
  34746. *
  34747. * When `escapeWithReference` is set to`true` and reference is completely
  34748. * outside its boundaries, the popper will overflow (or completely leave)
  34749. * the boundaries in order to remain attached to the edge of the reference.
  34750. *
  34751. * @memberof modifiers
  34752. * @inner
  34753. */
  34754. preventOverflow: {
  34755. /** @prop {number} order=300 - Index used to define the order of execution */
  34756. order: 300,
  34757. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34758. enabled: true,
  34759. /** @prop {ModifierFn} */
  34760. fn: preventOverflow,
  34761. /**
  34762. * @prop {Array} [priority=['left','right','top','bottom']]
  34763. * Popper will try to prevent overflow following these priorities by default,
  34764. * then, it could overflow on the left and on top of the `boundariesElement`
  34765. */
  34766. priority: ['left', 'right', 'top', 'bottom'],
  34767. /**
  34768. * @prop {number} padding=5
  34769. * Amount of pixel used to define a minimum distance between the boundaries
  34770. * and the popper. This makes sure the popper always has a little padding
  34771. * between the edges of its container
  34772. */
  34773. padding: 5,
  34774. /**
  34775. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34776. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34777. * `viewport` or any DOM element.
  34778. */
  34779. boundariesElement: 'scrollParent'
  34780. },
  34781. /**
  34782. * Modifier used to make sure the reference and its popper stay near each other
  34783. * without leaving any gap between the two. Especially useful when the arrow is
  34784. * enabled and you want to ensure that it points to its reference element.
  34785. * It cares only about the first axis. You can still have poppers with margin
  34786. * between the popper and its reference element.
  34787. * @memberof modifiers
  34788. * @inner
  34789. */
  34790. keepTogether: {
  34791. /** @prop {number} order=400 - Index used to define the order of execution */
  34792. order: 400,
  34793. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34794. enabled: true,
  34795. /** @prop {ModifierFn} */
  34796. fn: keepTogether
  34797. },
  34798. /**
  34799. * This modifier is used to move the `arrowElement` of the popper to make
  34800. * sure it is positioned between the reference element and its popper element.
  34801. * It will read the outer size of the `arrowElement` node to detect how many
  34802. * pixels of conjunction are needed.
  34803. *
  34804. * It has no effect if no `arrowElement` is provided.
  34805. * @memberof modifiers
  34806. * @inner
  34807. */
  34808. arrow: {
  34809. /** @prop {number} order=500 - Index used to define the order of execution */
  34810. order: 500,
  34811. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34812. enabled: true,
  34813. /** @prop {ModifierFn} */
  34814. fn: arrow,
  34815. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34816. element: '[x-arrow]'
  34817. },
  34818. /**
  34819. * Modifier used to flip the popper's placement when it starts to overlap its
  34820. * reference element.
  34821. *
  34822. * Requires the `preventOverflow` modifier before it in order to work.
  34823. *
  34824. * **NOTE:** this modifier will interrupt the current update cycle and will
  34825. * restart it if it detects the need to flip the placement.
  34826. * @memberof modifiers
  34827. * @inner
  34828. */
  34829. flip: {
  34830. /** @prop {number} order=600 - Index used to define the order of execution */
  34831. order: 600,
  34832. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34833. enabled: true,
  34834. /** @prop {ModifierFn} */
  34835. fn: flip,
  34836. /**
  34837. * @prop {String|Array} behavior='flip'
  34838. * The behavior used to change the popper's placement. It can be one of
  34839. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34840. * placements (with optional variations)
  34841. */
  34842. behavior: 'flip',
  34843. /**
  34844. * @prop {number} padding=5
  34845. * The popper will flip if it hits the edges of the `boundariesElement`
  34846. */
  34847. padding: 5,
  34848. /**
  34849. * @prop {String|HTMLElement} boundariesElement='viewport'
  34850. * The element which will define the boundaries of the popper position.
  34851. * The popper will never be placed outside of the defined boundaries
  34852. * (except if `keepTogether` is enabled)
  34853. */
  34854. boundariesElement: 'viewport',
  34855. /**
  34856. * @prop {Boolean} flipVariations=false
  34857. * The popper will switch placement variation between `-start` and `-end` when
  34858. * the reference element overlaps its boundaries.
  34859. *
  34860. * The original placement should have a set variation.
  34861. */
  34862. flipVariations: false,
  34863. /**
  34864. * @prop {Boolean} flipVariationsByContent=false
  34865. * The popper will switch placement variation between `-start` and `-end` when
  34866. * the popper element overlaps its reference boundaries.
  34867. *
  34868. * The original placement should have a set variation.
  34869. */
  34870. flipVariationsByContent: false
  34871. },
  34872. /**
  34873. * Modifier used to make the popper flow toward the inner of the reference element.
  34874. * By default, when this modifier is disabled, the popper will be placed outside
  34875. * the reference element.
  34876. * @memberof modifiers
  34877. * @inner
  34878. */
  34879. inner: {
  34880. /** @prop {number} order=700 - Index used to define the order of execution */
  34881. order: 700,
  34882. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34883. enabled: false,
  34884. /** @prop {ModifierFn} */
  34885. fn: inner
  34886. },
  34887. /**
  34888. * Modifier used to hide the popper when its reference element is outside of the
  34889. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34890. * be used to hide with a CSS selector the popper when its reference is
  34891. * out of boundaries.
  34892. *
  34893. * Requires the `preventOverflow` modifier before it in order to work.
  34894. * @memberof modifiers
  34895. * @inner
  34896. */
  34897. hide: {
  34898. /** @prop {number} order=800 - Index used to define the order of execution */
  34899. order: 800,
  34900. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34901. enabled: true,
  34902. /** @prop {ModifierFn} */
  34903. fn: hide
  34904. },
  34905. /**
  34906. * Computes the style that will be applied to the popper element to gets
  34907. * properly positioned.
  34908. *
  34909. * Note that this modifier will not touch the DOM, it just prepares the styles
  34910. * so that `applyStyle` modifier can apply it. This separation is useful
  34911. * in case you need to replace `applyStyle` with a custom implementation.
  34912. *
  34913. * This modifier has `850` as `order` value to maintain backward compatibility
  34914. * with previous versions of Popper.js. Expect the modifiers ordering method
  34915. * to change in future major versions of the library.
  34916. *
  34917. * @memberof modifiers
  34918. * @inner
  34919. */
  34920. computeStyle: {
  34921. /** @prop {number} order=850 - Index used to define the order of execution */
  34922. order: 850,
  34923. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34924. enabled: true,
  34925. /** @prop {ModifierFn} */
  34926. fn: computeStyle,
  34927. /**
  34928. * @prop {Boolean} gpuAcceleration=true
  34929. * If true, it uses the CSS 3D transformation to position the popper.
  34930. * Otherwise, it will use the `top` and `left` properties
  34931. */
  34932. gpuAcceleration: true,
  34933. /**
  34934. * @prop {string} [x='bottom']
  34935. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34936. * Change this if your popper should grow in a direction different from `bottom`
  34937. */
  34938. x: 'bottom',
  34939. /**
  34940. * @prop {string} [x='left']
  34941. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34942. * Change this if your popper should grow in a direction different from `right`
  34943. */
  34944. y: 'right'
  34945. },
  34946. /**
  34947. * Applies the computed styles to the popper element.
  34948. *
  34949. * All the DOM manipulations are limited to this modifier. This is useful in case
  34950. * you want to integrate Popper.js inside a framework or view library and you
  34951. * want to delegate all the DOM manipulations to it.
  34952. *
  34953. * Note that if you disable this modifier, you must make sure the popper element
  34954. * has its position set to `absolute` before Popper.js can do its work!
  34955. *
  34956. * Just disable this modifier and define your own to achieve the desired effect.
  34957. *
  34958. * @memberof modifiers
  34959. * @inner
  34960. */
  34961. applyStyle: {
  34962. /** @prop {number} order=900 - Index used to define the order of execution */
  34963. order: 900,
  34964. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34965. enabled: true,
  34966. /** @prop {ModifierFn} */
  34967. fn: applyStyle,
  34968. /** @prop {Function} */
  34969. onLoad: applyStyleOnLoad,
  34970. /**
  34971. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  34972. * @prop {Boolean} gpuAcceleration=true
  34973. * If true, it uses the CSS 3D transformation to position the popper.
  34974. * Otherwise, it will use the `top` and `left` properties
  34975. */
  34976. gpuAcceleration: undefined
  34977. }
  34978. };
  34979. /**
  34980. * The `dataObject` is an object containing all the information used by Popper.js.
  34981. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  34982. * @name dataObject
  34983. * @property {Object} data.instance The Popper.js instance
  34984. * @property {String} data.placement Placement applied to popper
  34985. * @property {String} data.originalPlacement Placement originally defined on init
  34986. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  34987. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  34988. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  34989. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34990. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34991. * @property {Object} data.boundaries Offsets of the popper boundaries
  34992. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  34993. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  34994. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  34995. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  34996. */
  34997. /**
  34998. * Default options provided to Popper.js constructor.<br />
  34999. * These can be overridden using the `options` argument of Popper.js.<br />
  35000. * To override an option, simply pass an object with the same
  35001. * structure of the `options` object, as the 3rd argument. For example:
  35002. * ```
  35003. * new Popper(ref, pop, {
  35004. * modifiers: {
  35005. * preventOverflow: { enabled: false }
  35006. * }
  35007. * })
  35008. * ```
  35009. * @type {Object}
  35010. * @static
  35011. * @memberof Popper
  35012. */
  35013. var Defaults = {
  35014. /**
  35015. * Popper's placement.
  35016. * @prop {Popper.placements} placement='bottom'
  35017. */
  35018. placement: 'bottom',
  35019. /**
  35020. * Set this to true if you want popper to position it self in 'fixed' mode
  35021. * @prop {Boolean} positionFixed=false
  35022. */
  35023. positionFixed: false,
  35024. /**
  35025. * Whether events (resize, scroll) are initially enabled.
  35026. * @prop {Boolean} eventsEnabled=true
  35027. */
  35028. eventsEnabled: true,
  35029. /**
  35030. * Set to true if you want to automatically remove the popper when
  35031. * you call the `destroy` method.
  35032. * @prop {Boolean} removeOnDestroy=false
  35033. */
  35034. removeOnDestroy: false,
  35035. /**
  35036. * Callback called when the popper is created.<br />
  35037. * By default, it is set to no-op.<br />
  35038. * Access Popper.js instance with `data.instance`.
  35039. * @prop {onCreate}
  35040. */
  35041. onCreate: function onCreate() {},
  35042. /**
  35043. * Callback called when the popper is updated. This callback is not called
  35044. * on the initialization/creation of the popper, but only on subsequent
  35045. * updates.<br />
  35046. * By default, it is set to no-op.<br />
  35047. * Access Popper.js instance with `data.instance`.
  35048. * @prop {onUpdate}
  35049. */
  35050. onUpdate: function onUpdate() {},
  35051. /**
  35052. * List of modifiers used to modify the offsets before they are applied to the popper.
  35053. * They provide most of the functionalities of Popper.js.
  35054. * @prop {modifiers}
  35055. */
  35056. modifiers: modifiers
  35057. };
  35058. /**
  35059. * @callback onCreate
  35060. * @param {dataObject} data
  35061. */
  35062. /**
  35063. * @callback onUpdate
  35064. * @param {dataObject} data
  35065. */
  35066. // Utils
  35067. // Methods
  35068. var Popper = function () {
  35069. /**
  35070. * Creates a new Popper.js instance.
  35071. * @class Popper
  35072. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35073. * @param {Element} popper - The HTML / XML element used as the popper
  35074. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35075. * @return {Object} instance - The generated Popper.js instance
  35076. */
  35077. function Popper(reference, popper) {
  35078. var _this = this;
  35079. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35080. classCallCheck(this, Popper);
  35081. this.scheduleUpdate = function () {
  35082. return requestAnimationFrame(_this.update);
  35083. };
  35084. // make update() debounced, so that it only runs at most once-per-tick
  35085. this.update = debounce(this.update.bind(this));
  35086. // with {} we create a new object with the options inside it
  35087. this.options = _extends({}, Popper.Defaults, options);
  35088. // init state
  35089. this.state = {
  35090. isDestroyed: false,
  35091. isCreated: false,
  35092. scrollParents: []
  35093. };
  35094. // get reference and popper elements (allow jQuery wrappers)
  35095. this.reference = reference && reference.jquery ? reference[0] : reference;
  35096. this.popper = popper && popper.jquery ? popper[0] : popper;
  35097. // Deep merge modifiers options
  35098. this.options.modifiers = {};
  35099. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35100. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35101. });
  35102. // Refactoring modifiers' list (Object => Array)
  35103. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35104. return _extends({
  35105. name: name
  35106. }, _this.options.modifiers[name]);
  35107. })
  35108. // sort the modifiers by order
  35109. .sort(function (a, b) {
  35110. return a.order - b.order;
  35111. });
  35112. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35113. // such code is executed in the same order of its modifier
  35114. // they could add new properties to their options configuration
  35115. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35116. this.modifiers.forEach(function (modifierOptions) {
  35117. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35118. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35119. }
  35120. });
  35121. // fire the first update to position the popper in the right place
  35122. this.update();
  35123. var eventsEnabled = this.options.eventsEnabled;
  35124. if (eventsEnabled) {
  35125. // setup event listeners, they will take care of update the position in specific situations
  35126. this.enableEventListeners();
  35127. }
  35128. this.state.eventsEnabled = eventsEnabled;
  35129. }
  35130. // We can't use class properties because they don't get listed in the
  35131. // class prototype and break stuff like Sinon stubs
  35132. createClass(Popper, [{
  35133. key: 'update',
  35134. value: function update$$1() {
  35135. return update.call(this);
  35136. }
  35137. }, {
  35138. key: 'destroy',
  35139. value: function destroy$$1() {
  35140. return destroy.call(this);
  35141. }
  35142. }, {
  35143. key: 'enableEventListeners',
  35144. value: function enableEventListeners$$1() {
  35145. return enableEventListeners.call(this);
  35146. }
  35147. }, {
  35148. key: 'disableEventListeners',
  35149. value: function disableEventListeners$$1() {
  35150. return disableEventListeners.call(this);
  35151. }
  35152. /**
  35153. * Schedules an update. It will run on the next UI update available.
  35154. * @method scheduleUpdate
  35155. * @memberof Popper
  35156. */
  35157. /**
  35158. * Collection of utilities useful when writing custom modifiers.
  35159. * Starting from version 1.7, this method is available only if you
  35160. * include `popper-utils.js` before `popper.js`.
  35161. *
  35162. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35163. * and will be removed in v2! Use the PopperUtils module directly instead.
  35164. * Due to the high instability of the methods contained in Utils, we can't
  35165. * guarantee them to follow semver. Use them at your own risk!
  35166. * @static
  35167. * @private
  35168. * @type {Object}
  35169. * @deprecated since version 1.8
  35170. * @member Utils
  35171. * @memberof Popper
  35172. */
  35173. }]);
  35174. return Popper;
  35175. }();
  35176. /**
  35177. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35178. * and lets you use it as replacement of a real DOM node.<br />
  35179. * You can use this method to position a popper relatively to a set of coordinates
  35180. * in case you don't have a DOM node to use as reference.
  35181. *
  35182. * ```
  35183. * new Popper(referenceObject, popperNode);
  35184. * ```
  35185. *
  35186. * NB: This feature isn't supported in Internet Explorer 10.
  35187. * @name referenceObject
  35188. * @property {Function} data.getBoundingClientRect
  35189. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35190. * @property {number} data.clientWidth
  35191. * An ES6 getter that will return the width of the virtual reference element.
  35192. * @property {number} data.clientHeight
  35193. * An ES6 getter that will return the height of the virtual reference element.
  35194. */
  35195. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35196. Popper.placements = placements;
  35197. Popper.Defaults = Defaults;
  35198. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35199. //# sourceMappingURL=popper.js.map
  35200. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35201. /***/ }),
  35202. /***/ "./node_modules/process/browser.js":
  35203. /*!*****************************************!*\
  35204. !*** ./node_modules/process/browser.js ***!
  35205. \*****************************************/
  35206. /*! no static exports found */
  35207. /***/ (function(module, exports) {
  35208. // shim for using process in browser
  35209. var process = module.exports = {};
  35210. // cached from whatever global is present so that test runners that stub it
  35211. // don't break things. But we need to wrap it in a try catch in case it is
  35212. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35213. // function because try/catches deoptimize in certain engines.
  35214. var cachedSetTimeout;
  35215. var cachedClearTimeout;
  35216. function defaultSetTimout() {
  35217. throw new Error('setTimeout has not been defined');
  35218. }
  35219. function defaultClearTimeout () {
  35220. throw new Error('clearTimeout has not been defined');
  35221. }
  35222. (function () {
  35223. try {
  35224. if (typeof setTimeout === 'function') {
  35225. cachedSetTimeout = setTimeout;
  35226. } else {
  35227. cachedSetTimeout = defaultSetTimout;
  35228. }
  35229. } catch (e) {
  35230. cachedSetTimeout = defaultSetTimout;
  35231. }
  35232. try {
  35233. if (typeof clearTimeout === 'function') {
  35234. cachedClearTimeout = clearTimeout;
  35235. } else {
  35236. cachedClearTimeout = defaultClearTimeout;
  35237. }
  35238. } catch (e) {
  35239. cachedClearTimeout = defaultClearTimeout;
  35240. }
  35241. } ())
  35242. function runTimeout(fun) {
  35243. if (cachedSetTimeout === setTimeout) {
  35244. //normal enviroments in sane situations
  35245. return setTimeout(fun, 0);
  35246. }
  35247. // if setTimeout wasn't available but was latter defined
  35248. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35249. cachedSetTimeout = setTimeout;
  35250. return setTimeout(fun, 0);
  35251. }
  35252. try {
  35253. // when when somebody has screwed with setTimeout but no I.E. maddness
  35254. return cachedSetTimeout(fun, 0);
  35255. } catch(e){
  35256. try {
  35257. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35258. return cachedSetTimeout.call(null, fun, 0);
  35259. } catch(e){
  35260. // 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
  35261. return cachedSetTimeout.call(this, fun, 0);
  35262. }
  35263. }
  35264. }
  35265. function runClearTimeout(marker) {
  35266. if (cachedClearTimeout === clearTimeout) {
  35267. //normal enviroments in sane situations
  35268. return clearTimeout(marker);
  35269. }
  35270. // if clearTimeout wasn't available but was latter defined
  35271. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35272. cachedClearTimeout = clearTimeout;
  35273. return clearTimeout(marker);
  35274. }
  35275. try {
  35276. // when when somebody has screwed with setTimeout but no I.E. maddness
  35277. return cachedClearTimeout(marker);
  35278. } catch (e){
  35279. try {
  35280. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35281. return cachedClearTimeout.call(null, marker);
  35282. } catch (e){
  35283. // 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.
  35284. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35285. return cachedClearTimeout.call(this, marker);
  35286. }
  35287. }
  35288. }
  35289. var queue = [];
  35290. var draining = false;
  35291. var currentQueue;
  35292. var queueIndex = -1;
  35293. function cleanUpNextTick() {
  35294. if (!draining || !currentQueue) {
  35295. return;
  35296. }
  35297. draining = false;
  35298. if (currentQueue.length) {
  35299. queue = currentQueue.concat(queue);
  35300. } else {
  35301. queueIndex = -1;
  35302. }
  35303. if (queue.length) {
  35304. drainQueue();
  35305. }
  35306. }
  35307. function drainQueue() {
  35308. if (draining) {
  35309. return;
  35310. }
  35311. var timeout = runTimeout(cleanUpNextTick);
  35312. draining = true;
  35313. var len = queue.length;
  35314. while(len) {
  35315. currentQueue = queue;
  35316. queue = [];
  35317. while (++queueIndex < len) {
  35318. if (currentQueue) {
  35319. currentQueue[queueIndex].run();
  35320. }
  35321. }
  35322. queueIndex = -1;
  35323. len = queue.length;
  35324. }
  35325. currentQueue = null;
  35326. draining = false;
  35327. runClearTimeout(timeout);
  35328. }
  35329. process.nextTick = function (fun) {
  35330. var args = new Array(arguments.length - 1);
  35331. if (arguments.length > 1) {
  35332. for (var i = 1; i < arguments.length; i++) {
  35333. args[i - 1] = arguments[i];
  35334. }
  35335. }
  35336. queue.push(new Item(fun, args));
  35337. if (queue.length === 1 && !draining) {
  35338. runTimeout(drainQueue);
  35339. }
  35340. };
  35341. // v8 likes predictible objects
  35342. function Item(fun, array) {
  35343. this.fun = fun;
  35344. this.array = array;
  35345. }
  35346. Item.prototype.run = function () {
  35347. this.fun.apply(null, this.array);
  35348. };
  35349. process.title = 'browser';
  35350. process.browser = true;
  35351. process.env = {};
  35352. process.argv = [];
  35353. process.version = ''; // empty string to avoid regexp issues
  35354. process.versions = {};
  35355. function noop() {}
  35356. process.on = noop;
  35357. process.addListener = noop;
  35358. process.once = noop;
  35359. process.off = noop;
  35360. process.removeListener = noop;
  35361. process.removeAllListeners = noop;
  35362. process.emit = noop;
  35363. process.prependListener = noop;
  35364. process.prependOnceListener = noop;
  35365. process.listeners = function (name) { return [] }
  35366. process.binding = function (name) {
  35367. throw new Error('process.binding is not supported');
  35368. };
  35369. process.cwd = function () { return '/' };
  35370. process.chdir = function (dir) {
  35371. throw new Error('process.chdir is not supported');
  35372. };
  35373. process.umask = function() { return 0; };
  35374. /***/ }),
  35375. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35376. /*!***************************************************!*\
  35377. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35378. \***************************************************/
  35379. /*! no static exports found */
  35380. /***/ (function(module, exports, __webpack_require__) {
  35381. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35382. * Pusher JavaScript Library v5.0.3
  35383. * https://pusher.com/
  35384. *
  35385. * Copyright 2017, Pusher
  35386. * Released under the MIT licence.
  35387. */
  35388. (function webpackUniversalModuleDefinition(root, factory) {
  35389. if(true)
  35390. module.exports = factory();
  35391. else {}
  35392. })(window, function() {
  35393. return /******/ (function(modules) { // webpackBootstrap
  35394. /******/ // The module cache
  35395. /******/ var installedModules = {};
  35396. /******/
  35397. /******/ // The require function
  35398. /******/ function __webpack_require__(moduleId) {
  35399. /******/
  35400. /******/ // Check if module is in cache
  35401. /******/ if(installedModules[moduleId]) {
  35402. /******/ return installedModules[moduleId].exports;
  35403. /******/ }
  35404. /******/ // Create a new module (and put it into the cache)
  35405. /******/ var module = installedModules[moduleId] = {
  35406. /******/ i: moduleId,
  35407. /******/ l: false,
  35408. /******/ exports: {}
  35409. /******/ };
  35410. /******/
  35411. /******/ // Execute the module function
  35412. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35413. /******/
  35414. /******/ // Flag the module as loaded
  35415. /******/ module.l = true;
  35416. /******/
  35417. /******/ // Return the exports of the module
  35418. /******/ return module.exports;
  35419. /******/ }
  35420. /******/
  35421. /******/
  35422. /******/ // expose the modules object (__webpack_modules__)
  35423. /******/ __webpack_require__.m = modules;
  35424. /******/
  35425. /******/ // expose the module cache
  35426. /******/ __webpack_require__.c = installedModules;
  35427. /******/
  35428. /******/ // define getter function for harmony exports
  35429. /******/ __webpack_require__.d = function(exports, name, getter) {
  35430. /******/ if(!__webpack_require__.o(exports, name)) {
  35431. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35432. /******/ }
  35433. /******/ };
  35434. /******/
  35435. /******/ // define __esModule on exports
  35436. /******/ __webpack_require__.r = function(exports) {
  35437. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35438. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35439. /******/ }
  35440. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35441. /******/ };
  35442. /******/
  35443. /******/ // create a fake namespace object
  35444. /******/ // mode & 1: value is a module id, require it
  35445. /******/ // mode & 2: merge all properties of value into the ns
  35446. /******/ // mode & 4: return value when already ns object
  35447. /******/ // mode & 8|1: behave like require
  35448. /******/ __webpack_require__.t = function(value, mode) {
  35449. /******/ if(mode & 1) value = __webpack_require__(value);
  35450. /******/ if(mode & 8) return value;
  35451. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35452. /******/ var ns = Object.create(null);
  35453. /******/ __webpack_require__.r(ns);
  35454. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35455. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35456. /******/ return ns;
  35457. /******/ };
  35458. /******/
  35459. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35460. /******/ __webpack_require__.n = function(module) {
  35461. /******/ var getter = module && module.__esModule ?
  35462. /******/ function getDefault() { return module['default']; } :
  35463. /******/ function getModuleExports() { return module; };
  35464. /******/ __webpack_require__.d(getter, 'a', getter);
  35465. /******/ return getter;
  35466. /******/ };
  35467. /******/
  35468. /******/ // Object.prototype.hasOwnProperty.call
  35469. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35470. /******/
  35471. /******/ // __webpack_public_path__
  35472. /******/ __webpack_require__.p = "";
  35473. /******/
  35474. /******/
  35475. /******/ // Load entry module and return exports
  35476. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35477. /******/ })
  35478. /************************************************************************/
  35479. /******/ ([
  35480. /* 0 */
  35481. /***/ (function(module, exports, __webpack_require__) {
  35482. (function(nacl) {
  35483. 'use strict';
  35484. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35485. // Public domain.
  35486. //
  35487. // Implementation derived from TweetNaCl version 20140427.
  35488. // See for details: http://tweetnacl.cr.yp.to/
  35489. var gf = function(init) {
  35490. var i, r = new Float64Array(16);
  35491. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35492. return r;
  35493. };
  35494. // Pluggable, initialized in high-level API below.
  35495. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35496. var _0 = new Uint8Array(16);
  35497. var _9 = new Uint8Array(32); _9[0] = 9;
  35498. var gf0 = gf(),
  35499. gf1 = gf([1]),
  35500. _121665 = gf([0xdb41, 1]),
  35501. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35502. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35503. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35504. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35505. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35506. function ts64(x, i, h, l) {
  35507. x[i] = (h >> 24) & 0xff;
  35508. x[i+1] = (h >> 16) & 0xff;
  35509. x[i+2] = (h >> 8) & 0xff;
  35510. x[i+3] = h & 0xff;
  35511. x[i+4] = (l >> 24) & 0xff;
  35512. x[i+5] = (l >> 16) & 0xff;
  35513. x[i+6] = (l >> 8) & 0xff;
  35514. x[i+7] = l & 0xff;
  35515. }
  35516. function vn(x, xi, y, yi, n) {
  35517. var i,d = 0;
  35518. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35519. return (1 & ((d - 1) >>> 8)) - 1;
  35520. }
  35521. function crypto_verify_16(x, xi, y, yi) {
  35522. return vn(x,xi,y,yi,16);
  35523. }
  35524. function crypto_verify_32(x, xi, y, yi) {
  35525. return vn(x,xi,y,yi,32);
  35526. }
  35527. function core_salsa20(o, p, k, c) {
  35528. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35529. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35530. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35531. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35532. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35533. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35534. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35535. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35536. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35537. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35538. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35539. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35540. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35541. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35542. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35543. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35544. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35545. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35546. x15 = j15, u;
  35547. for (var i = 0; i < 20; i += 2) {
  35548. u = x0 + x12 | 0;
  35549. x4 ^= u<<7 | u>>>(32-7);
  35550. u = x4 + x0 | 0;
  35551. x8 ^= u<<9 | u>>>(32-9);
  35552. u = x8 + x4 | 0;
  35553. x12 ^= u<<13 | u>>>(32-13);
  35554. u = x12 + x8 | 0;
  35555. x0 ^= u<<18 | u>>>(32-18);
  35556. u = x5 + x1 | 0;
  35557. x9 ^= u<<7 | u>>>(32-7);
  35558. u = x9 + x5 | 0;
  35559. x13 ^= u<<9 | u>>>(32-9);
  35560. u = x13 + x9 | 0;
  35561. x1 ^= u<<13 | u>>>(32-13);
  35562. u = x1 + x13 | 0;
  35563. x5 ^= u<<18 | u>>>(32-18);
  35564. u = x10 + x6 | 0;
  35565. x14 ^= u<<7 | u>>>(32-7);
  35566. u = x14 + x10 | 0;
  35567. x2 ^= u<<9 | u>>>(32-9);
  35568. u = x2 + x14 | 0;
  35569. x6 ^= u<<13 | u>>>(32-13);
  35570. u = x6 + x2 | 0;
  35571. x10 ^= u<<18 | u>>>(32-18);
  35572. u = x15 + x11 | 0;
  35573. x3 ^= u<<7 | u>>>(32-7);
  35574. u = x3 + x15 | 0;
  35575. x7 ^= u<<9 | u>>>(32-9);
  35576. u = x7 + x3 | 0;
  35577. x11 ^= u<<13 | u>>>(32-13);
  35578. u = x11 + x7 | 0;
  35579. x15 ^= u<<18 | u>>>(32-18);
  35580. u = x0 + x3 | 0;
  35581. x1 ^= u<<7 | u>>>(32-7);
  35582. u = x1 + x0 | 0;
  35583. x2 ^= u<<9 | u>>>(32-9);
  35584. u = x2 + x1 | 0;
  35585. x3 ^= u<<13 | u>>>(32-13);
  35586. u = x3 + x2 | 0;
  35587. x0 ^= u<<18 | u>>>(32-18);
  35588. u = x5 + x4 | 0;
  35589. x6 ^= u<<7 | u>>>(32-7);
  35590. u = x6 + x5 | 0;
  35591. x7 ^= u<<9 | u>>>(32-9);
  35592. u = x7 + x6 | 0;
  35593. x4 ^= u<<13 | u>>>(32-13);
  35594. u = x4 + x7 | 0;
  35595. x5 ^= u<<18 | u>>>(32-18);
  35596. u = x10 + x9 | 0;
  35597. x11 ^= u<<7 | u>>>(32-7);
  35598. u = x11 + x10 | 0;
  35599. x8 ^= u<<9 | u>>>(32-9);
  35600. u = x8 + x11 | 0;
  35601. x9 ^= u<<13 | u>>>(32-13);
  35602. u = x9 + x8 | 0;
  35603. x10 ^= u<<18 | u>>>(32-18);
  35604. u = x15 + x14 | 0;
  35605. x12 ^= u<<7 | u>>>(32-7);
  35606. u = x12 + x15 | 0;
  35607. x13 ^= u<<9 | u>>>(32-9);
  35608. u = x13 + x12 | 0;
  35609. x14 ^= u<<13 | u>>>(32-13);
  35610. u = x14 + x13 | 0;
  35611. x15 ^= u<<18 | u>>>(32-18);
  35612. }
  35613. x0 = x0 + j0 | 0;
  35614. x1 = x1 + j1 | 0;
  35615. x2 = x2 + j2 | 0;
  35616. x3 = x3 + j3 | 0;
  35617. x4 = x4 + j4 | 0;
  35618. x5 = x5 + j5 | 0;
  35619. x6 = x6 + j6 | 0;
  35620. x7 = x7 + j7 | 0;
  35621. x8 = x8 + j8 | 0;
  35622. x9 = x9 + j9 | 0;
  35623. x10 = x10 + j10 | 0;
  35624. x11 = x11 + j11 | 0;
  35625. x12 = x12 + j12 | 0;
  35626. x13 = x13 + j13 | 0;
  35627. x14 = x14 + j14 | 0;
  35628. x15 = x15 + j15 | 0;
  35629. o[ 0] = x0 >>> 0 & 0xff;
  35630. o[ 1] = x0 >>> 8 & 0xff;
  35631. o[ 2] = x0 >>> 16 & 0xff;
  35632. o[ 3] = x0 >>> 24 & 0xff;
  35633. o[ 4] = x1 >>> 0 & 0xff;
  35634. o[ 5] = x1 >>> 8 & 0xff;
  35635. o[ 6] = x1 >>> 16 & 0xff;
  35636. o[ 7] = x1 >>> 24 & 0xff;
  35637. o[ 8] = x2 >>> 0 & 0xff;
  35638. o[ 9] = x2 >>> 8 & 0xff;
  35639. o[10] = x2 >>> 16 & 0xff;
  35640. o[11] = x2 >>> 24 & 0xff;
  35641. o[12] = x3 >>> 0 & 0xff;
  35642. o[13] = x3 >>> 8 & 0xff;
  35643. o[14] = x3 >>> 16 & 0xff;
  35644. o[15] = x3 >>> 24 & 0xff;
  35645. o[16] = x4 >>> 0 & 0xff;
  35646. o[17] = x4 >>> 8 & 0xff;
  35647. o[18] = x4 >>> 16 & 0xff;
  35648. o[19] = x4 >>> 24 & 0xff;
  35649. o[20] = x5 >>> 0 & 0xff;
  35650. o[21] = x5 >>> 8 & 0xff;
  35651. o[22] = x5 >>> 16 & 0xff;
  35652. o[23] = x5 >>> 24 & 0xff;
  35653. o[24] = x6 >>> 0 & 0xff;
  35654. o[25] = x6 >>> 8 & 0xff;
  35655. o[26] = x6 >>> 16 & 0xff;
  35656. o[27] = x6 >>> 24 & 0xff;
  35657. o[28] = x7 >>> 0 & 0xff;
  35658. o[29] = x7 >>> 8 & 0xff;
  35659. o[30] = x7 >>> 16 & 0xff;
  35660. o[31] = x7 >>> 24 & 0xff;
  35661. o[32] = x8 >>> 0 & 0xff;
  35662. o[33] = x8 >>> 8 & 0xff;
  35663. o[34] = x8 >>> 16 & 0xff;
  35664. o[35] = x8 >>> 24 & 0xff;
  35665. o[36] = x9 >>> 0 & 0xff;
  35666. o[37] = x9 >>> 8 & 0xff;
  35667. o[38] = x9 >>> 16 & 0xff;
  35668. o[39] = x9 >>> 24 & 0xff;
  35669. o[40] = x10 >>> 0 & 0xff;
  35670. o[41] = x10 >>> 8 & 0xff;
  35671. o[42] = x10 >>> 16 & 0xff;
  35672. o[43] = x10 >>> 24 & 0xff;
  35673. o[44] = x11 >>> 0 & 0xff;
  35674. o[45] = x11 >>> 8 & 0xff;
  35675. o[46] = x11 >>> 16 & 0xff;
  35676. o[47] = x11 >>> 24 & 0xff;
  35677. o[48] = x12 >>> 0 & 0xff;
  35678. o[49] = x12 >>> 8 & 0xff;
  35679. o[50] = x12 >>> 16 & 0xff;
  35680. o[51] = x12 >>> 24 & 0xff;
  35681. o[52] = x13 >>> 0 & 0xff;
  35682. o[53] = x13 >>> 8 & 0xff;
  35683. o[54] = x13 >>> 16 & 0xff;
  35684. o[55] = x13 >>> 24 & 0xff;
  35685. o[56] = x14 >>> 0 & 0xff;
  35686. o[57] = x14 >>> 8 & 0xff;
  35687. o[58] = x14 >>> 16 & 0xff;
  35688. o[59] = x14 >>> 24 & 0xff;
  35689. o[60] = x15 >>> 0 & 0xff;
  35690. o[61] = x15 >>> 8 & 0xff;
  35691. o[62] = x15 >>> 16 & 0xff;
  35692. o[63] = x15 >>> 24 & 0xff;
  35693. }
  35694. function core_hsalsa20(o,p,k,c) {
  35695. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35696. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35697. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35698. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35699. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35700. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35701. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35702. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35703. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35704. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35705. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35706. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35707. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35708. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35709. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35710. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35711. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35712. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35713. x15 = j15, u;
  35714. for (var i = 0; i < 20; i += 2) {
  35715. u = x0 + x12 | 0;
  35716. x4 ^= u<<7 | u>>>(32-7);
  35717. u = x4 + x0 | 0;
  35718. x8 ^= u<<9 | u>>>(32-9);
  35719. u = x8 + x4 | 0;
  35720. x12 ^= u<<13 | u>>>(32-13);
  35721. u = x12 + x8 | 0;
  35722. x0 ^= u<<18 | u>>>(32-18);
  35723. u = x5 + x1 | 0;
  35724. x9 ^= u<<7 | u>>>(32-7);
  35725. u = x9 + x5 | 0;
  35726. x13 ^= u<<9 | u>>>(32-9);
  35727. u = x13 + x9 | 0;
  35728. x1 ^= u<<13 | u>>>(32-13);
  35729. u = x1 + x13 | 0;
  35730. x5 ^= u<<18 | u>>>(32-18);
  35731. u = x10 + x6 | 0;
  35732. x14 ^= u<<7 | u>>>(32-7);
  35733. u = x14 + x10 | 0;
  35734. x2 ^= u<<9 | u>>>(32-9);
  35735. u = x2 + x14 | 0;
  35736. x6 ^= u<<13 | u>>>(32-13);
  35737. u = x6 + x2 | 0;
  35738. x10 ^= u<<18 | u>>>(32-18);
  35739. u = x15 + x11 | 0;
  35740. x3 ^= u<<7 | u>>>(32-7);
  35741. u = x3 + x15 | 0;
  35742. x7 ^= u<<9 | u>>>(32-9);
  35743. u = x7 + x3 | 0;
  35744. x11 ^= u<<13 | u>>>(32-13);
  35745. u = x11 + x7 | 0;
  35746. x15 ^= u<<18 | u>>>(32-18);
  35747. u = x0 + x3 | 0;
  35748. x1 ^= u<<7 | u>>>(32-7);
  35749. u = x1 + x0 | 0;
  35750. x2 ^= u<<9 | u>>>(32-9);
  35751. u = x2 + x1 | 0;
  35752. x3 ^= u<<13 | u>>>(32-13);
  35753. u = x3 + x2 | 0;
  35754. x0 ^= u<<18 | u>>>(32-18);
  35755. u = x5 + x4 | 0;
  35756. x6 ^= u<<7 | u>>>(32-7);
  35757. u = x6 + x5 | 0;
  35758. x7 ^= u<<9 | u>>>(32-9);
  35759. u = x7 + x6 | 0;
  35760. x4 ^= u<<13 | u>>>(32-13);
  35761. u = x4 + x7 | 0;
  35762. x5 ^= u<<18 | u>>>(32-18);
  35763. u = x10 + x9 | 0;
  35764. x11 ^= u<<7 | u>>>(32-7);
  35765. u = x11 + x10 | 0;
  35766. x8 ^= u<<9 | u>>>(32-9);
  35767. u = x8 + x11 | 0;
  35768. x9 ^= u<<13 | u>>>(32-13);
  35769. u = x9 + x8 | 0;
  35770. x10 ^= u<<18 | u>>>(32-18);
  35771. u = x15 + x14 | 0;
  35772. x12 ^= u<<7 | u>>>(32-7);
  35773. u = x12 + x15 | 0;
  35774. x13 ^= u<<9 | u>>>(32-9);
  35775. u = x13 + x12 | 0;
  35776. x14 ^= u<<13 | u>>>(32-13);
  35777. u = x14 + x13 | 0;
  35778. x15 ^= u<<18 | u>>>(32-18);
  35779. }
  35780. o[ 0] = x0 >>> 0 & 0xff;
  35781. o[ 1] = x0 >>> 8 & 0xff;
  35782. o[ 2] = x0 >>> 16 & 0xff;
  35783. o[ 3] = x0 >>> 24 & 0xff;
  35784. o[ 4] = x5 >>> 0 & 0xff;
  35785. o[ 5] = x5 >>> 8 & 0xff;
  35786. o[ 6] = x5 >>> 16 & 0xff;
  35787. o[ 7] = x5 >>> 24 & 0xff;
  35788. o[ 8] = x10 >>> 0 & 0xff;
  35789. o[ 9] = x10 >>> 8 & 0xff;
  35790. o[10] = x10 >>> 16 & 0xff;
  35791. o[11] = x10 >>> 24 & 0xff;
  35792. o[12] = x15 >>> 0 & 0xff;
  35793. o[13] = x15 >>> 8 & 0xff;
  35794. o[14] = x15 >>> 16 & 0xff;
  35795. o[15] = x15 >>> 24 & 0xff;
  35796. o[16] = x6 >>> 0 & 0xff;
  35797. o[17] = x6 >>> 8 & 0xff;
  35798. o[18] = x6 >>> 16 & 0xff;
  35799. o[19] = x6 >>> 24 & 0xff;
  35800. o[20] = x7 >>> 0 & 0xff;
  35801. o[21] = x7 >>> 8 & 0xff;
  35802. o[22] = x7 >>> 16 & 0xff;
  35803. o[23] = x7 >>> 24 & 0xff;
  35804. o[24] = x8 >>> 0 & 0xff;
  35805. o[25] = x8 >>> 8 & 0xff;
  35806. o[26] = x8 >>> 16 & 0xff;
  35807. o[27] = x8 >>> 24 & 0xff;
  35808. o[28] = x9 >>> 0 & 0xff;
  35809. o[29] = x9 >>> 8 & 0xff;
  35810. o[30] = x9 >>> 16 & 0xff;
  35811. o[31] = x9 >>> 24 & 0xff;
  35812. }
  35813. function crypto_core_salsa20(out,inp,k,c) {
  35814. core_salsa20(out,inp,k,c);
  35815. }
  35816. function crypto_core_hsalsa20(out,inp,k,c) {
  35817. core_hsalsa20(out,inp,k,c);
  35818. }
  35819. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35820. // "expand 32-byte k"
  35821. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35822. var z = new Uint8Array(16), x = new Uint8Array(64);
  35823. var u, i;
  35824. for (i = 0; i < 16; i++) z[i] = 0;
  35825. for (i = 0; i < 8; i++) z[i] = n[i];
  35826. while (b >= 64) {
  35827. crypto_core_salsa20(x,z,k,sigma);
  35828. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35829. u = 1;
  35830. for (i = 8; i < 16; i++) {
  35831. u = u + (z[i] & 0xff) | 0;
  35832. z[i] = u & 0xff;
  35833. u >>>= 8;
  35834. }
  35835. b -= 64;
  35836. cpos += 64;
  35837. mpos += 64;
  35838. }
  35839. if (b > 0) {
  35840. crypto_core_salsa20(x,z,k,sigma);
  35841. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35842. }
  35843. return 0;
  35844. }
  35845. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35846. var z = new Uint8Array(16), x = new Uint8Array(64);
  35847. var u, i;
  35848. for (i = 0; i < 16; i++) z[i] = 0;
  35849. for (i = 0; i < 8; i++) z[i] = n[i];
  35850. while (b >= 64) {
  35851. crypto_core_salsa20(x,z,k,sigma);
  35852. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35853. u = 1;
  35854. for (i = 8; i < 16; i++) {
  35855. u = u + (z[i] & 0xff) | 0;
  35856. z[i] = u & 0xff;
  35857. u >>>= 8;
  35858. }
  35859. b -= 64;
  35860. cpos += 64;
  35861. }
  35862. if (b > 0) {
  35863. crypto_core_salsa20(x,z,k,sigma);
  35864. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35865. }
  35866. return 0;
  35867. }
  35868. function crypto_stream(c,cpos,d,n,k) {
  35869. var s = new Uint8Array(32);
  35870. crypto_core_hsalsa20(s,n,k,sigma);
  35871. var sn = new Uint8Array(8);
  35872. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35873. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35874. }
  35875. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35876. var s = new Uint8Array(32);
  35877. crypto_core_hsalsa20(s,n,k,sigma);
  35878. var sn = new Uint8Array(8);
  35879. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35880. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35881. }
  35882. /*
  35883. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35884. * https://github.com/floodyberry/poly1305-donna
  35885. */
  35886. var poly1305 = function(key) {
  35887. this.buffer = new Uint8Array(16);
  35888. this.r = new Uint16Array(10);
  35889. this.h = new Uint16Array(10);
  35890. this.pad = new Uint16Array(8);
  35891. this.leftover = 0;
  35892. this.fin = 0;
  35893. var t0, t1, t2, t3, t4, t5, t6, t7;
  35894. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35895. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35896. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35897. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35898. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35899. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35900. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35901. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35902. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35903. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35904. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35905. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35906. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35907. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35908. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35909. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35910. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35911. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35912. };
  35913. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35914. var hibit = this.fin ? 0 : (1 << 11);
  35915. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35916. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35917. var h0 = this.h[0],
  35918. h1 = this.h[1],
  35919. h2 = this.h[2],
  35920. h3 = this.h[3],
  35921. h4 = this.h[4],
  35922. h5 = this.h[5],
  35923. h6 = this.h[6],
  35924. h7 = this.h[7],
  35925. h8 = this.h[8],
  35926. h9 = this.h[9];
  35927. var r0 = this.r[0],
  35928. r1 = this.r[1],
  35929. r2 = this.r[2],
  35930. r3 = this.r[3],
  35931. r4 = this.r[4],
  35932. r5 = this.r[5],
  35933. r6 = this.r[6],
  35934. r7 = this.r[7],
  35935. r8 = this.r[8],
  35936. r9 = this.r[9];
  35937. while (bytes >= 16) {
  35938. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35939. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35940. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35941. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35942. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35943. h5 += ((t4 >>> 1)) & 0x1fff;
  35944. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35945. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35946. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35947. h9 += ((t7 >>> 5)) | hibit;
  35948. c = 0;
  35949. d0 = c;
  35950. d0 += h0 * r0;
  35951. d0 += h1 * (5 * r9);
  35952. d0 += h2 * (5 * r8);
  35953. d0 += h3 * (5 * r7);
  35954. d0 += h4 * (5 * r6);
  35955. c = (d0 >>> 13); d0 &= 0x1fff;
  35956. d0 += h5 * (5 * r5);
  35957. d0 += h6 * (5 * r4);
  35958. d0 += h7 * (5 * r3);
  35959. d0 += h8 * (5 * r2);
  35960. d0 += h9 * (5 * r1);
  35961. c += (d0 >>> 13); d0 &= 0x1fff;
  35962. d1 = c;
  35963. d1 += h0 * r1;
  35964. d1 += h1 * r0;
  35965. d1 += h2 * (5 * r9);
  35966. d1 += h3 * (5 * r8);
  35967. d1 += h4 * (5 * r7);
  35968. c = (d1 >>> 13); d1 &= 0x1fff;
  35969. d1 += h5 * (5 * r6);
  35970. d1 += h6 * (5 * r5);
  35971. d1 += h7 * (5 * r4);
  35972. d1 += h8 * (5 * r3);
  35973. d1 += h9 * (5 * r2);
  35974. c += (d1 >>> 13); d1 &= 0x1fff;
  35975. d2 = c;
  35976. d2 += h0 * r2;
  35977. d2 += h1 * r1;
  35978. d2 += h2 * r0;
  35979. d2 += h3 * (5 * r9);
  35980. d2 += h4 * (5 * r8);
  35981. c = (d2 >>> 13); d2 &= 0x1fff;
  35982. d2 += h5 * (5 * r7);
  35983. d2 += h6 * (5 * r6);
  35984. d2 += h7 * (5 * r5);
  35985. d2 += h8 * (5 * r4);
  35986. d2 += h9 * (5 * r3);
  35987. c += (d2 >>> 13); d2 &= 0x1fff;
  35988. d3 = c;
  35989. d3 += h0 * r3;
  35990. d3 += h1 * r2;
  35991. d3 += h2 * r1;
  35992. d3 += h3 * r0;
  35993. d3 += h4 * (5 * r9);
  35994. c = (d3 >>> 13); d3 &= 0x1fff;
  35995. d3 += h5 * (5 * r8);
  35996. d3 += h6 * (5 * r7);
  35997. d3 += h7 * (5 * r6);
  35998. d3 += h8 * (5 * r5);
  35999. d3 += h9 * (5 * r4);
  36000. c += (d3 >>> 13); d3 &= 0x1fff;
  36001. d4 = c;
  36002. d4 += h0 * r4;
  36003. d4 += h1 * r3;
  36004. d4 += h2 * r2;
  36005. d4 += h3 * r1;
  36006. d4 += h4 * r0;
  36007. c = (d4 >>> 13); d4 &= 0x1fff;
  36008. d4 += h5 * (5 * r9);
  36009. d4 += h6 * (5 * r8);
  36010. d4 += h7 * (5 * r7);
  36011. d4 += h8 * (5 * r6);
  36012. d4 += h9 * (5 * r5);
  36013. c += (d4 >>> 13); d4 &= 0x1fff;
  36014. d5 = c;
  36015. d5 += h0 * r5;
  36016. d5 += h1 * r4;
  36017. d5 += h2 * r3;
  36018. d5 += h3 * r2;
  36019. d5 += h4 * r1;
  36020. c = (d5 >>> 13); d5 &= 0x1fff;
  36021. d5 += h5 * r0;
  36022. d5 += h6 * (5 * r9);
  36023. d5 += h7 * (5 * r8);
  36024. d5 += h8 * (5 * r7);
  36025. d5 += h9 * (5 * r6);
  36026. c += (d5 >>> 13); d5 &= 0x1fff;
  36027. d6 = c;
  36028. d6 += h0 * r6;
  36029. d6 += h1 * r5;
  36030. d6 += h2 * r4;
  36031. d6 += h3 * r3;
  36032. d6 += h4 * r2;
  36033. c = (d6 >>> 13); d6 &= 0x1fff;
  36034. d6 += h5 * r1;
  36035. d6 += h6 * r0;
  36036. d6 += h7 * (5 * r9);
  36037. d6 += h8 * (5 * r8);
  36038. d6 += h9 * (5 * r7);
  36039. c += (d6 >>> 13); d6 &= 0x1fff;
  36040. d7 = c;
  36041. d7 += h0 * r7;
  36042. d7 += h1 * r6;
  36043. d7 += h2 * r5;
  36044. d7 += h3 * r4;
  36045. d7 += h4 * r3;
  36046. c = (d7 >>> 13); d7 &= 0x1fff;
  36047. d7 += h5 * r2;
  36048. d7 += h6 * r1;
  36049. d7 += h7 * r0;
  36050. d7 += h8 * (5 * r9);
  36051. d7 += h9 * (5 * r8);
  36052. c += (d7 >>> 13); d7 &= 0x1fff;
  36053. d8 = c;
  36054. d8 += h0 * r8;
  36055. d8 += h1 * r7;
  36056. d8 += h2 * r6;
  36057. d8 += h3 * r5;
  36058. d8 += h4 * r4;
  36059. c = (d8 >>> 13); d8 &= 0x1fff;
  36060. d8 += h5 * r3;
  36061. d8 += h6 * r2;
  36062. d8 += h7 * r1;
  36063. d8 += h8 * r0;
  36064. d8 += h9 * (5 * r9);
  36065. c += (d8 >>> 13); d8 &= 0x1fff;
  36066. d9 = c;
  36067. d9 += h0 * r9;
  36068. d9 += h1 * r8;
  36069. d9 += h2 * r7;
  36070. d9 += h3 * r6;
  36071. d9 += h4 * r5;
  36072. c = (d9 >>> 13); d9 &= 0x1fff;
  36073. d9 += h5 * r4;
  36074. d9 += h6 * r3;
  36075. d9 += h7 * r2;
  36076. d9 += h8 * r1;
  36077. d9 += h9 * r0;
  36078. c += (d9 >>> 13); d9 &= 0x1fff;
  36079. c = (((c << 2) + c)) | 0;
  36080. c = (c + d0) | 0;
  36081. d0 = c & 0x1fff;
  36082. c = (c >>> 13);
  36083. d1 += c;
  36084. h0 = d0;
  36085. h1 = d1;
  36086. h2 = d2;
  36087. h3 = d3;
  36088. h4 = d4;
  36089. h5 = d5;
  36090. h6 = d6;
  36091. h7 = d7;
  36092. h8 = d8;
  36093. h9 = d9;
  36094. mpos += 16;
  36095. bytes -= 16;
  36096. }
  36097. this.h[0] = h0;
  36098. this.h[1] = h1;
  36099. this.h[2] = h2;
  36100. this.h[3] = h3;
  36101. this.h[4] = h4;
  36102. this.h[5] = h5;
  36103. this.h[6] = h6;
  36104. this.h[7] = h7;
  36105. this.h[8] = h8;
  36106. this.h[9] = h9;
  36107. };
  36108. poly1305.prototype.finish = function(mac, macpos) {
  36109. var g = new Uint16Array(10);
  36110. var c, mask, f, i;
  36111. if (this.leftover) {
  36112. i = this.leftover;
  36113. this.buffer[i++] = 1;
  36114. for (; i < 16; i++) this.buffer[i] = 0;
  36115. this.fin = 1;
  36116. this.blocks(this.buffer, 0, 16);
  36117. }
  36118. c = this.h[1] >>> 13;
  36119. this.h[1] &= 0x1fff;
  36120. for (i = 2; i < 10; i++) {
  36121. this.h[i] += c;
  36122. c = this.h[i] >>> 13;
  36123. this.h[i] &= 0x1fff;
  36124. }
  36125. this.h[0] += (c * 5);
  36126. c = this.h[0] >>> 13;
  36127. this.h[0] &= 0x1fff;
  36128. this.h[1] += c;
  36129. c = this.h[1] >>> 13;
  36130. this.h[1] &= 0x1fff;
  36131. this.h[2] += c;
  36132. g[0] = this.h[0] + 5;
  36133. c = g[0] >>> 13;
  36134. g[0] &= 0x1fff;
  36135. for (i = 1; i < 10; i++) {
  36136. g[i] = this.h[i] + c;
  36137. c = g[i] >>> 13;
  36138. g[i] &= 0x1fff;
  36139. }
  36140. g[9] -= (1 << 13);
  36141. mask = (c ^ 1) - 1;
  36142. for (i = 0; i < 10; i++) g[i] &= mask;
  36143. mask = ~mask;
  36144. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36145. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36146. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36147. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36148. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36149. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36150. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36151. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36152. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36153. f = this.h[0] + this.pad[0];
  36154. this.h[0] = f & 0xffff;
  36155. for (i = 1; i < 8; i++) {
  36156. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36157. this.h[i] = f & 0xffff;
  36158. }
  36159. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36160. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36161. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36162. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36163. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36164. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36165. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36166. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36167. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36168. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36169. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36170. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36171. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36172. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36173. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36174. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36175. };
  36176. poly1305.prototype.update = function(m, mpos, bytes) {
  36177. var i, want;
  36178. if (this.leftover) {
  36179. want = (16 - this.leftover);
  36180. if (want > bytes)
  36181. want = bytes;
  36182. for (i = 0; i < want; i++)
  36183. this.buffer[this.leftover + i] = m[mpos+i];
  36184. bytes -= want;
  36185. mpos += want;
  36186. this.leftover += want;
  36187. if (this.leftover < 16)
  36188. return;
  36189. this.blocks(this.buffer, 0, 16);
  36190. this.leftover = 0;
  36191. }
  36192. if (bytes >= 16) {
  36193. want = bytes - (bytes % 16);
  36194. this.blocks(m, mpos, want);
  36195. mpos += want;
  36196. bytes -= want;
  36197. }
  36198. if (bytes) {
  36199. for (i = 0; i < bytes; i++)
  36200. this.buffer[this.leftover + i] = m[mpos+i];
  36201. this.leftover += bytes;
  36202. }
  36203. };
  36204. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36205. var s = new poly1305(k);
  36206. s.update(m, mpos, n);
  36207. s.finish(out, outpos);
  36208. return 0;
  36209. }
  36210. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36211. var x = new Uint8Array(16);
  36212. crypto_onetimeauth(x,0,m,mpos,n,k);
  36213. return crypto_verify_16(h,hpos,x,0);
  36214. }
  36215. function crypto_secretbox(c,m,d,n,k) {
  36216. var i;
  36217. if (d < 32) return -1;
  36218. crypto_stream_xor(c,0,m,0,d,n,k);
  36219. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36220. for (i = 0; i < 16; i++) c[i] = 0;
  36221. return 0;
  36222. }
  36223. function crypto_secretbox_open(m,c,d,n,k) {
  36224. var i;
  36225. var x = new Uint8Array(32);
  36226. if (d < 32) return -1;
  36227. crypto_stream(x,0,32,n,k);
  36228. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36229. crypto_stream_xor(m,0,c,0,d,n,k);
  36230. for (i = 0; i < 32; i++) m[i] = 0;
  36231. return 0;
  36232. }
  36233. function set25519(r, a) {
  36234. var i;
  36235. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36236. }
  36237. function car25519(o) {
  36238. var i, v, c = 1;
  36239. for (i = 0; i < 16; i++) {
  36240. v = o[i] + c + 65535;
  36241. c = Math.floor(v / 65536);
  36242. o[i] = v - c * 65536;
  36243. }
  36244. o[0] += c-1 + 37 * (c-1);
  36245. }
  36246. function sel25519(p, q, b) {
  36247. var t, c = ~(b-1);
  36248. for (var i = 0; i < 16; i++) {
  36249. t = c & (p[i] ^ q[i]);
  36250. p[i] ^= t;
  36251. q[i] ^= t;
  36252. }
  36253. }
  36254. function pack25519(o, n) {
  36255. var i, j, b;
  36256. var m = gf(), t = gf();
  36257. for (i = 0; i < 16; i++) t[i] = n[i];
  36258. car25519(t);
  36259. car25519(t);
  36260. car25519(t);
  36261. for (j = 0; j < 2; j++) {
  36262. m[0] = t[0] - 0xffed;
  36263. for (i = 1; i < 15; i++) {
  36264. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36265. m[i-1] &= 0xffff;
  36266. }
  36267. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36268. b = (m[15]>>16) & 1;
  36269. m[14] &= 0xffff;
  36270. sel25519(t, m, 1-b);
  36271. }
  36272. for (i = 0; i < 16; i++) {
  36273. o[2*i] = t[i] & 0xff;
  36274. o[2*i+1] = t[i]>>8;
  36275. }
  36276. }
  36277. function neq25519(a, b) {
  36278. var c = new Uint8Array(32), d = new Uint8Array(32);
  36279. pack25519(c, a);
  36280. pack25519(d, b);
  36281. return crypto_verify_32(c, 0, d, 0);
  36282. }
  36283. function par25519(a) {
  36284. var d = new Uint8Array(32);
  36285. pack25519(d, a);
  36286. return d[0] & 1;
  36287. }
  36288. function unpack25519(o, n) {
  36289. var i;
  36290. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36291. o[15] &= 0x7fff;
  36292. }
  36293. function A(o, a, b) {
  36294. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36295. }
  36296. function Z(o, a, b) {
  36297. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36298. }
  36299. function M(o, a, b) {
  36300. var v, c,
  36301. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36302. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36303. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36304. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36305. b0 = b[0],
  36306. b1 = b[1],
  36307. b2 = b[2],
  36308. b3 = b[3],
  36309. b4 = b[4],
  36310. b5 = b[5],
  36311. b6 = b[6],
  36312. b7 = b[7],
  36313. b8 = b[8],
  36314. b9 = b[9],
  36315. b10 = b[10],
  36316. b11 = b[11],
  36317. b12 = b[12],
  36318. b13 = b[13],
  36319. b14 = b[14],
  36320. b15 = b[15];
  36321. v = a[0];
  36322. t0 += v * b0;
  36323. t1 += v * b1;
  36324. t2 += v * b2;
  36325. t3 += v * b3;
  36326. t4 += v * b4;
  36327. t5 += v * b5;
  36328. t6 += v * b6;
  36329. t7 += v * b7;
  36330. t8 += v * b8;
  36331. t9 += v * b9;
  36332. t10 += v * b10;
  36333. t11 += v * b11;
  36334. t12 += v * b12;
  36335. t13 += v * b13;
  36336. t14 += v * b14;
  36337. t15 += v * b15;
  36338. v = a[1];
  36339. t1 += v * b0;
  36340. t2 += v * b1;
  36341. t3 += v * b2;
  36342. t4 += v * b3;
  36343. t5 += v * b4;
  36344. t6 += v * b5;
  36345. t7 += v * b6;
  36346. t8 += v * b7;
  36347. t9 += v * b8;
  36348. t10 += v * b9;
  36349. t11 += v * b10;
  36350. t12 += v * b11;
  36351. t13 += v * b12;
  36352. t14 += v * b13;
  36353. t15 += v * b14;
  36354. t16 += v * b15;
  36355. v = a[2];
  36356. t2 += v * b0;
  36357. t3 += v * b1;
  36358. t4 += v * b2;
  36359. t5 += v * b3;
  36360. t6 += v * b4;
  36361. t7 += v * b5;
  36362. t8 += v * b6;
  36363. t9 += v * b7;
  36364. t10 += v * b8;
  36365. t11 += v * b9;
  36366. t12 += v * b10;
  36367. t13 += v * b11;
  36368. t14 += v * b12;
  36369. t15 += v * b13;
  36370. t16 += v * b14;
  36371. t17 += v * b15;
  36372. v = a[3];
  36373. t3 += v * b0;
  36374. t4 += v * b1;
  36375. t5 += v * b2;
  36376. t6 += v * b3;
  36377. t7 += v * b4;
  36378. t8 += v * b5;
  36379. t9 += v * b6;
  36380. t10 += v * b7;
  36381. t11 += v * b8;
  36382. t12 += v * b9;
  36383. t13 += v * b10;
  36384. t14 += v * b11;
  36385. t15 += v * b12;
  36386. t16 += v * b13;
  36387. t17 += v * b14;
  36388. t18 += v * b15;
  36389. v = a[4];
  36390. t4 += v * b0;
  36391. t5 += v * b1;
  36392. t6 += v * b2;
  36393. t7 += v * b3;
  36394. t8 += v * b4;
  36395. t9 += v * b5;
  36396. t10 += v * b6;
  36397. t11 += v * b7;
  36398. t12 += v * b8;
  36399. t13 += v * b9;
  36400. t14 += v * b10;
  36401. t15 += v * b11;
  36402. t16 += v * b12;
  36403. t17 += v * b13;
  36404. t18 += v * b14;
  36405. t19 += v * b15;
  36406. v = a[5];
  36407. t5 += v * b0;
  36408. t6 += v * b1;
  36409. t7 += v * b2;
  36410. t8 += v * b3;
  36411. t9 += v * b4;
  36412. t10 += v * b5;
  36413. t11 += v * b6;
  36414. t12 += v * b7;
  36415. t13 += v * b8;
  36416. t14 += v * b9;
  36417. t15 += v * b10;
  36418. t16 += v * b11;
  36419. t17 += v * b12;
  36420. t18 += v * b13;
  36421. t19 += v * b14;
  36422. t20 += v * b15;
  36423. v = a[6];
  36424. t6 += v * b0;
  36425. t7 += v * b1;
  36426. t8 += v * b2;
  36427. t9 += v * b3;
  36428. t10 += v * b4;
  36429. t11 += v * b5;
  36430. t12 += v * b6;
  36431. t13 += v * b7;
  36432. t14 += v * b8;
  36433. t15 += v * b9;
  36434. t16 += v * b10;
  36435. t17 += v * b11;
  36436. t18 += v * b12;
  36437. t19 += v * b13;
  36438. t20 += v * b14;
  36439. t21 += v * b15;
  36440. v = a[7];
  36441. t7 += v * b0;
  36442. t8 += v * b1;
  36443. t9 += v * b2;
  36444. t10 += v * b3;
  36445. t11 += v * b4;
  36446. t12 += v * b5;
  36447. t13 += v * b6;
  36448. t14 += v * b7;
  36449. t15 += v * b8;
  36450. t16 += v * b9;
  36451. t17 += v * b10;
  36452. t18 += v * b11;
  36453. t19 += v * b12;
  36454. t20 += v * b13;
  36455. t21 += v * b14;
  36456. t22 += v * b15;
  36457. v = a[8];
  36458. t8 += v * b0;
  36459. t9 += v * b1;
  36460. t10 += v * b2;
  36461. t11 += v * b3;
  36462. t12 += v * b4;
  36463. t13 += v * b5;
  36464. t14 += v * b6;
  36465. t15 += v * b7;
  36466. t16 += v * b8;
  36467. t17 += v * b9;
  36468. t18 += v * b10;
  36469. t19 += v * b11;
  36470. t20 += v * b12;
  36471. t21 += v * b13;
  36472. t22 += v * b14;
  36473. t23 += v * b15;
  36474. v = a[9];
  36475. t9 += v * b0;
  36476. t10 += v * b1;
  36477. t11 += v * b2;
  36478. t12 += v * b3;
  36479. t13 += v * b4;
  36480. t14 += v * b5;
  36481. t15 += v * b6;
  36482. t16 += v * b7;
  36483. t17 += v * b8;
  36484. t18 += v * b9;
  36485. t19 += v * b10;
  36486. t20 += v * b11;
  36487. t21 += v * b12;
  36488. t22 += v * b13;
  36489. t23 += v * b14;
  36490. t24 += v * b15;
  36491. v = a[10];
  36492. t10 += v * b0;
  36493. t11 += v * b1;
  36494. t12 += v * b2;
  36495. t13 += v * b3;
  36496. t14 += v * b4;
  36497. t15 += v * b5;
  36498. t16 += v * b6;
  36499. t17 += v * b7;
  36500. t18 += v * b8;
  36501. t19 += v * b9;
  36502. t20 += v * b10;
  36503. t21 += v * b11;
  36504. t22 += v * b12;
  36505. t23 += v * b13;
  36506. t24 += v * b14;
  36507. t25 += v * b15;
  36508. v = a[11];
  36509. t11 += v * b0;
  36510. t12 += v * b1;
  36511. t13 += v * b2;
  36512. t14 += v * b3;
  36513. t15 += v * b4;
  36514. t16 += v * b5;
  36515. t17 += v * b6;
  36516. t18 += v * b7;
  36517. t19 += v * b8;
  36518. t20 += v * b9;
  36519. t21 += v * b10;
  36520. t22 += v * b11;
  36521. t23 += v * b12;
  36522. t24 += v * b13;
  36523. t25 += v * b14;
  36524. t26 += v * b15;
  36525. v = a[12];
  36526. t12 += v * b0;
  36527. t13 += v * b1;
  36528. t14 += v * b2;
  36529. t15 += v * b3;
  36530. t16 += v * b4;
  36531. t17 += v * b5;
  36532. t18 += v * b6;
  36533. t19 += v * b7;
  36534. t20 += v * b8;
  36535. t21 += v * b9;
  36536. t22 += v * b10;
  36537. t23 += v * b11;
  36538. t24 += v * b12;
  36539. t25 += v * b13;
  36540. t26 += v * b14;
  36541. t27 += v * b15;
  36542. v = a[13];
  36543. t13 += v * b0;
  36544. t14 += v * b1;
  36545. t15 += v * b2;
  36546. t16 += v * b3;
  36547. t17 += v * b4;
  36548. t18 += v * b5;
  36549. t19 += v * b6;
  36550. t20 += v * b7;
  36551. t21 += v * b8;
  36552. t22 += v * b9;
  36553. t23 += v * b10;
  36554. t24 += v * b11;
  36555. t25 += v * b12;
  36556. t26 += v * b13;
  36557. t27 += v * b14;
  36558. t28 += v * b15;
  36559. v = a[14];
  36560. t14 += v * b0;
  36561. t15 += v * b1;
  36562. t16 += v * b2;
  36563. t17 += v * b3;
  36564. t18 += v * b4;
  36565. t19 += v * b5;
  36566. t20 += v * b6;
  36567. t21 += v * b7;
  36568. t22 += v * b8;
  36569. t23 += v * b9;
  36570. t24 += v * b10;
  36571. t25 += v * b11;
  36572. t26 += v * b12;
  36573. t27 += v * b13;
  36574. t28 += v * b14;
  36575. t29 += v * b15;
  36576. v = a[15];
  36577. t15 += v * b0;
  36578. t16 += v * b1;
  36579. t17 += v * b2;
  36580. t18 += v * b3;
  36581. t19 += v * b4;
  36582. t20 += v * b5;
  36583. t21 += v * b6;
  36584. t22 += v * b7;
  36585. t23 += v * b8;
  36586. t24 += v * b9;
  36587. t25 += v * b10;
  36588. t26 += v * b11;
  36589. t27 += v * b12;
  36590. t28 += v * b13;
  36591. t29 += v * b14;
  36592. t30 += v * b15;
  36593. t0 += 38 * t16;
  36594. t1 += 38 * t17;
  36595. t2 += 38 * t18;
  36596. t3 += 38 * t19;
  36597. t4 += 38 * t20;
  36598. t5 += 38 * t21;
  36599. t6 += 38 * t22;
  36600. t7 += 38 * t23;
  36601. t8 += 38 * t24;
  36602. t9 += 38 * t25;
  36603. t10 += 38 * t26;
  36604. t11 += 38 * t27;
  36605. t12 += 38 * t28;
  36606. t13 += 38 * t29;
  36607. t14 += 38 * t30;
  36608. // t15 left as is
  36609. // first car
  36610. c = 1;
  36611. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36612. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36613. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36614. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36615. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36616. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36617. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36618. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36619. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36620. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36621. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36622. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36623. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36624. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36625. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36626. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36627. t0 += c-1 + 37 * (c-1);
  36628. // second car
  36629. c = 1;
  36630. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36631. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36632. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36633. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36634. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36635. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36636. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36637. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36638. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36639. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36640. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36641. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36642. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36643. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36644. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36645. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36646. t0 += c-1 + 37 * (c-1);
  36647. o[ 0] = t0;
  36648. o[ 1] = t1;
  36649. o[ 2] = t2;
  36650. o[ 3] = t3;
  36651. o[ 4] = t4;
  36652. o[ 5] = t5;
  36653. o[ 6] = t6;
  36654. o[ 7] = t7;
  36655. o[ 8] = t8;
  36656. o[ 9] = t9;
  36657. o[10] = t10;
  36658. o[11] = t11;
  36659. o[12] = t12;
  36660. o[13] = t13;
  36661. o[14] = t14;
  36662. o[15] = t15;
  36663. }
  36664. function S(o, a) {
  36665. M(o, a, a);
  36666. }
  36667. function inv25519(o, i) {
  36668. var c = gf();
  36669. var a;
  36670. for (a = 0; a < 16; a++) c[a] = i[a];
  36671. for (a = 253; a >= 0; a--) {
  36672. S(c, c);
  36673. if(a !== 2 && a !== 4) M(c, c, i);
  36674. }
  36675. for (a = 0; a < 16; a++) o[a] = c[a];
  36676. }
  36677. function pow2523(o, i) {
  36678. var c = gf();
  36679. var a;
  36680. for (a = 0; a < 16; a++) c[a] = i[a];
  36681. for (a = 250; a >= 0; a--) {
  36682. S(c, c);
  36683. if(a !== 1) M(c, c, i);
  36684. }
  36685. for (a = 0; a < 16; a++) o[a] = c[a];
  36686. }
  36687. function crypto_scalarmult(q, n, p) {
  36688. var z = new Uint8Array(32);
  36689. var x = new Float64Array(80), r, i;
  36690. var a = gf(), b = gf(), c = gf(),
  36691. d = gf(), e = gf(), f = gf();
  36692. for (i = 0; i < 31; i++) z[i] = n[i];
  36693. z[31]=(n[31]&127)|64;
  36694. z[0]&=248;
  36695. unpack25519(x,p);
  36696. for (i = 0; i < 16; i++) {
  36697. b[i]=x[i];
  36698. d[i]=a[i]=c[i]=0;
  36699. }
  36700. a[0]=d[0]=1;
  36701. for (i=254; i>=0; --i) {
  36702. r=(z[i>>>3]>>>(i&7))&1;
  36703. sel25519(a,b,r);
  36704. sel25519(c,d,r);
  36705. A(e,a,c);
  36706. Z(a,a,c);
  36707. A(c,b,d);
  36708. Z(b,b,d);
  36709. S(d,e);
  36710. S(f,a);
  36711. M(a,c,a);
  36712. M(c,b,e);
  36713. A(e,a,c);
  36714. Z(a,a,c);
  36715. S(b,a);
  36716. Z(c,d,f);
  36717. M(a,c,_121665);
  36718. A(a,a,d);
  36719. M(c,c,a);
  36720. M(a,d,f);
  36721. M(d,b,x);
  36722. S(b,e);
  36723. sel25519(a,b,r);
  36724. sel25519(c,d,r);
  36725. }
  36726. for (i = 0; i < 16; i++) {
  36727. x[i+16]=a[i];
  36728. x[i+32]=c[i];
  36729. x[i+48]=b[i];
  36730. x[i+64]=d[i];
  36731. }
  36732. var x32 = x.subarray(32);
  36733. var x16 = x.subarray(16);
  36734. inv25519(x32,x32);
  36735. M(x16,x16,x32);
  36736. pack25519(q,x16);
  36737. return 0;
  36738. }
  36739. function crypto_scalarmult_base(q, n) {
  36740. return crypto_scalarmult(q, n, _9);
  36741. }
  36742. function crypto_box_keypair(y, x) {
  36743. randombytes(x, 32);
  36744. return crypto_scalarmult_base(y, x);
  36745. }
  36746. function crypto_box_beforenm(k, y, x) {
  36747. var s = new Uint8Array(32);
  36748. crypto_scalarmult(s, x, y);
  36749. return crypto_core_hsalsa20(k, _0, s, sigma);
  36750. }
  36751. var crypto_box_afternm = crypto_secretbox;
  36752. var crypto_box_open_afternm = crypto_secretbox_open;
  36753. function crypto_box(c, m, d, n, y, x) {
  36754. var k = new Uint8Array(32);
  36755. crypto_box_beforenm(k, y, x);
  36756. return crypto_box_afternm(c, m, d, n, k);
  36757. }
  36758. function crypto_box_open(m, c, d, n, y, x) {
  36759. var k = new Uint8Array(32);
  36760. crypto_box_beforenm(k, y, x);
  36761. return crypto_box_open_afternm(m, c, d, n, k);
  36762. }
  36763. var K = [
  36764. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36765. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36766. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36767. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36768. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36769. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36770. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36771. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36772. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36773. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36774. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36775. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36776. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36777. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36778. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36779. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36780. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36781. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36782. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36783. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36784. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36785. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36786. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36787. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36788. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36789. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36790. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36791. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36792. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36793. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36794. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36795. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36796. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36797. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36798. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36799. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36800. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36801. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36802. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36803. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36804. ];
  36805. function crypto_hashblocks_hl(hh, hl, m, n) {
  36806. var wh = new Int32Array(16), wl = new Int32Array(16),
  36807. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36808. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36809. th, tl, i, j, h, l, a, b, c, d;
  36810. var ah0 = hh[0],
  36811. ah1 = hh[1],
  36812. ah2 = hh[2],
  36813. ah3 = hh[3],
  36814. ah4 = hh[4],
  36815. ah5 = hh[5],
  36816. ah6 = hh[6],
  36817. ah7 = hh[7],
  36818. al0 = hl[0],
  36819. al1 = hl[1],
  36820. al2 = hl[2],
  36821. al3 = hl[3],
  36822. al4 = hl[4],
  36823. al5 = hl[5],
  36824. al6 = hl[6],
  36825. al7 = hl[7];
  36826. var pos = 0;
  36827. while (n >= 128) {
  36828. for (i = 0; i < 16; i++) {
  36829. j = 8 * i + pos;
  36830. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36831. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36832. }
  36833. for (i = 0; i < 80; i++) {
  36834. bh0 = ah0;
  36835. bh1 = ah1;
  36836. bh2 = ah2;
  36837. bh3 = ah3;
  36838. bh4 = ah4;
  36839. bh5 = ah5;
  36840. bh6 = ah6;
  36841. bh7 = ah7;
  36842. bl0 = al0;
  36843. bl1 = al1;
  36844. bl2 = al2;
  36845. bl3 = al3;
  36846. bl4 = al4;
  36847. bl5 = al5;
  36848. bl6 = al6;
  36849. bl7 = al7;
  36850. // add
  36851. h = ah7;
  36852. l = al7;
  36853. a = l & 0xffff; b = l >>> 16;
  36854. c = h & 0xffff; d = h >>> 16;
  36855. // Sigma1
  36856. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36857. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36858. a += l & 0xffff; b += l >>> 16;
  36859. c += h & 0xffff; d += h >>> 16;
  36860. // Ch
  36861. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36862. l = (al4 & al5) ^ (~al4 & al6);
  36863. a += l & 0xffff; b += l >>> 16;
  36864. c += h & 0xffff; d += h >>> 16;
  36865. // K
  36866. h = K[i*2];
  36867. l = K[i*2+1];
  36868. a += l & 0xffff; b += l >>> 16;
  36869. c += h & 0xffff; d += h >>> 16;
  36870. // w
  36871. h = wh[i%16];
  36872. l = wl[i%16];
  36873. a += l & 0xffff; b += l >>> 16;
  36874. c += h & 0xffff; d += h >>> 16;
  36875. b += a >>> 16;
  36876. c += b >>> 16;
  36877. d += c >>> 16;
  36878. th = c & 0xffff | d << 16;
  36879. tl = a & 0xffff | b << 16;
  36880. // add
  36881. h = th;
  36882. l = tl;
  36883. a = l & 0xffff; b = l >>> 16;
  36884. c = h & 0xffff; d = h >>> 16;
  36885. // Sigma0
  36886. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36887. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36888. a += l & 0xffff; b += l >>> 16;
  36889. c += h & 0xffff; d += h >>> 16;
  36890. // Maj
  36891. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36892. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36893. a += l & 0xffff; b += l >>> 16;
  36894. c += h & 0xffff; d += h >>> 16;
  36895. b += a >>> 16;
  36896. c += b >>> 16;
  36897. d += c >>> 16;
  36898. bh7 = (c & 0xffff) | (d << 16);
  36899. bl7 = (a & 0xffff) | (b << 16);
  36900. // add
  36901. h = bh3;
  36902. l = bl3;
  36903. a = l & 0xffff; b = l >>> 16;
  36904. c = h & 0xffff; d = h >>> 16;
  36905. h = th;
  36906. l = tl;
  36907. a += l & 0xffff; b += l >>> 16;
  36908. c += h & 0xffff; d += h >>> 16;
  36909. b += a >>> 16;
  36910. c += b >>> 16;
  36911. d += c >>> 16;
  36912. bh3 = (c & 0xffff) | (d << 16);
  36913. bl3 = (a & 0xffff) | (b << 16);
  36914. ah1 = bh0;
  36915. ah2 = bh1;
  36916. ah3 = bh2;
  36917. ah4 = bh3;
  36918. ah5 = bh4;
  36919. ah6 = bh5;
  36920. ah7 = bh6;
  36921. ah0 = bh7;
  36922. al1 = bl0;
  36923. al2 = bl1;
  36924. al3 = bl2;
  36925. al4 = bl3;
  36926. al5 = bl4;
  36927. al6 = bl5;
  36928. al7 = bl6;
  36929. al0 = bl7;
  36930. if (i%16 === 15) {
  36931. for (j = 0; j < 16; j++) {
  36932. // add
  36933. h = wh[j];
  36934. l = wl[j];
  36935. a = l & 0xffff; b = l >>> 16;
  36936. c = h & 0xffff; d = h >>> 16;
  36937. h = wh[(j+9)%16];
  36938. l = wl[(j+9)%16];
  36939. a += l & 0xffff; b += l >>> 16;
  36940. c += h & 0xffff; d += h >>> 16;
  36941. // sigma0
  36942. th = wh[(j+1)%16];
  36943. tl = wl[(j+1)%16];
  36944. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36945. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36946. a += l & 0xffff; b += l >>> 16;
  36947. c += h & 0xffff; d += h >>> 16;
  36948. // sigma1
  36949. th = wh[(j+14)%16];
  36950. tl = wl[(j+14)%16];
  36951. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36952. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36953. a += l & 0xffff; b += l >>> 16;
  36954. c += h & 0xffff; d += h >>> 16;
  36955. b += a >>> 16;
  36956. c += b >>> 16;
  36957. d += c >>> 16;
  36958. wh[j] = (c & 0xffff) | (d << 16);
  36959. wl[j] = (a & 0xffff) | (b << 16);
  36960. }
  36961. }
  36962. }
  36963. // add
  36964. h = ah0;
  36965. l = al0;
  36966. a = l & 0xffff; b = l >>> 16;
  36967. c = h & 0xffff; d = h >>> 16;
  36968. h = hh[0];
  36969. l = hl[0];
  36970. a += l & 0xffff; b += l >>> 16;
  36971. c += h & 0xffff; d += h >>> 16;
  36972. b += a >>> 16;
  36973. c += b >>> 16;
  36974. d += c >>> 16;
  36975. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  36976. hl[0] = al0 = (a & 0xffff) | (b << 16);
  36977. h = ah1;
  36978. l = al1;
  36979. a = l & 0xffff; b = l >>> 16;
  36980. c = h & 0xffff; d = h >>> 16;
  36981. h = hh[1];
  36982. l = hl[1];
  36983. a += l & 0xffff; b += l >>> 16;
  36984. c += h & 0xffff; d += h >>> 16;
  36985. b += a >>> 16;
  36986. c += b >>> 16;
  36987. d += c >>> 16;
  36988. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  36989. hl[1] = al1 = (a & 0xffff) | (b << 16);
  36990. h = ah2;
  36991. l = al2;
  36992. a = l & 0xffff; b = l >>> 16;
  36993. c = h & 0xffff; d = h >>> 16;
  36994. h = hh[2];
  36995. l = hl[2];
  36996. a += l & 0xffff; b += l >>> 16;
  36997. c += h & 0xffff; d += h >>> 16;
  36998. b += a >>> 16;
  36999. c += b >>> 16;
  37000. d += c >>> 16;
  37001. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37002. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37003. h = ah3;
  37004. l = al3;
  37005. a = l & 0xffff; b = l >>> 16;
  37006. c = h & 0xffff; d = h >>> 16;
  37007. h = hh[3];
  37008. l = hl[3];
  37009. a += l & 0xffff; b += l >>> 16;
  37010. c += h & 0xffff; d += h >>> 16;
  37011. b += a >>> 16;
  37012. c += b >>> 16;
  37013. d += c >>> 16;
  37014. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37015. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37016. h = ah4;
  37017. l = al4;
  37018. a = l & 0xffff; b = l >>> 16;
  37019. c = h & 0xffff; d = h >>> 16;
  37020. h = hh[4];
  37021. l = hl[4];
  37022. a += l & 0xffff; b += l >>> 16;
  37023. c += h & 0xffff; d += h >>> 16;
  37024. b += a >>> 16;
  37025. c += b >>> 16;
  37026. d += c >>> 16;
  37027. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37028. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37029. h = ah5;
  37030. l = al5;
  37031. a = l & 0xffff; b = l >>> 16;
  37032. c = h & 0xffff; d = h >>> 16;
  37033. h = hh[5];
  37034. l = hl[5];
  37035. a += l & 0xffff; b += l >>> 16;
  37036. c += h & 0xffff; d += h >>> 16;
  37037. b += a >>> 16;
  37038. c += b >>> 16;
  37039. d += c >>> 16;
  37040. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37041. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37042. h = ah6;
  37043. l = al6;
  37044. a = l & 0xffff; b = l >>> 16;
  37045. c = h & 0xffff; d = h >>> 16;
  37046. h = hh[6];
  37047. l = hl[6];
  37048. a += l & 0xffff; b += l >>> 16;
  37049. c += h & 0xffff; d += h >>> 16;
  37050. b += a >>> 16;
  37051. c += b >>> 16;
  37052. d += c >>> 16;
  37053. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37054. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37055. h = ah7;
  37056. l = al7;
  37057. a = l & 0xffff; b = l >>> 16;
  37058. c = h & 0xffff; d = h >>> 16;
  37059. h = hh[7];
  37060. l = hl[7];
  37061. a += l & 0xffff; b += l >>> 16;
  37062. c += h & 0xffff; d += h >>> 16;
  37063. b += a >>> 16;
  37064. c += b >>> 16;
  37065. d += c >>> 16;
  37066. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37067. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37068. pos += 128;
  37069. n -= 128;
  37070. }
  37071. return n;
  37072. }
  37073. function crypto_hash(out, m, n) {
  37074. var hh = new Int32Array(8),
  37075. hl = new Int32Array(8),
  37076. x = new Uint8Array(256),
  37077. i, b = n;
  37078. hh[0] = 0x6a09e667;
  37079. hh[1] = 0xbb67ae85;
  37080. hh[2] = 0x3c6ef372;
  37081. hh[3] = 0xa54ff53a;
  37082. hh[4] = 0x510e527f;
  37083. hh[5] = 0x9b05688c;
  37084. hh[6] = 0x1f83d9ab;
  37085. hh[7] = 0x5be0cd19;
  37086. hl[0] = 0xf3bcc908;
  37087. hl[1] = 0x84caa73b;
  37088. hl[2] = 0xfe94f82b;
  37089. hl[3] = 0x5f1d36f1;
  37090. hl[4] = 0xade682d1;
  37091. hl[5] = 0x2b3e6c1f;
  37092. hl[6] = 0xfb41bd6b;
  37093. hl[7] = 0x137e2179;
  37094. crypto_hashblocks_hl(hh, hl, m, n);
  37095. n %= 128;
  37096. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37097. x[n] = 128;
  37098. n = 256-128*(n<112?1:0);
  37099. x[n-9] = 0;
  37100. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37101. crypto_hashblocks_hl(hh, hl, x, n);
  37102. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37103. return 0;
  37104. }
  37105. function add(p, q) {
  37106. var a = gf(), b = gf(), c = gf(),
  37107. d = gf(), e = gf(), f = gf(),
  37108. g = gf(), h = gf(), t = gf();
  37109. Z(a, p[1], p[0]);
  37110. Z(t, q[1], q[0]);
  37111. M(a, a, t);
  37112. A(b, p[0], p[1]);
  37113. A(t, q[0], q[1]);
  37114. M(b, b, t);
  37115. M(c, p[3], q[3]);
  37116. M(c, c, D2);
  37117. M(d, p[2], q[2]);
  37118. A(d, d, d);
  37119. Z(e, b, a);
  37120. Z(f, d, c);
  37121. A(g, d, c);
  37122. A(h, b, a);
  37123. M(p[0], e, f);
  37124. M(p[1], h, g);
  37125. M(p[2], g, f);
  37126. M(p[3], e, h);
  37127. }
  37128. function cswap(p, q, b) {
  37129. var i;
  37130. for (i = 0; i < 4; i++) {
  37131. sel25519(p[i], q[i], b);
  37132. }
  37133. }
  37134. function pack(r, p) {
  37135. var tx = gf(), ty = gf(), zi = gf();
  37136. inv25519(zi, p[2]);
  37137. M(tx, p[0], zi);
  37138. M(ty, p[1], zi);
  37139. pack25519(r, ty);
  37140. r[31] ^= par25519(tx) << 7;
  37141. }
  37142. function scalarmult(p, q, s) {
  37143. var b, i;
  37144. set25519(p[0], gf0);
  37145. set25519(p[1], gf1);
  37146. set25519(p[2], gf1);
  37147. set25519(p[3], gf0);
  37148. for (i = 255; i >= 0; --i) {
  37149. b = (s[(i/8)|0] >> (i&7)) & 1;
  37150. cswap(p, q, b);
  37151. add(q, p);
  37152. add(p, p);
  37153. cswap(p, q, b);
  37154. }
  37155. }
  37156. function scalarbase(p, s) {
  37157. var q = [gf(), gf(), gf(), gf()];
  37158. set25519(q[0], X);
  37159. set25519(q[1], Y);
  37160. set25519(q[2], gf1);
  37161. M(q[3], X, Y);
  37162. scalarmult(p, q, s);
  37163. }
  37164. function crypto_sign_keypair(pk, sk, seeded) {
  37165. var d = new Uint8Array(64);
  37166. var p = [gf(), gf(), gf(), gf()];
  37167. var i;
  37168. if (!seeded) randombytes(sk, 32);
  37169. crypto_hash(d, sk, 32);
  37170. d[0] &= 248;
  37171. d[31] &= 127;
  37172. d[31] |= 64;
  37173. scalarbase(p, d);
  37174. pack(pk, p);
  37175. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37176. return 0;
  37177. }
  37178. 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]);
  37179. function modL(r, x) {
  37180. var carry, i, j, k;
  37181. for (i = 63; i >= 32; --i) {
  37182. carry = 0;
  37183. for (j = i - 32, k = i - 12; j < k; ++j) {
  37184. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37185. carry = (x[j] + 128) >> 8;
  37186. x[j] -= carry * 256;
  37187. }
  37188. x[j] += carry;
  37189. x[i] = 0;
  37190. }
  37191. carry = 0;
  37192. for (j = 0; j < 32; j++) {
  37193. x[j] += carry - (x[31] >> 4) * L[j];
  37194. carry = x[j] >> 8;
  37195. x[j] &= 255;
  37196. }
  37197. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37198. for (i = 0; i < 32; i++) {
  37199. x[i+1] += x[i] >> 8;
  37200. r[i] = x[i] & 255;
  37201. }
  37202. }
  37203. function reduce(r) {
  37204. var x = new Float64Array(64), i;
  37205. for (i = 0; i < 64; i++) x[i] = r[i];
  37206. for (i = 0; i < 64; i++) r[i] = 0;
  37207. modL(r, x);
  37208. }
  37209. // Note: difference from C - smlen returned, not passed as argument.
  37210. function crypto_sign(sm, m, n, sk) {
  37211. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37212. var i, j, x = new Float64Array(64);
  37213. var p = [gf(), gf(), gf(), gf()];
  37214. crypto_hash(d, sk, 32);
  37215. d[0] &= 248;
  37216. d[31] &= 127;
  37217. d[31] |= 64;
  37218. var smlen = n + 64;
  37219. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37220. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37221. crypto_hash(r, sm.subarray(32), n+32);
  37222. reduce(r);
  37223. scalarbase(p, r);
  37224. pack(sm, p);
  37225. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37226. crypto_hash(h, sm, n + 64);
  37227. reduce(h);
  37228. for (i = 0; i < 64; i++) x[i] = 0;
  37229. for (i = 0; i < 32; i++) x[i] = r[i];
  37230. for (i = 0; i < 32; i++) {
  37231. for (j = 0; j < 32; j++) {
  37232. x[i+j] += h[i] * d[j];
  37233. }
  37234. }
  37235. modL(sm.subarray(32), x);
  37236. return smlen;
  37237. }
  37238. function unpackneg(r, p) {
  37239. var t = gf(), chk = gf(), num = gf(),
  37240. den = gf(), den2 = gf(), den4 = gf(),
  37241. den6 = gf();
  37242. set25519(r[2], gf1);
  37243. unpack25519(r[1], p);
  37244. S(num, r[1]);
  37245. M(den, num, D);
  37246. Z(num, num, r[2]);
  37247. A(den, r[2], den);
  37248. S(den2, den);
  37249. S(den4, den2);
  37250. M(den6, den4, den2);
  37251. M(t, den6, num);
  37252. M(t, t, den);
  37253. pow2523(t, t);
  37254. M(t, t, num);
  37255. M(t, t, den);
  37256. M(t, t, den);
  37257. M(r[0], t, den);
  37258. S(chk, r[0]);
  37259. M(chk, chk, den);
  37260. if (neq25519(chk, num)) M(r[0], r[0], I);
  37261. S(chk, r[0]);
  37262. M(chk, chk, den);
  37263. if (neq25519(chk, num)) return -1;
  37264. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37265. M(r[3], r[0], r[1]);
  37266. return 0;
  37267. }
  37268. function crypto_sign_open(m, sm, n, pk) {
  37269. var i, mlen;
  37270. var t = new Uint8Array(32), h = new Uint8Array(64);
  37271. var p = [gf(), gf(), gf(), gf()],
  37272. q = [gf(), gf(), gf(), gf()];
  37273. mlen = -1;
  37274. if (n < 64) return -1;
  37275. if (unpackneg(q, pk)) return -1;
  37276. for (i = 0; i < n; i++) m[i] = sm[i];
  37277. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37278. crypto_hash(h, m, n);
  37279. reduce(h);
  37280. scalarmult(p, q, h);
  37281. scalarbase(q, sm.subarray(32));
  37282. add(p, q);
  37283. pack(t, p);
  37284. n -= 64;
  37285. if (crypto_verify_32(sm, 0, t, 0)) {
  37286. for (i = 0; i < n; i++) m[i] = 0;
  37287. return -1;
  37288. }
  37289. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37290. mlen = n;
  37291. return mlen;
  37292. }
  37293. var crypto_secretbox_KEYBYTES = 32,
  37294. crypto_secretbox_NONCEBYTES = 24,
  37295. crypto_secretbox_ZEROBYTES = 32,
  37296. crypto_secretbox_BOXZEROBYTES = 16,
  37297. crypto_scalarmult_BYTES = 32,
  37298. crypto_scalarmult_SCALARBYTES = 32,
  37299. crypto_box_PUBLICKEYBYTES = 32,
  37300. crypto_box_SECRETKEYBYTES = 32,
  37301. crypto_box_BEFORENMBYTES = 32,
  37302. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37303. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37304. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37305. crypto_sign_BYTES = 64,
  37306. crypto_sign_PUBLICKEYBYTES = 32,
  37307. crypto_sign_SECRETKEYBYTES = 64,
  37308. crypto_sign_SEEDBYTES = 32,
  37309. crypto_hash_BYTES = 64;
  37310. nacl.lowlevel = {
  37311. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37312. crypto_stream_xor: crypto_stream_xor,
  37313. crypto_stream: crypto_stream,
  37314. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37315. crypto_stream_salsa20: crypto_stream_salsa20,
  37316. crypto_onetimeauth: crypto_onetimeauth,
  37317. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37318. crypto_verify_16: crypto_verify_16,
  37319. crypto_verify_32: crypto_verify_32,
  37320. crypto_secretbox: crypto_secretbox,
  37321. crypto_secretbox_open: crypto_secretbox_open,
  37322. crypto_scalarmult: crypto_scalarmult,
  37323. crypto_scalarmult_base: crypto_scalarmult_base,
  37324. crypto_box_beforenm: crypto_box_beforenm,
  37325. crypto_box_afternm: crypto_box_afternm,
  37326. crypto_box: crypto_box,
  37327. crypto_box_open: crypto_box_open,
  37328. crypto_box_keypair: crypto_box_keypair,
  37329. crypto_hash: crypto_hash,
  37330. crypto_sign: crypto_sign,
  37331. crypto_sign_keypair: crypto_sign_keypair,
  37332. crypto_sign_open: crypto_sign_open,
  37333. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37334. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37335. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37336. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37337. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37338. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37339. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37340. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37341. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37342. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37343. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37344. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37345. crypto_sign_BYTES: crypto_sign_BYTES,
  37346. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37347. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37348. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37349. crypto_hash_BYTES: crypto_hash_BYTES
  37350. };
  37351. /* High-level API */
  37352. function checkLengths(k, n) {
  37353. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37354. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37355. }
  37356. function checkBoxLengths(pk, sk) {
  37357. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37358. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37359. }
  37360. function checkArrayTypes() {
  37361. for (var i = 0; i < arguments.length; i++) {
  37362. if (!(arguments[i] instanceof Uint8Array))
  37363. throw new TypeError('unexpected type, use Uint8Array');
  37364. }
  37365. }
  37366. function cleanup(arr) {
  37367. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37368. }
  37369. nacl.randomBytes = function(n) {
  37370. var b = new Uint8Array(n);
  37371. randombytes(b, n);
  37372. return b;
  37373. };
  37374. nacl.secretbox = function(msg, nonce, key) {
  37375. checkArrayTypes(msg, nonce, key);
  37376. checkLengths(key, nonce);
  37377. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37378. var c = new Uint8Array(m.length);
  37379. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37380. crypto_secretbox(c, m, m.length, nonce, key);
  37381. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37382. };
  37383. nacl.secretbox.open = function(box, nonce, key) {
  37384. checkArrayTypes(box, nonce, key);
  37385. checkLengths(key, nonce);
  37386. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37387. var m = new Uint8Array(c.length);
  37388. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37389. if (c.length < 32) return null;
  37390. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37391. return m.subarray(crypto_secretbox_ZEROBYTES);
  37392. };
  37393. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37394. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37395. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37396. nacl.scalarMult = function(n, p) {
  37397. checkArrayTypes(n, p);
  37398. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37399. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37400. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37401. crypto_scalarmult(q, n, p);
  37402. return q;
  37403. };
  37404. nacl.scalarMult.base = function(n) {
  37405. checkArrayTypes(n);
  37406. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37407. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37408. crypto_scalarmult_base(q, n);
  37409. return q;
  37410. };
  37411. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37412. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37413. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37414. var k = nacl.box.before(publicKey, secretKey);
  37415. return nacl.secretbox(msg, nonce, k);
  37416. };
  37417. nacl.box.before = function(publicKey, secretKey) {
  37418. checkArrayTypes(publicKey, secretKey);
  37419. checkBoxLengths(publicKey, secretKey);
  37420. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37421. crypto_box_beforenm(k, publicKey, secretKey);
  37422. return k;
  37423. };
  37424. nacl.box.after = nacl.secretbox;
  37425. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37426. var k = nacl.box.before(publicKey, secretKey);
  37427. return nacl.secretbox.open(msg, nonce, k);
  37428. };
  37429. nacl.box.open.after = nacl.secretbox.open;
  37430. nacl.box.keyPair = function() {
  37431. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37432. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37433. crypto_box_keypair(pk, sk);
  37434. return {publicKey: pk, secretKey: sk};
  37435. };
  37436. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37437. checkArrayTypes(secretKey);
  37438. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37439. throw new Error('bad secret key size');
  37440. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37441. crypto_scalarmult_base(pk, secretKey);
  37442. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37443. };
  37444. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37445. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37446. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37447. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37448. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37449. nacl.sign = function(msg, secretKey) {
  37450. checkArrayTypes(msg, secretKey);
  37451. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37452. throw new Error('bad secret key size');
  37453. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37454. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37455. return signedMsg;
  37456. };
  37457. nacl.sign.open = function(signedMsg, publicKey) {
  37458. checkArrayTypes(signedMsg, publicKey);
  37459. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37460. throw new Error('bad public key size');
  37461. var tmp = new Uint8Array(signedMsg.length);
  37462. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37463. if (mlen < 0) return null;
  37464. var m = new Uint8Array(mlen);
  37465. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37466. return m;
  37467. };
  37468. nacl.sign.detached = function(msg, secretKey) {
  37469. var signedMsg = nacl.sign(msg, secretKey);
  37470. var sig = new Uint8Array(crypto_sign_BYTES);
  37471. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37472. return sig;
  37473. };
  37474. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37475. checkArrayTypes(msg, sig, publicKey);
  37476. if (sig.length !== crypto_sign_BYTES)
  37477. throw new Error('bad signature size');
  37478. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37479. throw new Error('bad public key size');
  37480. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37481. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37482. var i;
  37483. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37484. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37485. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37486. };
  37487. nacl.sign.keyPair = function() {
  37488. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37489. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37490. crypto_sign_keypair(pk, sk);
  37491. return {publicKey: pk, secretKey: sk};
  37492. };
  37493. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37494. checkArrayTypes(secretKey);
  37495. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37496. throw new Error('bad secret key size');
  37497. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37498. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37499. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37500. };
  37501. nacl.sign.keyPair.fromSeed = function(seed) {
  37502. checkArrayTypes(seed);
  37503. if (seed.length !== crypto_sign_SEEDBYTES)
  37504. throw new Error('bad seed size');
  37505. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37506. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37507. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37508. crypto_sign_keypair(pk, sk, true);
  37509. return {publicKey: pk, secretKey: sk};
  37510. };
  37511. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37512. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37513. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37514. nacl.sign.signatureLength = crypto_sign_BYTES;
  37515. nacl.hash = function(msg) {
  37516. checkArrayTypes(msg);
  37517. var h = new Uint8Array(crypto_hash_BYTES);
  37518. crypto_hash(h, msg, msg.length);
  37519. return h;
  37520. };
  37521. nacl.hash.hashLength = crypto_hash_BYTES;
  37522. nacl.verify = function(x, y) {
  37523. checkArrayTypes(x, y);
  37524. // Zero length arguments are considered not equal.
  37525. if (x.length === 0 || y.length === 0) return false;
  37526. if (x.length !== y.length) return false;
  37527. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37528. };
  37529. nacl.setPRNG = function(fn) {
  37530. randombytes = fn;
  37531. };
  37532. (function() {
  37533. // Initialize PRNG if environment provides CSPRNG.
  37534. // If not, methods calling randombytes will throw.
  37535. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37536. if (crypto && crypto.getRandomValues) {
  37537. // Browsers.
  37538. var QUOTA = 65536;
  37539. nacl.setPRNG(function(x, n) {
  37540. var i, v = new Uint8Array(n);
  37541. for (i = 0; i < n; i += QUOTA) {
  37542. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37543. }
  37544. for (i = 0; i < n; i++) x[i] = v[i];
  37545. cleanup(v);
  37546. });
  37547. } else if (true) {
  37548. // Node.js.
  37549. crypto = __webpack_require__(3);
  37550. if (crypto && crypto.randomBytes) {
  37551. nacl.setPRNG(function(x, n) {
  37552. var i, v = crypto.randomBytes(n);
  37553. for (i = 0; i < n; i++) x[i] = v[i];
  37554. cleanup(v);
  37555. });
  37556. }
  37557. }
  37558. })();
  37559. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37560. /***/ }),
  37561. /* 1 */
  37562. /***/ (function(module, exports, __webpack_require__) {
  37563. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37564. // Public domain.
  37565. (function(root, f) {
  37566. 'use strict';
  37567. if ( true && module.exports) module.exports = f();
  37568. else if (root.nacl) root.nacl.util = f();
  37569. else {
  37570. root.nacl = {};
  37571. root.nacl.util = f();
  37572. }
  37573. }(this, function() {
  37574. 'use strict';
  37575. var util = {};
  37576. function validateBase64(s) {
  37577. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37578. throw new TypeError('invalid encoding');
  37579. }
  37580. }
  37581. util.decodeUTF8 = function(s) {
  37582. if (typeof s !== 'string') throw new TypeError('expected string');
  37583. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37584. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37585. return b;
  37586. };
  37587. util.encodeUTF8 = function(arr) {
  37588. var i, s = [];
  37589. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37590. return decodeURIComponent(escape(s.join('')));
  37591. };
  37592. if (typeof atob === 'undefined') {
  37593. // Node.js
  37594. if (typeof Buffer.from !== 'undefined') {
  37595. // Node v6 and later
  37596. util.encodeBase64 = function (arr) { // v6 and later
  37597. return Buffer.from(arr).toString('base64');
  37598. };
  37599. util.decodeBase64 = function (s) {
  37600. validateBase64(s);
  37601. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37602. };
  37603. } else {
  37604. // Node earlier than v6
  37605. util.encodeBase64 = function (arr) { // v6 and later
  37606. return (new Buffer(arr)).toString('base64');
  37607. };
  37608. util.decodeBase64 = function(s) {
  37609. validateBase64(s);
  37610. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37611. };
  37612. }
  37613. } else {
  37614. // Browsers
  37615. util.encodeBase64 = function(arr) {
  37616. var i, s = [], len = arr.length;
  37617. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37618. return btoa(s.join(''));
  37619. };
  37620. util.decodeBase64 = function(s) {
  37621. validateBase64(s);
  37622. var i, d = atob(s), b = new Uint8Array(d.length);
  37623. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37624. return b;
  37625. };
  37626. }
  37627. return util;
  37628. }));
  37629. /***/ }),
  37630. /* 2 */
  37631. /***/ (function(module, exports, __webpack_require__) {
  37632. // required so we don't have to do require('pusher').default etc.
  37633. module.exports = __webpack_require__(4).default;
  37634. /***/ }),
  37635. /* 3 */
  37636. /***/ (function(module, exports) {
  37637. /* (ignored) */
  37638. /***/ }),
  37639. /* 4 */
  37640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37641. "use strict";
  37642. __webpack_require__.r(__webpack_exports__);
  37643. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37644. var ScriptReceiverFactory = (function () {
  37645. function ScriptReceiverFactory(prefix, name) {
  37646. this.lastId = 0;
  37647. this.prefix = prefix;
  37648. this.name = name;
  37649. }
  37650. ScriptReceiverFactory.prototype.create = function (callback) {
  37651. this.lastId++;
  37652. var number = this.lastId;
  37653. var id = this.prefix + number;
  37654. var name = this.name + "[" + number + "]";
  37655. var called = false;
  37656. var callbackWrapper = function () {
  37657. if (!called) {
  37658. callback.apply(null, arguments);
  37659. called = true;
  37660. }
  37661. };
  37662. this[number] = callbackWrapper;
  37663. return { number: number, id: id, name: name, callback: callbackWrapper };
  37664. };
  37665. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37666. delete this[receiver.number];
  37667. };
  37668. return ScriptReceiverFactory;
  37669. }());
  37670. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37671. // CONCATENATED MODULE: ./src/core/defaults.ts
  37672. var Defaults = {
  37673. VERSION: "5.0.3",
  37674. PROTOCOL: 7,
  37675. host: 'ws.pusherapp.com',
  37676. ws_port: 80,
  37677. wss_port: 443,
  37678. ws_path: '',
  37679. sockjs_host: 'sockjs.pusher.com',
  37680. sockjs_http_port: 80,
  37681. sockjs_https_port: 443,
  37682. sockjs_path: '/pusher',
  37683. stats_host: 'stats.pusher.com',
  37684. channel_auth_endpoint: '/pusher/auth',
  37685. channel_auth_transport: 'ajax',
  37686. activity_timeout: 120000,
  37687. pong_timeout: 30000,
  37688. unavailable_timeout: 10000,
  37689. cdn_http: "http://js.pusher.com",
  37690. cdn_https: "https://js.pusher.com",
  37691. dependency_suffix: ""
  37692. };
  37693. /* harmony default export */ var defaults = (Defaults);
  37694. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37695. var dependency_loader_DependencyLoader = (function () {
  37696. function DependencyLoader(options) {
  37697. this.options = options;
  37698. this.receivers = options.receivers || ScriptReceivers;
  37699. this.loading = {};
  37700. }
  37701. DependencyLoader.prototype.load = function (name, options, callback) {
  37702. var self = this;
  37703. if (self.loading[name] && self.loading[name].length > 0) {
  37704. self.loading[name].push(callback);
  37705. }
  37706. else {
  37707. self.loading[name] = [callback];
  37708. var request = runtime.createScriptRequest(self.getPath(name, options));
  37709. var receiver = self.receivers.create(function (error) {
  37710. self.receivers.remove(receiver);
  37711. if (self.loading[name]) {
  37712. var callbacks = self.loading[name];
  37713. delete self.loading[name];
  37714. var successCallback = function (wasSuccessful) {
  37715. if (!wasSuccessful) {
  37716. request.cleanup();
  37717. }
  37718. };
  37719. for (var i = 0; i < callbacks.length; i++) {
  37720. callbacks[i](error, successCallback);
  37721. }
  37722. }
  37723. });
  37724. request.send(receiver);
  37725. }
  37726. };
  37727. DependencyLoader.prototype.getRoot = function (options) {
  37728. var cdn;
  37729. var protocol = runtime.getDocument().location.protocol;
  37730. if ((options && options.useTLS) || protocol === "https:") {
  37731. cdn = this.options.cdn_https;
  37732. }
  37733. else {
  37734. cdn = this.options.cdn_http;
  37735. }
  37736. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37737. };
  37738. DependencyLoader.prototype.getPath = function (name, options) {
  37739. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37740. };
  37741. ;
  37742. return DependencyLoader;
  37743. }());
  37744. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37745. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37746. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37747. var Dependencies = new dependency_loader({
  37748. cdn_http: defaults.cdn_http,
  37749. cdn_https: defaults.cdn_https,
  37750. version: defaults.VERSION,
  37751. suffix: defaults.dependency_suffix,
  37752. receivers: DependenciesReceivers
  37753. });
  37754. // CONCATENATED MODULE: ./src/core/base64.ts
  37755. function encode(s) {
  37756. return btoa(utob(s));
  37757. }
  37758. var fromCharCode = String.fromCharCode;
  37759. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37760. var b64tab = {};
  37761. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37762. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37763. }
  37764. var cb_utob = function (c) {
  37765. var cc = c.charCodeAt(0);
  37766. return cc < 0x80
  37767. ? c
  37768. : cc < 0x800
  37769. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37770. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37771. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37772. fromCharCode(0x80 | (cc & 0x3f));
  37773. };
  37774. var utob = function (u) {
  37775. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37776. };
  37777. var cb_encode = function (ccc) {
  37778. var padlen = [0, 2, 1][ccc.length % 3];
  37779. var ord = (ccc.charCodeAt(0) << 16) |
  37780. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37781. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37782. var chars = [
  37783. b64chars.charAt(ord >>> 18),
  37784. b64chars.charAt((ord >>> 12) & 63),
  37785. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37786. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37787. ];
  37788. return chars.join('');
  37789. };
  37790. var btoa = window.btoa ||
  37791. function (b) {
  37792. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37793. };
  37794. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37795. var Timer = (function () {
  37796. function Timer(set, clear, delay, callback) {
  37797. var _this = this;
  37798. this.clear = clear;
  37799. this.timer = set(function () {
  37800. if (_this.timer) {
  37801. _this.timer = callback(_this.timer);
  37802. }
  37803. }, delay);
  37804. }
  37805. Timer.prototype.isRunning = function () {
  37806. return this.timer !== null;
  37807. };
  37808. Timer.prototype.ensureAborted = function () {
  37809. if (this.timer) {
  37810. this.clear(this.timer);
  37811. this.timer = null;
  37812. }
  37813. };
  37814. return Timer;
  37815. }());
  37816. /* harmony default export */ var abstract_timer = (Timer);
  37817. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37818. var __extends = (undefined && undefined.__extends) || (function () {
  37819. var extendStatics = function (d, b) {
  37820. extendStatics = Object.setPrototypeOf ||
  37821. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37822. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37823. return extendStatics(d, b);
  37824. };
  37825. return function (d, b) {
  37826. extendStatics(d, b);
  37827. function __() { this.constructor = d; }
  37828. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37829. };
  37830. })();
  37831. function timers_clearTimeout(timer) {
  37832. window.clearTimeout(timer);
  37833. }
  37834. function timers_clearInterval(timer) {
  37835. window.clearInterval(timer);
  37836. }
  37837. var OneOffTimer = (function (_super) {
  37838. __extends(OneOffTimer, _super);
  37839. function OneOffTimer(delay, callback) {
  37840. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37841. callback();
  37842. return null;
  37843. }) || this;
  37844. }
  37845. return OneOffTimer;
  37846. }(abstract_timer));
  37847. var PeriodicTimer = (function (_super) {
  37848. __extends(PeriodicTimer, _super);
  37849. function PeriodicTimer(delay, callback) {
  37850. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37851. callback();
  37852. return timer;
  37853. }) || this;
  37854. }
  37855. return PeriodicTimer;
  37856. }(abstract_timer));
  37857. // CONCATENATED MODULE: ./src/core/util.ts
  37858. var Util = {
  37859. now: function () {
  37860. if (Date.now) {
  37861. return Date.now();
  37862. }
  37863. else {
  37864. return new Date().valueOf();
  37865. }
  37866. },
  37867. defer: function (callback) {
  37868. return new OneOffTimer(0, callback);
  37869. },
  37870. method: function (name) {
  37871. var args = [];
  37872. for (var _i = 1; _i < arguments.length; _i++) {
  37873. args[_i - 1] = arguments[_i];
  37874. }
  37875. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37876. return function (object) {
  37877. return object[name].apply(object, boundArguments.concat(arguments));
  37878. };
  37879. }
  37880. };
  37881. /* harmony default export */ var util = (Util);
  37882. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37883. function extend(target) {
  37884. var sources = [];
  37885. for (var _i = 1; _i < arguments.length; _i++) {
  37886. sources[_i - 1] = arguments[_i];
  37887. }
  37888. for (var i = 0; i < sources.length; i++) {
  37889. var extensions = sources[i];
  37890. for (var property in extensions) {
  37891. if (extensions[property] && extensions[property].constructor &&
  37892. extensions[property].constructor === Object) {
  37893. target[property] = extend(target[property] || {}, extensions[property]);
  37894. }
  37895. else {
  37896. target[property] = extensions[property];
  37897. }
  37898. }
  37899. }
  37900. return target;
  37901. }
  37902. function stringify() {
  37903. var m = ["Pusher"];
  37904. for (var i = 0; i < arguments.length; i++) {
  37905. if (typeof arguments[i] === "string") {
  37906. m.push(arguments[i]);
  37907. }
  37908. else {
  37909. m.push(safeJSONStringify(arguments[i]));
  37910. }
  37911. }
  37912. return m.join(" : ");
  37913. }
  37914. function arrayIndexOf(array, item) {
  37915. var nativeIndexOf = Array.prototype.indexOf;
  37916. if (array === null) {
  37917. return -1;
  37918. }
  37919. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37920. return array.indexOf(item);
  37921. }
  37922. for (var i = 0, l = array.length; i < l; i++) {
  37923. if (array[i] === item) {
  37924. return i;
  37925. }
  37926. }
  37927. return -1;
  37928. }
  37929. function objectApply(object, f) {
  37930. for (var key in object) {
  37931. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37932. f(object[key], key, object);
  37933. }
  37934. }
  37935. }
  37936. function keys(object) {
  37937. var keys = [];
  37938. objectApply(object, function (_, key) {
  37939. keys.push(key);
  37940. });
  37941. return keys;
  37942. }
  37943. function values(object) {
  37944. var values = [];
  37945. objectApply(object, function (value) {
  37946. values.push(value);
  37947. });
  37948. return values;
  37949. }
  37950. function apply(array, f, context) {
  37951. for (var i = 0; i < array.length; i++) {
  37952. f.call(context || window, array[i], i, array);
  37953. }
  37954. }
  37955. function map(array, f) {
  37956. var result = [];
  37957. for (var i = 0; i < array.length; i++) {
  37958. result.push(f(array[i], i, array, result));
  37959. }
  37960. return result;
  37961. }
  37962. function mapObject(object, f) {
  37963. var result = {};
  37964. objectApply(object, function (value, key) {
  37965. result[key] = f(value);
  37966. });
  37967. return result;
  37968. }
  37969. function filter(array, test) {
  37970. test = test || function (value) { return !!value; };
  37971. var result = [];
  37972. for (var i = 0; i < array.length; i++) {
  37973. if (test(array[i], i, array, result)) {
  37974. result.push(array[i]);
  37975. }
  37976. }
  37977. return result;
  37978. }
  37979. function filterObject(object, test) {
  37980. var result = {};
  37981. objectApply(object, function (value, key) {
  37982. if ((test && test(value, key, object, result)) || Boolean(value)) {
  37983. result[key] = value;
  37984. }
  37985. });
  37986. return result;
  37987. }
  37988. function flatten(object) {
  37989. var result = [];
  37990. objectApply(object, function (value, key) {
  37991. result.push([key, value]);
  37992. });
  37993. return result;
  37994. }
  37995. function any(array, test) {
  37996. for (var i = 0; i < array.length; i++) {
  37997. if (test(array[i], i, array)) {
  37998. return true;
  37999. }
  38000. }
  38001. return false;
  38002. }
  38003. function collections_all(array, test) {
  38004. for (var i = 0; i < array.length; i++) {
  38005. if (!test(array[i], i, array)) {
  38006. return false;
  38007. }
  38008. }
  38009. return true;
  38010. }
  38011. function encodeParamsObject(data) {
  38012. return mapObject(data, function (value) {
  38013. if (typeof value === "object") {
  38014. value = safeJSONStringify(value);
  38015. }
  38016. return encodeURIComponent(encode(value.toString()));
  38017. });
  38018. }
  38019. function buildQueryString(data) {
  38020. var params = filterObject(data, function (value) {
  38021. return value !== undefined;
  38022. });
  38023. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38024. return query;
  38025. }
  38026. function decycleObject(object) {
  38027. var objects = [], paths = [];
  38028. return (function derez(value, path) {
  38029. var i, name, nu;
  38030. switch (typeof value) {
  38031. case 'object':
  38032. if (!value) {
  38033. return null;
  38034. }
  38035. for (i = 0; i < objects.length; i += 1) {
  38036. if (objects[i] === value) {
  38037. return { $ref: paths[i] };
  38038. }
  38039. }
  38040. objects.push(value);
  38041. paths.push(path);
  38042. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38043. nu = [];
  38044. for (i = 0; i < value.length; i += 1) {
  38045. nu[i] = derez(value[i], path + '[' + i + ']');
  38046. }
  38047. }
  38048. else {
  38049. nu = {};
  38050. for (name in value) {
  38051. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38052. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38053. }
  38054. }
  38055. }
  38056. return nu;
  38057. case 'number':
  38058. case 'string':
  38059. case 'boolean':
  38060. return value;
  38061. }
  38062. }(object, '$'));
  38063. }
  38064. function safeJSONStringify(source) {
  38065. try {
  38066. return JSON.stringify(source);
  38067. }
  38068. catch (e) {
  38069. return JSON.stringify(decycleObject(source));
  38070. }
  38071. }
  38072. // CONCATENATED MODULE: ./src/core/logger.ts
  38073. var logger_Logger = (function () {
  38074. function Logger() {
  38075. this.globalLog = function (message) {
  38076. if (window.console && window.console.log) {
  38077. window.console.log(message);
  38078. }
  38079. };
  38080. }
  38081. Logger.prototype.debug = function () {
  38082. var args = [];
  38083. for (var _i = 0; _i < arguments.length; _i++) {
  38084. args[_i] = arguments[_i];
  38085. }
  38086. this.log(this.globalLog, args);
  38087. };
  38088. Logger.prototype.warn = function () {
  38089. var args = [];
  38090. for (var _i = 0; _i < arguments.length; _i++) {
  38091. args[_i] = arguments[_i];
  38092. }
  38093. this.log(this.globalLogWarn, args);
  38094. };
  38095. Logger.prototype.error = function () {
  38096. var args = [];
  38097. for (var _i = 0; _i < arguments.length; _i++) {
  38098. args[_i] = arguments[_i];
  38099. }
  38100. this.log(this.globalLogError, args);
  38101. };
  38102. Logger.prototype.globalLogWarn = function (message) {
  38103. if (window.console && window.console.warn) {
  38104. window.console.warn(message);
  38105. }
  38106. else {
  38107. this.globalLog(message);
  38108. }
  38109. };
  38110. Logger.prototype.globalLogError = function (message) {
  38111. if (window.console && window.console.error) {
  38112. window.console.error(message);
  38113. }
  38114. else {
  38115. this.globalLogWarn(message);
  38116. }
  38117. };
  38118. Logger.prototype.log = function (defaultLoggingFunction) {
  38119. var args = [];
  38120. for (var _i = 1; _i < arguments.length; _i++) {
  38121. args[_i - 1] = arguments[_i];
  38122. }
  38123. var message = stringify.apply(this, arguments);
  38124. if (core_pusher.log) {
  38125. core_pusher.log(message);
  38126. }
  38127. else if (core_pusher.logToConsole) {
  38128. var log = defaultLoggingFunction.bind(this);
  38129. log(message);
  38130. }
  38131. };
  38132. return Logger;
  38133. }());
  38134. /* harmony default export */ var logger = (new logger_Logger());
  38135. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38136. var urlStore = {
  38137. baseUrl: "https://pusher.com",
  38138. urls: {
  38139. authenticationEndpoint: {
  38140. path: "/docs/authenticating_users",
  38141. },
  38142. javascriptQuickStart: {
  38143. path: "/docs/javascript_quick_start"
  38144. },
  38145. triggeringClientEvents: {
  38146. path: "/docs/client_api_guide/client_events#trigger-events"
  38147. }
  38148. }
  38149. };
  38150. var buildLogSuffix = function (key) {
  38151. var urlPrefix = "See:";
  38152. var urlObj = urlStore.urls[key];
  38153. if (!urlObj)
  38154. return "";
  38155. var url;
  38156. if (urlObj.fullUrl) {
  38157. url = urlObj.fullUrl;
  38158. }
  38159. else if (urlObj.path) {
  38160. url = urlStore.baseUrl + urlObj.path;
  38161. }
  38162. if (!url)
  38163. return "";
  38164. return urlPrefix + " " + url;
  38165. };
  38166. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38167. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38168. var ajax = function (context, socketId, callback) {
  38169. var self = this, xhr;
  38170. xhr = runtime.createXHR();
  38171. xhr.open("POST", self.options.authEndpoint, true);
  38172. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38173. for (var headerName in this.authOptions.headers) {
  38174. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38175. }
  38176. xhr.onreadystatechange = function () {
  38177. if (xhr.readyState === 4) {
  38178. if (xhr.status === 200) {
  38179. var data, parsed = false;
  38180. try {
  38181. data = JSON.parse(xhr.responseText);
  38182. parsed = true;
  38183. }
  38184. catch (e) {
  38185. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38186. }
  38187. if (parsed) {
  38188. callback(false, data);
  38189. }
  38190. }
  38191. else {
  38192. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38193. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38194. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38195. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38196. callback(true, xhr.status);
  38197. }
  38198. }
  38199. };
  38200. xhr.send(this.composeQuery(socketId));
  38201. return xhr;
  38202. };
  38203. /* harmony default export */ var xhr_auth = (ajax);
  38204. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38205. var jsonp = function (context, socketId, callback) {
  38206. if (this.authOptions.headers !== undefined) {
  38207. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38208. }
  38209. var callbackName = context.nextAuthCallbackID.toString();
  38210. context.nextAuthCallbackID++;
  38211. var document = context.getDocument();
  38212. var script = document.createElement("script");
  38213. context.auth_callbacks[callbackName] = function (data) {
  38214. callback(false, data);
  38215. };
  38216. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38217. script.src = this.options.authEndpoint +
  38218. '?callback=' +
  38219. encodeURIComponent(callback_name) +
  38220. '&' +
  38221. this.composeQuery(socketId);
  38222. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38223. head.insertBefore(script, head.firstChild);
  38224. };
  38225. /* harmony default export */ var jsonp_auth = (jsonp);
  38226. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38227. var ScriptRequest = (function () {
  38228. function ScriptRequest(src) {
  38229. this.src = src;
  38230. }
  38231. ScriptRequest.prototype.send = function (receiver) {
  38232. var self = this;
  38233. var errorString = "Error loading " + self.src;
  38234. self.script = document.createElement("script");
  38235. self.script.id = receiver.id;
  38236. self.script.src = self.src;
  38237. self.script.type = "text/javascript";
  38238. self.script.charset = "UTF-8";
  38239. if (self.script.addEventListener) {
  38240. self.script.onerror = function () {
  38241. receiver.callback(errorString);
  38242. };
  38243. self.script.onload = function () {
  38244. receiver.callback(null);
  38245. };
  38246. }
  38247. else {
  38248. self.script.onreadystatechange = function () {
  38249. if (self.script.readyState === 'loaded' ||
  38250. self.script.readyState === 'complete') {
  38251. receiver.callback(null);
  38252. }
  38253. };
  38254. }
  38255. if (self.script.async === undefined && document.attachEvent &&
  38256. /opera/i.test(navigator.userAgent)) {
  38257. self.errorScript = document.createElement("script");
  38258. self.errorScript.id = receiver.id + "_error";
  38259. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38260. self.script.async = self.errorScript.async = false;
  38261. }
  38262. else {
  38263. self.script.async = true;
  38264. }
  38265. var head = document.getElementsByTagName('head')[0];
  38266. head.insertBefore(self.script, head.firstChild);
  38267. if (self.errorScript) {
  38268. head.insertBefore(self.errorScript, self.script.nextSibling);
  38269. }
  38270. };
  38271. ScriptRequest.prototype.cleanup = function () {
  38272. if (this.script) {
  38273. this.script.onload = this.script.onerror = null;
  38274. this.script.onreadystatechange = null;
  38275. }
  38276. if (this.script && this.script.parentNode) {
  38277. this.script.parentNode.removeChild(this.script);
  38278. }
  38279. if (this.errorScript && this.errorScript.parentNode) {
  38280. this.errorScript.parentNode.removeChild(this.errorScript);
  38281. }
  38282. this.script = null;
  38283. this.errorScript = null;
  38284. };
  38285. return ScriptRequest;
  38286. }());
  38287. /* harmony default export */ var script_request = (ScriptRequest);
  38288. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38289. var jsonp_request_JSONPRequest = (function () {
  38290. function JSONPRequest(url, data) {
  38291. this.url = url;
  38292. this.data = data;
  38293. }
  38294. JSONPRequest.prototype.send = function (receiver) {
  38295. if (this.request) {
  38296. return;
  38297. }
  38298. var query = buildQueryString(this.data);
  38299. var url = this.url + "/" + receiver.number + "?" + query;
  38300. this.request = runtime.createScriptRequest(url);
  38301. this.request.send(receiver);
  38302. };
  38303. JSONPRequest.prototype.cleanup = function () {
  38304. if (this.request) {
  38305. this.request.cleanup();
  38306. }
  38307. };
  38308. return JSONPRequest;
  38309. }());
  38310. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38311. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38312. var getAgent = function (sender, useTLS) {
  38313. return function (data, callback) {
  38314. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38315. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38316. var request = runtime.createJSONPRequest(url, data);
  38317. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38318. ScriptReceivers.remove(receiver);
  38319. request.cleanup();
  38320. if (result && result.host) {
  38321. sender.host = result.host;
  38322. }
  38323. if (callback) {
  38324. callback(error, result);
  38325. }
  38326. });
  38327. request.send(receiver);
  38328. };
  38329. };
  38330. var jsonp_timeline_jsonp = {
  38331. name: 'jsonp',
  38332. getAgent: getAgent
  38333. };
  38334. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38335. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38336. function getGenericURL(baseScheme, params, path) {
  38337. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38338. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38339. return scheme + "://" + host + path;
  38340. }
  38341. function getGenericPath(key, queryString) {
  38342. var path = "/app/" + key;
  38343. var query = "?protocol=" + defaults.PROTOCOL +
  38344. "&client=js" +
  38345. "&version=" + defaults.VERSION +
  38346. (queryString ? ("&" + queryString) : "");
  38347. return path + query;
  38348. }
  38349. var ws = {
  38350. getInitial: function (key, params) {
  38351. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38352. return getGenericURL("ws", params, path);
  38353. }
  38354. };
  38355. var http = {
  38356. getInitial: function (key, params) {
  38357. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38358. return getGenericURL("http", params, path);
  38359. }
  38360. };
  38361. var sockjs = {
  38362. getInitial: function (key, params) {
  38363. return getGenericURL("http", params, params.httpPath || "/pusher");
  38364. },
  38365. getPath: function (key, params) {
  38366. return getGenericPath(key);
  38367. }
  38368. };
  38369. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38370. var callback_registry_CallbackRegistry = (function () {
  38371. function CallbackRegistry() {
  38372. this._callbacks = {};
  38373. }
  38374. CallbackRegistry.prototype.get = function (name) {
  38375. return this._callbacks[prefix(name)];
  38376. };
  38377. CallbackRegistry.prototype.add = function (name, callback, context) {
  38378. var prefixedEventName = prefix(name);
  38379. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38380. this._callbacks[prefixedEventName].push({
  38381. fn: callback,
  38382. context: context
  38383. });
  38384. };
  38385. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38386. if (!name && !callback && !context) {
  38387. this._callbacks = {};
  38388. return;
  38389. }
  38390. var names = name ? [prefix(name)] : keys(this._callbacks);
  38391. if (callback || context) {
  38392. this.removeCallback(names, callback, context);
  38393. }
  38394. else {
  38395. this.removeAllCallbacks(names);
  38396. }
  38397. };
  38398. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38399. apply(names, function (name) {
  38400. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38401. return (callback && callback !== binding.fn) ||
  38402. (context && context !== binding.context);
  38403. });
  38404. if (this._callbacks[name].length === 0) {
  38405. delete this._callbacks[name];
  38406. }
  38407. }, this);
  38408. };
  38409. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38410. apply(names, function (name) {
  38411. delete this._callbacks[name];
  38412. }, this);
  38413. };
  38414. return CallbackRegistry;
  38415. }());
  38416. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38417. function prefix(name) {
  38418. return "_" + name;
  38419. }
  38420. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38421. var dispatcher_Dispatcher = (function () {
  38422. function Dispatcher(failThrough) {
  38423. this.callbacks = new callback_registry();
  38424. this.global_callbacks = [];
  38425. this.failThrough = failThrough;
  38426. }
  38427. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38428. this.callbacks.add(eventName, callback, context);
  38429. return this;
  38430. };
  38431. Dispatcher.prototype.bind_global = function (callback) {
  38432. this.global_callbacks.push(callback);
  38433. return this;
  38434. };
  38435. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38436. this.callbacks.remove(eventName, callback, context);
  38437. return this;
  38438. };
  38439. Dispatcher.prototype.unbind_global = function (callback) {
  38440. if (!callback) {
  38441. this.global_callbacks = [];
  38442. return this;
  38443. }
  38444. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38445. return this;
  38446. };
  38447. Dispatcher.prototype.unbind_all = function () {
  38448. this.unbind();
  38449. this.unbind_global();
  38450. return this;
  38451. };
  38452. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38453. for (var i = 0; i < this.global_callbacks.length; i++) {
  38454. this.global_callbacks[i](eventName, data);
  38455. }
  38456. var callbacks = this.callbacks.get(eventName);
  38457. var args = [];
  38458. if (metadata) {
  38459. args.push(data, metadata);
  38460. }
  38461. else if (data) {
  38462. args.push(data);
  38463. }
  38464. if (callbacks && callbacks.length > 0) {
  38465. for (var i = 0; i < callbacks.length; i++) {
  38466. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38467. }
  38468. }
  38469. else if (this.failThrough) {
  38470. this.failThrough(eventName, data);
  38471. }
  38472. return this;
  38473. };
  38474. return Dispatcher;
  38475. }());
  38476. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38477. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38478. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38479. var extendStatics = function (d, b) {
  38480. extendStatics = Object.setPrototypeOf ||
  38481. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38482. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38483. return extendStatics(d, b);
  38484. };
  38485. return function (d, b) {
  38486. extendStatics(d, b);
  38487. function __() { this.constructor = d; }
  38488. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38489. };
  38490. })();
  38491. var transport_connection_TransportConnection = (function (_super) {
  38492. transport_connection_extends(TransportConnection, _super);
  38493. function TransportConnection(hooks, name, priority, key, options) {
  38494. var _this = _super.call(this) || this;
  38495. _this.initialize = runtime.transportConnectionInitializer;
  38496. _this.hooks = hooks;
  38497. _this.name = name;
  38498. _this.priority = priority;
  38499. _this.key = key;
  38500. _this.options = options;
  38501. _this.state = "new";
  38502. _this.timeline = options.timeline;
  38503. _this.activityTimeout = options.activityTimeout;
  38504. _this.id = _this.timeline.generateUniqueID();
  38505. return _this;
  38506. }
  38507. TransportConnection.prototype.handlesActivityChecks = function () {
  38508. return Boolean(this.hooks.handlesActivityChecks);
  38509. };
  38510. TransportConnection.prototype.supportsPing = function () {
  38511. return Boolean(this.hooks.supportsPing);
  38512. };
  38513. TransportConnection.prototype.connect = function () {
  38514. var _this = this;
  38515. if (this.socket || this.state !== "initialized") {
  38516. return false;
  38517. }
  38518. var url = this.hooks.urls.getInitial(this.key, this.options);
  38519. try {
  38520. this.socket = this.hooks.getSocket(url, this.options);
  38521. }
  38522. catch (e) {
  38523. util.defer(function () {
  38524. _this.onError(e);
  38525. _this.changeState("closed");
  38526. });
  38527. return false;
  38528. }
  38529. this.bindListeners();
  38530. logger.debug("Connecting", { transport: this.name, url: url });
  38531. this.changeState("connecting");
  38532. return true;
  38533. };
  38534. TransportConnection.prototype.close = function () {
  38535. if (this.socket) {
  38536. this.socket.close();
  38537. return true;
  38538. }
  38539. else {
  38540. return false;
  38541. }
  38542. };
  38543. TransportConnection.prototype.send = function (data) {
  38544. var _this = this;
  38545. if (this.state === "open") {
  38546. util.defer(function () {
  38547. if (_this.socket) {
  38548. _this.socket.send(data);
  38549. }
  38550. });
  38551. return true;
  38552. }
  38553. else {
  38554. return false;
  38555. }
  38556. };
  38557. TransportConnection.prototype.ping = function () {
  38558. if (this.state === "open" && this.supportsPing()) {
  38559. this.socket.ping();
  38560. }
  38561. };
  38562. TransportConnection.prototype.onOpen = function () {
  38563. if (this.hooks.beforeOpen) {
  38564. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38565. }
  38566. this.changeState("open");
  38567. this.socket.onopen = undefined;
  38568. };
  38569. TransportConnection.prototype.onError = function (error) {
  38570. this.emit("error", { type: 'WebSocketError', error: error });
  38571. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38572. };
  38573. TransportConnection.prototype.onClose = function (closeEvent) {
  38574. if (closeEvent) {
  38575. this.changeState("closed", {
  38576. code: closeEvent.code,
  38577. reason: closeEvent.reason,
  38578. wasClean: closeEvent.wasClean
  38579. });
  38580. }
  38581. else {
  38582. this.changeState("closed");
  38583. }
  38584. this.unbindListeners();
  38585. this.socket = undefined;
  38586. };
  38587. TransportConnection.prototype.onMessage = function (message) {
  38588. this.emit("message", message);
  38589. };
  38590. TransportConnection.prototype.onActivity = function () {
  38591. this.emit("activity");
  38592. };
  38593. TransportConnection.prototype.bindListeners = function () {
  38594. var _this = this;
  38595. this.socket.onopen = function () {
  38596. _this.onOpen();
  38597. };
  38598. this.socket.onerror = function (error) {
  38599. _this.onError(error);
  38600. };
  38601. this.socket.onclose = function (closeEvent) {
  38602. _this.onClose(closeEvent);
  38603. };
  38604. this.socket.onmessage = function (message) {
  38605. _this.onMessage(message);
  38606. };
  38607. if (this.supportsPing()) {
  38608. this.socket.onactivity = function () { _this.onActivity(); };
  38609. }
  38610. };
  38611. TransportConnection.prototype.unbindListeners = function () {
  38612. if (this.socket) {
  38613. this.socket.onopen = undefined;
  38614. this.socket.onerror = undefined;
  38615. this.socket.onclose = undefined;
  38616. this.socket.onmessage = undefined;
  38617. if (this.supportsPing()) {
  38618. this.socket.onactivity = undefined;
  38619. }
  38620. }
  38621. };
  38622. TransportConnection.prototype.changeState = function (state, params) {
  38623. this.state = state;
  38624. this.timeline.info(this.buildTimelineMessage({
  38625. state: state,
  38626. params: params
  38627. }));
  38628. this.emit(state, params);
  38629. };
  38630. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38631. return extend({ cid: this.id }, message);
  38632. };
  38633. return TransportConnection;
  38634. }(dispatcher));
  38635. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38636. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38637. var transport_Transport = (function () {
  38638. function Transport(hooks) {
  38639. this.hooks = hooks;
  38640. }
  38641. Transport.prototype.isSupported = function (environment) {
  38642. return this.hooks.isSupported(environment);
  38643. };
  38644. Transport.prototype.createConnection = function (name, priority, key, options) {
  38645. return new transport_connection(this.hooks, name, priority, key, options);
  38646. };
  38647. return Transport;
  38648. }());
  38649. /* harmony default export */ var transports_transport = (transport_Transport);
  38650. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38651. var WSTransport = new transports_transport({
  38652. urls: ws,
  38653. handlesActivityChecks: false,
  38654. supportsPing: false,
  38655. isInitialized: function () {
  38656. return Boolean(runtime.getWebSocketAPI());
  38657. },
  38658. isSupported: function () {
  38659. return Boolean(runtime.getWebSocketAPI());
  38660. },
  38661. getSocket: function (url) {
  38662. return runtime.createWebSocket(url);
  38663. }
  38664. });
  38665. var httpConfiguration = {
  38666. urls: http,
  38667. handlesActivityChecks: false,
  38668. supportsPing: true,
  38669. isInitialized: function () {
  38670. return true;
  38671. }
  38672. };
  38673. var streamingConfiguration = extend({ getSocket: function (url) {
  38674. return runtime.HTTPFactory.createStreamingSocket(url);
  38675. }
  38676. }, httpConfiguration);
  38677. var pollingConfiguration = extend({ getSocket: function (url) {
  38678. return runtime.HTTPFactory.createPollingSocket(url);
  38679. }
  38680. }, httpConfiguration);
  38681. var xhrConfiguration = {
  38682. isSupported: function () {
  38683. return runtime.isXHRSupported();
  38684. }
  38685. };
  38686. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38687. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38688. var Transports = {
  38689. ws: WSTransport,
  38690. xhr_streaming: XHRStreamingTransport,
  38691. xhr_polling: XHRPollingTransport
  38692. };
  38693. /* harmony default export */ var transports = (Transports);
  38694. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38695. var SockJSTransport = new transports_transport({
  38696. file: "sockjs",
  38697. urls: sockjs,
  38698. handlesActivityChecks: true,
  38699. supportsPing: false,
  38700. isSupported: function () {
  38701. return true;
  38702. },
  38703. isInitialized: function () {
  38704. return window.SockJS !== undefined;
  38705. },
  38706. getSocket: function (url, options) {
  38707. return new window.SockJS(url, null, {
  38708. js_path: Dependencies.getPath("sockjs", {
  38709. useTLS: options.useTLS
  38710. }),
  38711. ignore_null_origin: options.ignoreNullOrigin
  38712. });
  38713. },
  38714. beforeOpen: function (socket, path) {
  38715. socket.send(JSON.stringify({
  38716. path: path
  38717. }));
  38718. }
  38719. });
  38720. var xdrConfiguration = {
  38721. isSupported: function (environment) {
  38722. var yes = runtime.isXDRSupported(environment.useTLS);
  38723. return yes;
  38724. }
  38725. };
  38726. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38727. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38728. transports.xdr_streaming = XDRStreamingTransport;
  38729. transports.xdr_polling = XDRPollingTransport;
  38730. transports.sockjs = SockJSTransport;
  38731. /* harmony default export */ var transports_transports = (transports);
  38732. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38733. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38734. var extendStatics = function (d, b) {
  38735. extendStatics = Object.setPrototypeOf ||
  38736. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38737. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38738. return extendStatics(d, b);
  38739. };
  38740. return function (d, b) {
  38741. extendStatics(d, b);
  38742. function __() { this.constructor = d; }
  38743. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38744. };
  38745. })();
  38746. var NetInfo = (function (_super) {
  38747. net_info_extends(NetInfo, _super);
  38748. function NetInfo() {
  38749. var _this = _super.call(this) || this;
  38750. var self = _this;
  38751. if (window.addEventListener !== undefined) {
  38752. window.addEventListener("online", function () {
  38753. self.emit('online');
  38754. }, false);
  38755. window.addEventListener("offline", function () {
  38756. self.emit('offline');
  38757. }, false);
  38758. }
  38759. return _this;
  38760. }
  38761. NetInfo.prototype.isOnline = function () {
  38762. if (window.navigator.onLine === undefined) {
  38763. return true;
  38764. }
  38765. else {
  38766. return window.navigator.onLine;
  38767. }
  38768. };
  38769. return NetInfo;
  38770. }(dispatcher));
  38771. var net_info_Network = new NetInfo();
  38772. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38773. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38774. function AssistantToTheTransportManager(manager, transport, options) {
  38775. this.manager = manager;
  38776. this.transport = transport;
  38777. this.minPingDelay = options.minPingDelay;
  38778. this.maxPingDelay = options.maxPingDelay;
  38779. this.pingDelay = undefined;
  38780. }
  38781. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38782. var _this = this;
  38783. options = extend({}, options, {
  38784. activityTimeout: this.pingDelay
  38785. });
  38786. var connection = this.transport.createConnection(name, priority, key, options);
  38787. var openTimestamp = null;
  38788. var onOpen = function () {
  38789. connection.unbind("open", onOpen);
  38790. connection.bind("closed", onClosed);
  38791. openTimestamp = util.now();
  38792. };
  38793. var onClosed = function (closeEvent) {
  38794. connection.unbind("closed", onClosed);
  38795. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38796. _this.manager.reportDeath();
  38797. }
  38798. else if (!closeEvent.wasClean && openTimestamp) {
  38799. var lifespan = util.now() - openTimestamp;
  38800. if (lifespan < 2 * _this.maxPingDelay) {
  38801. _this.manager.reportDeath();
  38802. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38803. }
  38804. }
  38805. };
  38806. connection.bind("open", onOpen);
  38807. return connection;
  38808. };
  38809. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38810. return this.manager.isAlive() && this.transport.isSupported(environment);
  38811. };
  38812. return AssistantToTheTransportManager;
  38813. }());
  38814. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38815. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38816. var Protocol = {
  38817. decodeMessage: function (messageEvent) {
  38818. try {
  38819. var messageData = JSON.parse(messageEvent.data);
  38820. var pusherEventData = messageData.data;
  38821. if (typeof pusherEventData === 'string') {
  38822. try {
  38823. pusherEventData = JSON.parse(messageData.data);
  38824. }
  38825. catch (e) { }
  38826. }
  38827. var pusherEvent = {
  38828. event: messageData.event,
  38829. channel: messageData.channel,
  38830. data: pusherEventData,
  38831. };
  38832. if (messageData.user_id) {
  38833. pusherEvent.user_id = messageData.user_id;
  38834. }
  38835. return pusherEvent;
  38836. }
  38837. catch (e) {
  38838. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38839. }
  38840. },
  38841. encodeMessage: function (event) {
  38842. return JSON.stringify(event);
  38843. },
  38844. processHandshake: function (messageEvent) {
  38845. var message = Protocol.decodeMessage(messageEvent);
  38846. if (message.event === "pusher:connection_established") {
  38847. if (!message.data.activity_timeout) {
  38848. throw "No activity timeout specified in handshake";
  38849. }
  38850. return {
  38851. action: "connected",
  38852. id: message.data.socket_id,
  38853. activityTimeout: message.data.activity_timeout * 1000
  38854. };
  38855. }
  38856. else if (message.event === "pusher:error") {
  38857. return {
  38858. action: this.getCloseAction(message.data),
  38859. error: this.getCloseError(message.data)
  38860. };
  38861. }
  38862. else {
  38863. throw "Invalid handshake";
  38864. }
  38865. },
  38866. getCloseAction: function (closeEvent) {
  38867. if (closeEvent.code < 4000) {
  38868. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38869. return "backoff";
  38870. }
  38871. else {
  38872. return null;
  38873. }
  38874. }
  38875. else if (closeEvent.code === 4000) {
  38876. return "tls_only";
  38877. }
  38878. else if (closeEvent.code < 4100) {
  38879. return "refused";
  38880. }
  38881. else if (closeEvent.code < 4200) {
  38882. return "backoff";
  38883. }
  38884. else if (closeEvent.code < 4300) {
  38885. return "retry";
  38886. }
  38887. else {
  38888. return "refused";
  38889. }
  38890. },
  38891. getCloseError: function (closeEvent) {
  38892. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38893. return {
  38894. type: 'PusherError',
  38895. data: {
  38896. code: closeEvent.code,
  38897. message: closeEvent.reason || closeEvent.message
  38898. }
  38899. };
  38900. }
  38901. else {
  38902. return null;
  38903. }
  38904. }
  38905. };
  38906. /* harmony default export */ var protocol_protocol = (Protocol);
  38907. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38908. var connection_extends = (undefined && undefined.__extends) || (function () {
  38909. var extendStatics = function (d, b) {
  38910. extendStatics = Object.setPrototypeOf ||
  38911. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38912. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38913. return extendStatics(d, b);
  38914. };
  38915. return function (d, b) {
  38916. extendStatics(d, b);
  38917. function __() { this.constructor = d; }
  38918. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38919. };
  38920. })();
  38921. var connection_Connection = (function (_super) {
  38922. connection_extends(Connection, _super);
  38923. function Connection(id, transport) {
  38924. var _this = _super.call(this) || this;
  38925. _this.id = id;
  38926. _this.transport = transport;
  38927. _this.activityTimeout = transport.activityTimeout;
  38928. _this.bindListeners();
  38929. return _this;
  38930. }
  38931. Connection.prototype.handlesActivityChecks = function () {
  38932. return this.transport.handlesActivityChecks();
  38933. };
  38934. Connection.prototype.send = function (data) {
  38935. return this.transport.send(data);
  38936. };
  38937. Connection.prototype.send_event = function (name, data, channel) {
  38938. var event = { event: name, data: data };
  38939. if (channel) {
  38940. event.channel = channel;
  38941. }
  38942. logger.debug('Event sent', event);
  38943. return this.send(protocol_protocol.encodeMessage(event));
  38944. };
  38945. Connection.prototype.ping = function () {
  38946. if (this.transport.supportsPing()) {
  38947. this.transport.ping();
  38948. }
  38949. else {
  38950. this.send_event('pusher:ping', {});
  38951. }
  38952. };
  38953. Connection.prototype.close = function () {
  38954. this.transport.close();
  38955. };
  38956. Connection.prototype.bindListeners = function () {
  38957. var _this = this;
  38958. var listeners = {
  38959. message: function (messageEvent) {
  38960. var pusherEvent;
  38961. try {
  38962. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  38963. }
  38964. catch (e) {
  38965. _this.emit('error', {
  38966. type: 'MessageParseError',
  38967. error: e,
  38968. data: messageEvent.data
  38969. });
  38970. }
  38971. if (pusherEvent !== undefined) {
  38972. logger.debug('Event recd', pusherEvent);
  38973. switch (pusherEvent.event) {
  38974. case 'pusher:error':
  38975. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  38976. break;
  38977. case 'pusher:ping':
  38978. _this.emit("ping");
  38979. break;
  38980. case 'pusher:pong':
  38981. _this.emit("pong");
  38982. break;
  38983. }
  38984. _this.emit('message', pusherEvent);
  38985. }
  38986. },
  38987. activity: function () {
  38988. _this.emit("activity");
  38989. },
  38990. error: function (error) {
  38991. _this.emit("error", { type: "WebSocketError", error: error });
  38992. },
  38993. closed: function (closeEvent) {
  38994. unbindListeners();
  38995. if (closeEvent && closeEvent.code) {
  38996. _this.handleCloseEvent(closeEvent);
  38997. }
  38998. _this.transport = null;
  38999. _this.emit("closed");
  39000. }
  39001. };
  39002. var unbindListeners = function () {
  39003. objectApply(listeners, function (listener, event) {
  39004. _this.transport.unbind(event, listener);
  39005. });
  39006. };
  39007. objectApply(listeners, function (listener, event) {
  39008. _this.transport.bind(event, listener);
  39009. });
  39010. };
  39011. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39012. var action = protocol_protocol.getCloseAction(closeEvent);
  39013. var error = protocol_protocol.getCloseError(closeEvent);
  39014. if (error) {
  39015. this.emit('error', error);
  39016. }
  39017. if (action) {
  39018. this.emit(action, { action: action, error: error });
  39019. }
  39020. };
  39021. return Connection;
  39022. }(dispatcher));
  39023. /* harmony default export */ var connection_connection = (connection_Connection);
  39024. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39025. var handshake_Handshake = (function () {
  39026. function Handshake(transport, callback) {
  39027. this.transport = transport;
  39028. this.callback = callback;
  39029. this.bindListeners();
  39030. }
  39031. Handshake.prototype.close = function () {
  39032. this.unbindListeners();
  39033. this.transport.close();
  39034. };
  39035. Handshake.prototype.bindListeners = function () {
  39036. var _this = this;
  39037. this.onMessage = function (m) {
  39038. _this.unbindListeners();
  39039. var result;
  39040. try {
  39041. result = protocol_protocol.processHandshake(m);
  39042. }
  39043. catch (e) {
  39044. _this.finish("error", { error: e });
  39045. _this.transport.close();
  39046. return;
  39047. }
  39048. if (result.action === "connected") {
  39049. _this.finish("connected", {
  39050. connection: new connection_connection(result.id, _this.transport),
  39051. activityTimeout: result.activityTimeout
  39052. });
  39053. }
  39054. else {
  39055. _this.finish(result.action, { error: result.error });
  39056. _this.transport.close();
  39057. }
  39058. };
  39059. this.onClosed = function (closeEvent) {
  39060. _this.unbindListeners();
  39061. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39062. var error = protocol_protocol.getCloseError(closeEvent);
  39063. _this.finish(action, { error: error });
  39064. };
  39065. this.transport.bind("message", this.onMessage);
  39066. this.transport.bind("closed", this.onClosed);
  39067. };
  39068. Handshake.prototype.unbindListeners = function () {
  39069. this.transport.unbind("message", this.onMessage);
  39070. this.transport.unbind("closed", this.onClosed);
  39071. };
  39072. Handshake.prototype.finish = function (action, params) {
  39073. this.callback(extend({ transport: this.transport, action: action }, params));
  39074. };
  39075. return Handshake;
  39076. }());
  39077. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39078. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39079. var pusher_authorizer_PusherAuthorizer = (function () {
  39080. function PusherAuthorizer(channel, options) {
  39081. this.channel = channel;
  39082. var authTransport = options.authTransport;
  39083. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39084. throw "'" + authTransport + "' is not a recognized auth transport";
  39085. }
  39086. this.type = authTransport;
  39087. this.options = options;
  39088. this.authOptions = (options || {}).auth || {};
  39089. }
  39090. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39091. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39092. '&channel_name=' + encodeURIComponent(this.channel.name);
  39093. for (var i in this.authOptions.params) {
  39094. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39095. }
  39096. return query;
  39097. };
  39098. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39099. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39100. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39101. };
  39102. return PusherAuthorizer;
  39103. }());
  39104. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39105. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39106. var timeline_sender_TimelineSender = (function () {
  39107. function TimelineSender(timeline, options) {
  39108. this.timeline = timeline;
  39109. this.options = options || {};
  39110. }
  39111. TimelineSender.prototype.send = function (useTLS, callback) {
  39112. if (this.timeline.isEmpty()) {
  39113. return;
  39114. }
  39115. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39116. };
  39117. return TimelineSender;
  39118. }());
  39119. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39120. // CONCATENATED MODULE: ./src/core/errors.ts
  39121. var errors_extends = (undefined && undefined.__extends) || (function () {
  39122. var extendStatics = function (d, b) {
  39123. extendStatics = Object.setPrototypeOf ||
  39124. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39125. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39126. return extendStatics(d, b);
  39127. };
  39128. return function (d, b) {
  39129. extendStatics(d, b);
  39130. function __() { this.constructor = d; }
  39131. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39132. };
  39133. })();
  39134. var BadEventName = (function (_super) {
  39135. errors_extends(BadEventName, _super);
  39136. function BadEventName(msg) {
  39137. var _newTarget = this.constructor;
  39138. var _this = _super.call(this, msg) || this;
  39139. Object.setPrototypeOf(_this, _newTarget.prototype);
  39140. return _this;
  39141. }
  39142. return BadEventName;
  39143. }(Error));
  39144. var RequestTimedOut = (function (_super) {
  39145. errors_extends(RequestTimedOut, _super);
  39146. function RequestTimedOut(msg) {
  39147. var _newTarget = this.constructor;
  39148. var _this = _super.call(this, msg) || this;
  39149. Object.setPrototypeOf(_this, _newTarget.prototype);
  39150. return _this;
  39151. }
  39152. return RequestTimedOut;
  39153. }(Error));
  39154. var TransportPriorityTooLow = (function (_super) {
  39155. errors_extends(TransportPriorityTooLow, _super);
  39156. function TransportPriorityTooLow(msg) {
  39157. var _newTarget = this.constructor;
  39158. var _this = _super.call(this, msg) || this;
  39159. Object.setPrototypeOf(_this, _newTarget.prototype);
  39160. return _this;
  39161. }
  39162. return TransportPriorityTooLow;
  39163. }(Error));
  39164. var TransportClosed = (function (_super) {
  39165. errors_extends(TransportClosed, _super);
  39166. function TransportClosed(msg) {
  39167. var _newTarget = this.constructor;
  39168. var _this = _super.call(this, msg) || this;
  39169. Object.setPrototypeOf(_this, _newTarget.prototype);
  39170. return _this;
  39171. }
  39172. return TransportClosed;
  39173. }(Error));
  39174. var UnsupportedFeature = (function (_super) {
  39175. errors_extends(UnsupportedFeature, _super);
  39176. function UnsupportedFeature(msg) {
  39177. var _newTarget = this.constructor;
  39178. var _this = _super.call(this, msg) || this;
  39179. Object.setPrototypeOf(_this, _newTarget.prototype);
  39180. return _this;
  39181. }
  39182. return UnsupportedFeature;
  39183. }(Error));
  39184. var UnsupportedTransport = (function (_super) {
  39185. errors_extends(UnsupportedTransport, _super);
  39186. function UnsupportedTransport(msg) {
  39187. var _newTarget = this.constructor;
  39188. var _this = _super.call(this, msg) || this;
  39189. Object.setPrototypeOf(_this, _newTarget.prototype);
  39190. return _this;
  39191. }
  39192. return UnsupportedTransport;
  39193. }(Error));
  39194. var UnsupportedStrategy = (function (_super) {
  39195. errors_extends(UnsupportedStrategy, _super);
  39196. function UnsupportedStrategy(msg) {
  39197. var _newTarget = this.constructor;
  39198. var _this = _super.call(this, msg) || this;
  39199. Object.setPrototypeOf(_this, _newTarget.prototype);
  39200. return _this;
  39201. }
  39202. return UnsupportedStrategy;
  39203. }(Error));
  39204. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39205. var channel_extends = (undefined && undefined.__extends) || (function () {
  39206. var extendStatics = function (d, b) {
  39207. extendStatics = Object.setPrototypeOf ||
  39208. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39209. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39210. return extendStatics(d, b);
  39211. };
  39212. return function (d, b) {
  39213. extendStatics(d, b);
  39214. function __() { this.constructor = d; }
  39215. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39216. };
  39217. })();
  39218. var channel_Channel = (function (_super) {
  39219. channel_extends(Channel, _super);
  39220. function Channel(name, pusher) {
  39221. var _this = _super.call(this, function (event, data) {
  39222. logger.debug('No callbacks on ' + name + ' for ' + event);
  39223. }) || this;
  39224. _this.name = name;
  39225. _this.pusher = pusher;
  39226. _this.subscribed = false;
  39227. _this.subscriptionPending = false;
  39228. _this.subscriptionCancelled = false;
  39229. return _this;
  39230. }
  39231. Channel.prototype.authorize = function (socketId, callback) {
  39232. return callback(false, {});
  39233. };
  39234. Channel.prototype.trigger = function (event, data) {
  39235. if (event.indexOf("client-") !== 0) {
  39236. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39237. }
  39238. if (!this.subscribed) {
  39239. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39240. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39241. }
  39242. return this.pusher.send_event(event, data, this.name);
  39243. };
  39244. Channel.prototype.disconnect = function () {
  39245. this.subscribed = false;
  39246. this.subscriptionPending = false;
  39247. };
  39248. Channel.prototype.handleEvent = function (event) {
  39249. var eventName = event.event;
  39250. var data = event.data;
  39251. if (eventName === "pusher_internal:subscription_succeeded") {
  39252. this.handleSubscriptionSucceededEvent(event);
  39253. }
  39254. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39255. var metadata = {};
  39256. this.emit(eventName, data, metadata);
  39257. }
  39258. };
  39259. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39260. this.subscriptionPending = false;
  39261. this.subscribed = true;
  39262. if (this.subscriptionCancelled) {
  39263. this.pusher.unsubscribe(this.name);
  39264. }
  39265. else {
  39266. this.emit("pusher:subscription_succeeded", event.data);
  39267. }
  39268. };
  39269. Channel.prototype.subscribe = function () {
  39270. var _this = this;
  39271. if (this.subscribed) {
  39272. return;
  39273. }
  39274. this.subscriptionPending = true;
  39275. this.subscriptionCancelled = false;
  39276. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39277. if (error) {
  39278. logger.error(data);
  39279. _this.emit('pusher:subscription_error', data);
  39280. }
  39281. else {
  39282. _this.pusher.send_event('pusher:subscribe', {
  39283. auth: data.auth,
  39284. channel_data: data.channel_data,
  39285. channel: _this.name
  39286. });
  39287. }
  39288. });
  39289. };
  39290. Channel.prototype.unsubscribe = function () {
  39291. this.subscribed = false;
  39292. this.pusher.send_event('pusher:unsubscribe', {
  39293. channel: this.name
  39294. });
  39295. };
  39296. Channel.prototype.cancelSubscription = function () {
  39297. this.subscriptionCancelled = true;
  39298. };
  39299. Channel.prototype.reinstateSubscription = function () {
  39300. this.subscriptionCancelled = false;
  39301. };
  39302. return Channel;
  39303. }(dispatcher));
  39304. /* harmony default export */ var channels_channel = (channel_Channel);
  39305. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39306. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39307. var extendStatics = function (d, b) {
  39308. extendStatics = Object.setPrototypeOf ||
  39309. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39310. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39311. return extendStatics(d, b);
  39312. };
  39313. return function (d, b) {
  39314. extendStatics(d, b);
  39315. function __() { this.constructor = d; }
  39316. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39317. };
  39318. })();
  39319. var private_channel_PrivateChannel = (function (_super) {
  39320. private_channel_extends(PrivateChannel, _super);
  39321. function PrivateChannel() {
  39322. return _super !== null && _super.apply(this, arguments) || this;
  39323. }
  39324. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39325. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39326. return authorizer.authorize(socketId, callback);
  39327. };
  39328. return PrivateChannel;
  39329. }(channels_channel));
  39330. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39331. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39332. var members_Members = (function () {
  39333. function Members() {
  39334. this.reset();
  39335. }
  39336. Members.prototype.get = function (id) {
  39337. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39338. return {
  39339. id: id,
  39340. info: this.members[id]
  39341. };
  39342. }
  39343. else {
  39344. return null;
  39345. }
  39346. };
  39347. Members.prototype.each = function (callback) {
  39348. var _this = this;
  39349. objectApply(this.members, function (member, id) {
  39350. callback(_this.get(id));
  39351. });
  39352. };
  39353. Members.prototype.setMyID = function (id) {
  39354. this.myID = id;
  39355. };
  39356. Members.prototype.onSubscription = function (subscriptionData) {
  39357. this.members = subscriptionData.presence.hash;
  39358. this.count = subscriptionData.presence.count;
  39359. this.me = this.get(this.myID);
  39360. };
  39361. Members.prototype.addMember = function (memberData) {
  39362. if (this.get(memberData.user_id) === null) {
  39363. this.count++;
  39364. }
  39365. this.members[memberData.user_id] = memberData.user_info;
  39366. return this.get(memberData.user_id);
  39367. };
  39368. Members.prototype.removeMember = function (memberData) {
  39369. var member = this.get(memberData.user_id);
  39370. if (member) {
  39371. delete this.members[memberData.user_id];
  39372. this.count--;
  39373. }
  39374. return member;
  39375. };
  39376. Members.prototype.reset = function () {
  39377. this.members = {};
  39378. this.count = 0;
  39379. this.myID = null;
  39380. this.me = null;
  39381. };
  39382. return Members;
  39383. }());
  39384. /* harmony default export */ var members = (members_Members);
  39385. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39386. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39387. var extendStatics = function (d, b) {
  39388. extendStatics = Object.setPrototypeOf ||
  39389. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39390. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39391. return extendStatics(d, b);
  39392. };
  39393. return function (d, b) {
  39394. extendStatics(d, b);
  39395. function __() { this.constructor = d; }
  39396. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39397. };
  39398. })();
  39399. var presence_channel_PresenceChannel = (function (_super) {
  39400. presence_channel_extends(PresenceChannel, _super);
  39401. function PresenceChannel(name, pusher) {
  39402. var _this = _super.call(this, name, pusher) || this;
  39403. _this.members = new members();
  39404. return _this;
  39405. }
  39406. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39407. var _this = this;
  39408. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39409. if (!error) {
  39410. if (authData.channel_data === undefined) {
  39411. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39412. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39413. ("expected 'channel_data' field. " + suffix));
  39414. callback("Invalid auth response");
  39415. return;
  39416. }
  39417. var channelData = JSON.parse(authData.channel_data);
  39418. _this.members.setMyID(channelData.user_id);
  39419. }
  39420. callback(error, authData);
  39421. });
  39422. };
  39423. PresenceChannel.prototype.handleEvent = function (event) {
  39424. var eventName = event.event;
  39425. if (eventName.indexOf("pusher_internal:") === 0) {
  39426. this.handleInternalEvent(event);
  39427. }
  39428. else {
  39429. var data = event.data;
  39430. var metadata = {};
  39431. if (event.user_id) {
  39432. metadata.user_id = event.user_id;
  39433. }
  39434. this.emit(eventName, data, metadata);
  39435. }
  39436. };
  39437. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39438. var eventName = event.event;
  39439. var data = event.data;
  39440. switch (eventName) {
  39441. case "pusher_internal:subscription_succeeded":
  39442. this.handleSubscriptionSucceededEvent(event);
  39443. break;
  39444. case "pusher_internal:member_added":
  39445. var addedMember = this.members.addMember(data);
  39446. this.emit('pusher:member_added', addedMember);
  39447. break;
  39448. case "pusher_internal:member_removed":
  39449. var removedMember = this.members.removeMember(data);
  39450. if (removedMember) {
  39451. this.emit('pusher:member_removed', removedMember);
  39452. }
  39453. break;
  39454. }
  39455. };
  39456. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39457. this.subscriptionPending = false;
  39458. this.subscribed = true;
  39459. if (this.subscriptionCancelled) {
  39460. this.pusher.unsubscribe(this.name);
  39461. }
  39462. else {
  39463. this.members.onSubscription(event.data);
  39464. this.emit("pusher:subscription_succeeded", this.members);
  39465. }
  39466. };
  39467. PresenceChannel.prototype.disconnect = function () {
  39468. this.members.reset();
  39469. _super.prototype.disconnect.call(this);
  39470. };
  39471. return PresenceChannel;
  39472. }(private_channel));
  39473. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39474. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39475. var nacl_fast = __webpack_require__(0);
  39476. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39477. var nacl_util = __webpack_require__(1);
  39478. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39479. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39480. var extendStatics = function (d, b) {
  39481. extendStatics = Object.setPrototypeOf ||
  39482. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39483. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39484. return extendStatics(d, b);
  39485. };
  39486. return function (d, b) {
  39487. extendStatics(d, b);
  39488. function __() { this.constructor = d; }
  39489. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39490. };
  39491. })();
  39492. var encrypted_channel_EncryptedChannel = (function (_super) {
  39493. encrypted_channel_extends(EncryptedChannel, _super);
  39494. function EncryptedChannel() {
  39495. var _this = _super !== null && _super.apply(this, arguments) || this;
  39496. _this.key = null;
  39497. return _this;
  39498. }
  39499. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39500. var _this = this;
  39501. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39502. if (error) {
  39503. callback(true, authData);
  39504. return;
  39505. }
  39506. var sharedSecret = authData["shared_secret"];
  39507. if (!sharedSecret) {
  39508. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39509. callback(true, errorMsg);
  39510. return;
  39511. }
  39512. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39513. delete authData["shared_secret"];
  39514. callback(false, authData);
  39515. });
  39516. };
  39517. EncryptedChannel.prototype.trigger = function (event, data) {
  39518. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39519. };
  39520. EncryptedChannel.prototype.handleEvent = function (event) {
  39521. var eventName = event.event;
  39522. var data = event.data;
  39523. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39524. _super.prototype.handleEvent.call(this, event);
  39525. return;
  39526. }
  39527. this.handleEncryptedEvent(eventName, data);
  39528. };
  39529. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39530. var _this = this;
  39531. if (!this.key) {
  39532. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39533. return;
  39534. }
  39535. if (!data.ciphertext || !data.nonce) {
  39536. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39537. return;
  39538. }
  39539. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39540. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39541. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39542. return;
  39543. }
  39544. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39545. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39546. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39547. return;
  39548. }
  39549. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39550. if (bytes === null) {
  39551. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39552. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39553. if (error) {
  39554. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39555. return;
  39556. }
  39557. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39558. if (bytes === null) {
  39559. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39560. return;
  39561. }
  39562. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39563. return;
  39564. });
  39565. return;
  39566. }
  39567. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39568. };
  39569. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39570. try {
  39571. this.emit(eventName, JSON.parse(data));
  39572. }
  39573. catch (e) {
  39574. this.emit(eventName, data);
  39575. }
  39576. return this;
  39577. };
  39578. return EncryptedChannel;
  39579. }(private_channel));
  39580. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39581. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39582. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39583. var extendStatics = function (d, b) {
  39584. extendStatics = Object.setPrototypeOf ||
  39585. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39586. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39587. return extendStatics(d, b);
  39588. };
  39589. return function (d, b) {
  39590. extendStatics(d, b);
  39591. function __() { this.constructor = d; }
  39592. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39593. };
  39594. })();
  39595. var connection_manager_ConnectionManager = (function (_super) {
  39596. connection_manager_extends(ConnectionManager, _super);
  39597. function ConnectionManager(key, options) {
  39598. var _this = _super.call(this) || this;
  39599. _this.key = key;
  39600. _this.options = options || {};
  39601. _this.state = "initialized";
  39602. _this.connection = null;
  39603. _this.usingTLS = !!options.useTLS;
  39604. _this.timeline = _this.options.timeline;
  39605. _this.errorCallbacks = _this.buildErrorCallbacks();
  39606. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39607. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39608. var Network = runtime.getNetwork();
  39609. Network.bind("online", function () {
  39610. _this.timeline.info({ netinfo: "online" });
  39611. if (_this.state === "connecting" || _this.state === "unavailable") {
  39612. _this.retryIn(0);
  39613. }
  39614. });
  39615. Network.bind("offline", function () {
  39616. _this.timeline.info({ netinfo: "offline" });
  39617. if (_this.connection) {
  39618. _this.sendActivityCheck();
  39619. }
  39620. });
  39621. _this.updateStrategy();
  39622. return _this;
  39623. }
  39624. ConnectionManager.prototype.connect = function () {
  39625. if (this.connection || this.runner) {
  39626. return;
  39627. }
  39628. if (!this.strategy.isSupported()) {
  39629. this.updateState("failed");
  39630. return;
  39631. }
  39632. this.updateState("connecting");
  39633. this.startConnecting();
  39634. this.setUnavailableTimer();
  39635. };
  39636. ;
  39637. ConnectionManager.prototype.send = function (data) {
  39638. if (this.connection) {
  39639. return this.connection.send(data);
  39640. }
  39641. else {
  39642. return false;
  39643. }
  39644. };
  39645. ;
  39646. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39647. if (this.connection) {
  39648. return this.connection.send_event(name, data, channel);
  39649. }
  39650. else {
  39651. return false;
  39652. }
  39653. };
  39654. ;
  39655. ConnectionManager.prototype.disconnect = function () {
  39656. this.disconnectInternally();
  39657. this.updateState("disconnected");
  39658. };
  39659. ;
  39660. ConnectionManager.prototype.isUsingTLS = function () {
  39661. return this.usingTLS;
  39662. };
  39663. ;
  39664. ConnectionManager.prototype.startConnecting = function () {
  39665. var _this = this;
  39666. var callback = function (error, handshake) {
  39667. if (error) {
  39668. _this.runner = _this.strategy.connect(0, callback);
  39669. }
  39670. else {
  39671. if (handshake.action === "error") {
  39672. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39673. _this.timeline.error({ handshakeError: handshake.error });
  39674. }
  39675. else {
  39676. _this.abortConnecting();
  39677. _this.handshakeCallbacks[handshake.action](handshake);
  39678. }
  39679. }
  39680. };
  39681. this.runner = this.strategy.connect(0, callback);
  39682. };
  39683. ;
  39684. ConnectionManager.prototype.abortConnecting = function () {
  39685. if (this.runner) {
  39686. this.runner.abort();
  39687. this.runner = null;
  39688. }
  39689. };
  39690. ;
  39691. ConnectionManager.prototype.disconnectInternally = function () {
  39692. this.abortConnecting();
  39693. this.clearRetryTimer();
  39694. this.clearUnavailableTimer();
  39695. if (this.connection) {
  39696. var connection = this.abandonConnection();
  39697. connection.close();
  39698. }
  39699. };
  39700. ;
  39701. ConnectionManager.prototype.updateStrategy = function () {
  39702. this.strategy = this.options.getStrategy({
  39703. key: this.key,
  39704. timeline: this.timeline,
  39705. useTLS: this.usingTLS
  39706. });
  39707. };
  39708. ;
  39709. ConnectionManager.prototype.retryIn = function (delay) {
  39710. var _this = this;
  39711. this.timeline.info({ action: "retry", delay: delay });
  39712. if (delay > 0) {
  39713. this.emit("connecting_in", Math.round(delay / 1000));
  39714. }
  39715. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39716. _this.disconnectInternally();
  39717. _this.connect();
  39718. });
  39719. };
  39720. ;
  39721. ConnectionManager.prototype.clearRetryTimer = function () {
  39722. if (this.retryTimer) {
  39723. this.retryTimer.ensureAborted();
  39724. this.retryTimer = null;
  39725. }
  39726. };
  39727. ;
  39728. ConnectionManager.prototype.setUnavailableTimer = function () {
  39729. var _this = this;
  39730. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39731. _this.updateState("unavailable");
  39732. });
  39733. };
  39734. ;
  39735. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39736. if (this.unavailableTimer) {
  39737. this.unavailableTimer.ensureAborted();
  39738. }
  39739. };
  39740. ;
  39741. ConnectionManager.prototype.sendActivityCheck = function () {
  39742. var _this = this;
  39743. this.stopActivityCheck();
  39744. this.connection.ping();
  39745. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39746. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39747. _this.retryIn(0);
  39748. });
  39749. };
  39750. ;
  39751. ConnectionManager.prototype.resetActivityCheck = function () {
  39752. var _this = this;
  39753. this.stopActivityCheck();
  39754. if (this.connection && !this.connection.handlesActivityChecks()) {
  39755. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39756. _this.sendActivityCheck();
  39757. });
  39758. }
  39759. };
  39760. ;
  39761. ConnectionManager.prototype.stopActivityCheck = function () {
  39762. if (this.activityTimer) {
  39763. this.activityTimer.ensureAborted();
  39764. }
  39765. };
  39766. ;
  39767. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39768. var _this = this;
  39769. return extend({}, errorCallbacks, {
  39770. message: function (message) {
  39771. _this.resetActivityCheck();
  39772. _this.emit('message', message);
  39773. },
  39774. ping: function () {
  39775. _this.send_event('pusher:pong', {});
  39776. },
  39777. activity: function () {
  39778. _this.resetActivityCheck();
  39779. },
  39780. error: function (error) {
  39781. _this.emit("error", { type: "WebSocketError", error: error });
  39782. },
  39783. closed: function () {
  39784. _this.abandonConnection();
  39785. if (_this.shouldRetry()) {
  39786. _this.retryIn(1000);
  39787. }
  39788. }
  39789. });
  39790. };
  39791. ;
  39792. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39793. var _this = this;
  39794. return extend({}, errorCallbacks, {
  39795. connected: function (handshake) {
  39796. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39797. _this.clearUnavailableTimer();
  39798. _this.setConnection(handshake.connection);
  39799. _this.socket_id = _this.connection.id;
  39800. _this.updateState("connected", { socket_id: _this.socket_id });
  39801. }
  39802. });
  39803. };
  39804. ;
  39805. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39806. var _this = this;
  39807. var withErrorEmitted = function (callback) {
  39808. return function (result) {
  39809. if (result.error) {
  39810. _this.emit("error", { type: "WebSocketError", error: result.error });
  39811. }
  39812. callback(result);
  39813. };
  39814. };
  39815. return {
  39816. tls_only: withErrorEmitted(function () {
  39817. _this.usingTLS = true;
  39818. _this.updateStrategy();
  39819. _this.retryIn(0);
  39820. }),
  39821. refused: withErrorEmitted(function () {
  39822. _this.disconnect();
  39823. }),
  39824. backoff: withErrorEmitted(function () {
  39825. _this.retryIn(1000);
  39826. }),
  39827. retry: withErrorEmitted(function () {
  39828. _this.retryIn(0);
  39829. })
  39830. };
  39831. };
  39832. ;
  39833. ConnectionManager.prototype.setConnection = function (connection) {
  39834. this.connection = connection;
  39835. for (var event in this.connectionCallbacks) {
  39836. this.connection.bind(event, this.connectionCallbacks[event]);
  39837. }
  39838. this.resetActivityCheck();
  39839. };
  39840. ;
  39841. ConnectionManager.prototype.abandonConnection = function () {
  39842. if (!this.connection) {
  39843. return;
  39844. }
  39845. this.stopActivityCheck();
  39846. for (var event in this.connectionCallbacks) {
  39847. this.connection.unbind(event, this.connectionCallbacks[event]);
  39848. }
  39849. var connection = this.connection;
  39850. this.connection = null;
  39851. return connection;
  39852. };
  39853. ConnectionManager.prototype.updateState = function (newState, data) {
  39854. var previousState = this.state;
  39855. this.state = newState;
  39856. if (previousState !== newState) {
  39857. var newStateDescription = newState;
  39858. if (newStateDescription === "connected") {
  39859. newStateDescription += " with new socket ID " + data.socket_id;
  39860. }
  39861. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39862. this.timeline.info({ state: newState, params: data });
  39863. this.emit('state_change', { previous: previousState, current: newState });
  39864. this.emit(newState, data);
  39865. }
  39866. };
  39867. ConnectionManager.prototype.shouldRetry = function () {
  39868. return this.state === "connecting" || this.state === "connected";
  39869. };
  39870. return ConnectionManager;
  39871. }(dispatcher));
  39872. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39873. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39874. var channels_Channels = (function () {
  39875. function Channels() {
  39876. this.channels = {};
  39877. }
  39878. Channels.prototype.add = function (name, pusher) {
  39879. if (!this.channels[name]) {
  39880. this.channels[name] = createChannel(name, pusher);
  39881. }
  39882. return this.channels[name];
  39883. };
  39884. Channels.prototype.all = function () {
  39885. return values(this.channels);
  39886. };
  39887. Channels.prototype.find = function (name) {
  39888. return this.channels[name];
  39889. };
  39890. Channels.prototype.remove = function (name) {
  39891. var channel = this.channels[name];
  39892. delete this.channels[name];
  39893. return channel;
  39894. };
  39895. Channels.prototype.disconnect = function () {
  39896. objectApply(this.channels, function (channel) {
  39897. channel.disconnect();
  39898. });
  39899. };
  39900. return Channels;
  39901. }());
  39902. /* harmony default export */ var channels = (channels_Channels);
  39903. function createChannel(name, pusher) {
  39904. if (name.indexOf('private-encrypted-') === 0) {
  39905. if (false) { var errorMsg; }
  39906. return factory.createEncryptedChannel(name, pusher);
  39907. }
  39908. else if (name.indexOf('private-') === 0) {
  39909. return factory.createPrivateChannel(name, pusher);
  39910. }
  39911. else if (name.indexOf('presence-') === 0) {
  39912. return factory.createPresenceChannel(name, pusher);
  39913. }
  39914. else {
  39915. return factory.createChannel(name, pusher);
  39916. }
  39917. }
  39918. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39919. var Factory = {
  39920. createChannels: function () {
  39921. return new channels();
  39922. },
  39923. createConnectionManager: function (key, options) {
  39924. return new connection_manager(key, options);
  39925. },
  39926. createChannel: function (name, pusher) {
  39927. return new channels_channel(name, pusher);
  39928. },
  39929. createPrivateChannel: function (name, pusher) {
  39930. return new private_channel(name, pusher);
  39931. },
  39932. createPresenceChannel: function (name, pusher) {
  39933. return new presence_channel(name, pusher);
  39934. },
  39935. createEncryptedChannel: function (name, pusher) {
  39936. return new encrypted_channel(name, pusher);
  39937. },
  39938. createTimelineSender: function (timeline, options) {
  39939. return new timeline_sender(timeline, options);
  39940. },
  39941. createAuthorizer: function (channel, options) {
  39942. if (options.authorizer) {
  39943. return options.authorizer(channel, options);
  39944. }
  39945. return new pusher_authorizer(channel, options);
  39946. },
  39947. createHandshake: function (transport, callback) {
  39948. return new connection_handshake(transport, callback);
  39949. },
  39950. createAssistantToTheTransportManager: function (manager, transport, options) {
  39951. return new assistant_to_the_transport_manager(manager, transport, options);
  39952. }
  39953. };
  39954. /* harmony default export */ var factory = (Factory);
  39955. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  39956. var transport_manager_TransportManager = (function () {
  39957. function TransportManager(options) {
  39958. this.options = options || {};
  39959. this.livesLeft = this.options.lives || Infinity;
  39960. }
  39961. TransportManager.prototype.getAssistant = function (transport) {
  39962. return factory.createAssistantToTheTransportManager(this, transport, {
  39963. minPingDelay: this.options.minPingDelay,
  39964. maxPingDelay: this.options.maxPingDelay
  39965. });
  39966. };
  39967. TransportManager.prototype.isAlive = function () {
  39968. return this.livesLeft > 0;
  39969. };
  39970. TransportManager.prototype.reportDeath = function () {
  39971. this.livesLeft -= 1;
  39972. };
  39973. return TransportManager;
  39974. }());
  39975. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  39976. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  39977. var sequential_strategy_SequentialStrategy = (function () {
  39978. function SequentialStrategy(strategies, options) {
  39979. this.strategies = strategies;
  39980. this.loop = Boolean(options.loop);
  39981. this.failFast = Boolean(options.failFast);
  39982. this.timeout = options.timeout;
  39983. this.timeoutLimit = options.timeoutLimit;
  39984. }
  39985. SequentialStrategy.prototype.isSupported = function () {
  39986. return any(this.strategies, util.method("isSupported"));
  39987. };
  39988. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  39989. var _this = this;
  39990. var strategies = this.strategies;
  39991. var current = 0;
  39992. var timeout = this.timeout;
  39993. var runner = null;
  39994. var tryNextStrategy = function (error, handshake) {
  39995. if (handshake) {
  39996. callback(null, handshake);
  39997. }
  39998. else {
  39999. current = current + 1;
  40000. if (_this.loop) {
  40001. current = current % strategies.length;
  40002. }
  40003. if (current < strategies.length) {
  40004. if (timeout) {
  40005. timeout = timeout * 2;
  40006. if (_this.timeoutLimit) {
  40007. timeout = Math.min(timeout, _this.timeoutLimit);
  40008. }
  40009. }
  40010. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40011. }
  40012. else {
  40013. callback(true);
  40014. }
  40015. }
  40016. };
  40017. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40018. return {
  40019. abort: function () {
  40020. runner.abort();
  40021. },
  40022. forceMinPriority: function (p) {
  40023. minPriority = p;
  40024. if (runner) {
  40025. runner.forceMinPriority(p);
  40026. }
  40027. }
  40028. };
  40029. };
  40030. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40031. var timer = null;
  40032. var runner = null;
  40033. if (options.timeout > 0) {
  40034. timer = new OneOffTimer(options.timeout, function () {
  40035. runner.abort();
  40036. callback(true);
  40037. });
  40038. }
  40039. runner = strategy.connect(minPriority, function (error, handshake) {
  40040. if (error && timer && timer.isRunning() && !options.failFast) {
  40041. return;
  40042. }
  40043. if (timer) {
  40044. timer.ensureAborted();
  40045. }
  40046. callback(error, handshake);
  40047. });
  40048. return {
  40049. abort: function () {
  40050. if (timer) {
  40051. timer.ensureAborted();
  40052. }
  40053. runner.abort();
  40054. },
  40055. forceMinPriority: function (p) {
  40056. runner.forceMinPriority(p);
  40057. }
  40058. };
  40059. };
  40060. return SequentialStrategy;
  40061. }());
  40062. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40063. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40064. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40065. function BestConnectedEverStrategy(strategies) {
  40066. this.strategies = strategies;
  40067. }
  40068. BestConnectedEverStrategy.prototype.isSupported = function () {
  40069. return any(this.strategies, util.method("isSupported"));
  40070. };
  40071. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40072. return connect(this.strategies, minPriority, function (i, runners) {
  40073. return function (error, handshake) {
  40074. runners[i].error = error;
  40075. if (error) {
  40076. if (allRunnersFailed(runners)) {
  40077. callback(true);
  40078. }
  40079. return;
  40080. }
  40081. apply(runners, function (runner) {
  40082. runner.forceMinPriority(handshake.transport.priority);
  40083. });
  40084. callback(null, handshake);
  40085. };
  40086. });
  40087. };
  40088. return BestConnectedEverStrategy;
  40089. }());
  40090. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40091. function connect(strategies, minPriority, callbackBuilder) {
  40092. var runners = map(strategies, function (strategy, i, _, rs) {
  40093. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40094. });
  40095. return {
  40096. abort: function () {
  40097. apply(runners, abortRunner);
  40098. },
  40099. forceMinPriority: function (p) {
  40100. apply(runners, function (runner) {
  40101. runner.forceMinPriority(p);
  40102. });
  40103. }
  40104. };
  40105. }
  40106. function allRunnersFailed(runners) {
  40107. return collections_all(runners, function (runner) {
  40108. return Boolean(runner.error);
  40109. });
  40110. }
  40111. function abortRunner(runner) {
  40112. if (!runner.error && !runner.aborted) {
  40113. runner.abort();
  40114. runner.aborted = true;
  40115. }
  40116. }
  40117. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40118. var cached_strategy_CachedStrategy = (function () {
  40119. function CachedStrategy(strategy, transports, options) {
  40120. this.strategy = strategy;
  40121. this.transports = transports;
  40122. this.ttl = options.ttl || 1800 * 1000;
  40123. this.usingTLS = options.useTLS;
  40124. this.timeline = options.timeline;
  40125. }
  40126. CachedStrategy.prototype.isSupported = function () {
  40127. return this.strategy.isSupported();
  40128. };
  40129. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40130. var usingTLS = this.usingTLS;
  40131. var info = fetchTransportCache(usingTLS);
  40132. var strategies = [this.strategy];
  40133. if (info && info.timestamp + this.ttl >= util.now()) {
  40134. var transport = this.transports[info.transport];
  40135. if (transport) {
  40136. this.timeline.info({
  40137. cached: true,
  40138. transport: info.transport,
  40139. latency: info.latency
  40140. });
  40141. strategies.push(new sequential_strategy([transport], {
  40142. timeout: info.latency * 2 + 1000,
  40143. failFast: true
  40144. }));
  40145. }
  40146. }
  40147. var startTimestamp = util.now();
  40148. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40149. if (error) {
  40150. flushTransportCache(usingTLS);
  40151. if (strategies.length > 0) {
  40152. startTimestamp = util.now();
  40153. runner = strategies.pop().connect(minPriority, cb);
  40154. }
  40155. else {
  40156. callback(error);
  40157. }
  40158. }
  40159. else {
  40160. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40161. callback(null, handshake);
  40162. }
  40163. });
  40164. return {
  40165. abort: function () {
  40166. runner.abort();
  40167. },
  40168. forceMinPriority: function (p) {
  40169. minPriority = p;
  40170. if (runner) {
  40171. runner.forceMinPriority(p);
  40172. }
  40173. }
  40174. };
  40175. };
  40176. return CachedStrategy;
  40177. }());
  40178. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40179. function getTransportCacheKey(usingTLS) {
  40180. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40181. }
  40182. function fetchTransportCache(usingTLS) {
  40183. var storage = runtime.getLocalStorage();
  40184. if (storage) {
  40185. try {
  40186. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40187. if (serializedCache) {
  40188. return JSON.parse(serializedCache);
  40189. }
  40190. }
  40191. catch (e) {
  40192. flushTransportCache(usingTLS);
  40193. }
  40194. }
  40195. return null;
  40196. }
  40197. function storeTransportCache(usingTLS, transport, latency) {
  40198. var storage = runtime.getLocalStorage();
  40199. if (storage) {
  40200. try {
  40201. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40202. timestamp: util.now(),
  40203. transport: transport,
  40204. latency: latency
  40205. });
  40206. }
  40207. catch (e) {
  40208. }
  40209. }
  40210. }
  40211. function flushTransportCache(usingTLS) {
  40212. var storage = runtime.getLocalStorage();
  40213. if (storage) {
  40214. try {
  40215. delete storage[getTransportCacheKey(usingTLS)];
  40216. }
  40217. catch (e) {
  40218. }
  40219. }
  40220. }
  40221. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40222. var delayed_strategy_DelayedStrategy = (function () {
  40223. function DelayedStrategy(strategy, _a) {
  40224. var number = _a.delay;
  40225. this.strategy = strategy;
  40226. this.options = { delay: number };
  40227. }
  40228. DelayedStrategy.prototype.isSupported = function () {
  40229. return this.strategy.isSupported();
  40230. };
  40231. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40232. var strategy = this.strategy;
  40233. var runner;
  40234. var timer = new OneOffTimer(this.options.delay, function () {
  40235. runner = strategy.connect(minPriority, callback);
  40236. });
  40237. return {
  40238. abort: function () {
  40239. timer.ensureAborted();
  40240. if (runner) {
  40241. runner.abort();
  40242. }
  40243. },
  40244. forceMinPriority: function (p) {
  40245. minPriority = p;
  40246. if (runner) {
  40247. runner.forceMinPriority(p);
  40248. }
  40249. }
  40250. };
  40251. };
  40252. return DelayedStrategy;
  40253. }());
  40254. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40255. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40256. var IfStrategy = (function () {
  40257. function IfStrategy(test, trueBranch, falseBranch) {
  40258. this.test = test;
  40259. this.trueBranch = trueBranch;
  40260. this.falseBranch = falseBranch;
  40261. }
  40262. IfStrategy.prototype.isSupported = function () {
  40263. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40264. return branch.isSupported();
  40265. };
  40266. IfStrategy.prototype.connect = function (minPriority, callback) {
  40267. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40268. return branch.connect(minPriority, callback);
  40269. };
  40270. return IfStrategy;
  40271. }());
  40272. /* harmony default export */ var if_strategy = (IfStrategy);
  40273. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40274. var FirstConnectedStrategy = (function () {
  40275. function FirstConnectedStrategy(strategy) {
  40276. this.strategy = strategy;
  40277. }
  40278. FirstConnectedStrategy.prototype.isSupported = function () {
  40279. return this.strategy.isSupported();
  40280. };
  40281. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40282. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40283. if (handshake) {
  40284. runner.abort();
  40285. }
  40286. callback(error, handshake);
  40287. });
  40288. return runner;
  40289. };
  40290. return FirstConnectedStrategy;
  40291. }());
  40292. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40293. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40294. function testSupportsStrategy(strategy) {
  40295. return function () {
  40296. return strategy.isSupported();
  40297. };
  40298. }
  40299. var getDefaultStrategy = function (config, defineTransport) {
  40300. var definedTransports = {};
  40301. function defineTransportStrategy(name, type, priority, options, manager) {
  40302. var transport = defineTransport(config, name, type, priority, options, manager);
  40303. definedTransports[name] = transport;
  40304. return transport;
  40305. }
  40306. var ws_options = {
  40307. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40308. hostTLS: config.wsHost + ":" + config.wssPort,
  40309. httpPath: config.wsPath
  40310. };
  40311. var wss_options = extend({}, ws_options, {
  40312. useTLS: true
  40313. });
  40314. var sockjs_options = {
  40315. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40316. hostTLS: config.httpHost + ":" + config.httpsPort,
  40317. httpPath: config.httpPath
  40318. };
  40319. var timeouts = {
  40320. loop: true,
  40321. timeout: 15000,
  40322. timeoutLimit: 60000
  40323. };
  40324. var ws_manager = new transport_manager({
  40325. lives: 2,
  40326. minPingDelay: 10000,
  40327. maxPingDelay: config.activity_timeout
  40328. });
  40329. var streaming_manager = new transport_manager({
  40330. lives: 2,
  40331. minPingDelay: 10000,
  40332. maxPingDelay: config.activity_timeout
  40333. });
  40334. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40335. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40336. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40337. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40338. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40339. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40340. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40341. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40342. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40343. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40344. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40345. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40346. 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);
  40347. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40348. var wsStrategy;
  40349. if (config.useTLS) {
  40350. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40351. }
  40352. else {
  40353. wsStrategy = new best_connected_ever_strategy([
  40354. ws_loop,
  40355. new delayed_strategy(wss_loop, { delay: 2000 }),
  40356. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40357. ]);
  40358. }
  40359. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40360. ttl: 1800000,
  40361. timeline: config.timeline,
  40362. useTLS: config.useTLS
  40363. });
  40364. };
  40365. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40366. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40367. /* harmony default export */ var transport_connection_initializer = (function () {
  40368. var self = this;
  40369. self.timeline.info(self.buildTimelineMessage({
  40370. transport: self.name + (self.options.useTLS ? "s" : "")
  40371. }));
  40372. if (self.hooks.isInitialized()) {
  40373. self.changeState("initialized");
  40374. }
  40375. else if (self.hooks.file) {
  40376. self.changeState("initializing");
  40377. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40378. if (self.hooks.isInitialized()) {
  40379. self.changeState("initialized");
  40380. callback(true);
  40381. }
  40382. else {
  40383. if (error) {
  40384. self.onError(error);
  40385. }
  40386. self.onClose();
  40387. callback(false);
  40388. }
  40389. });
  40390. }
  40391. else {
  40392. self.onClose();
  40393. }
  40394. });
  40395. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40396. var http_xdomain_request_hooks = {
  40397. getRequest: function (socket) {
  40398. var xdr = new window.XDomainRequest();
  40399. xdr.ontimeout = function () {
  40400. socket.emit("error", new RequestTimedOut());
  40401. socket.close();
  40402. };
  40403. xdr.onerror = function (e) {
  40404. socket.emit("error", e);
  40405. socket.close();
  40406. };
  40407. xdr.onprogress = function () {
  40408. if (xdr.responseText && xdr.responseText.length > 0) {
  40409. socket.onChunk(200, xdr.responseText);
  40410. }
  40411. };
  40412. xdr.onload = function () {
  40413. if (xdr.responseText && xdr.responseText.length > 0) {
  40414. socket.onChunk(200, xdr.responseText);
  40415. }
  40416. socket.emit("finished", 200);
  40417. socket.close();
  40418. };
  40419. return xdr;
  40420. },
  40421. abortRequest: function (xdr) {
  40422. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40423. xdr.abort();
  40424. }
  40425. };
  40426. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40427. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40428. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40429. var extendStatics = function (d, b) {
  40430. extendStatics = Object.setPrototypeOf ||
  40431. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40432. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40433. return extendStatics(d, b);
  40434. };
  40435. return function (d, b) {
  40436. extendStatics(d, b);
  40437. function __() { this.constructor = d; }
  40438. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40439. };
  40440. })();
  40441. var MAX_BUFFER_LENGTH = 256 * 1024;
  40442. var http_request_HTTPRequest = (function (_super) {
  40443. http_request_extends(HTTPRequest, _super);
  40444. function HTTPRequest(hooks, method, url) {
  40445. var _this = _super.call(this) || this;
  40446. _this.hooks = hooks;
  40447. _this.method = method;
  40448. _this.url = url;
  40449. return _this;
  40450. }
  40451. HTTPRequest.prototype.start = function (payload) {
  40452. var _this = this;
  40453. this.position = 0;
  40454. this.xhr = this.hooks.getRequest(this);
  40455. this.unloader = function () {
  40456. _this.close();
  40457. };
  40458. runtime.addUnloadListener(this.unloader);
  40459. this.xhr.open(this.method, this.url, true);
  40460. if (this.xhr.setRequestHeader) {
  40461. this.xhr.setRequestHeader("Content-Type", "application/json");
  40462. }
  40463. this.xhr.send(payload);
  40464. };
  40465. HTTPRequest.prototype.close = function () {
  40466. if (this.unloader) {
  40467. runtime.removeUnloadListener(this.unloader);
  40468. this.unloader = null;
  40469. }
  40470. if (this.xhr) {
  40471. this.hooks.abortRequest(this.xhr);
  40472. this.xhr = null;
  40473. }
  40474. };
  40475. HTTPRequest.prototype.onChunk = function (status, data) {
  40476. while (true) {
  40477. var chunk = this.advanceBuffer(data);
  40478. if (chunk) {
  40479. this.emit("chunk", { status: status, data: chunk });
  40480. }
  40481. else {
  40482. break;
  40483. }
  40484. }
  40485. if (this.isBufferTooLong(data)) {
  40486. this.emit("buffer_too_long");
  40487. }
  40488. };
  40489. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40490. var unreadData = buffer.slice(this.position);
  40491. var endOfLinePosition = unreadData.indexOf("\n");
  40492. if (endOfLinePosition !== -1) {
  40493. this.position += endOfLinePosition + 1;
  40494. return unreadData.slice(0, endOfLinePosition);
  40495. }
  40496. else {
  40497. return null;
  40498. }
  40499. };
  40500. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40501. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40502. };
  40503. return HTTPRequest;
  40504. }(dispatcher));
  40505. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40506. // CONCATENATED MODULE: ./src/core/http/state.ts
  40507. var State;
  40508. (function (State) {
  40509. State[State["CONNECTING"] = 0] = "CONNECTING";
  40510. State[State["OPEN"] = 1] = "OPEN";
  40511. State[State["CLOSED"] = 3] = "CLOSED";
  40512. })(State || (State = {}));
  40513. /* harmony default export */ var state = (State);
  40514. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40515. var autoIncrement = 1;
  40516. var http_socket_HTTPSocket = (function () {
  40517. function HTTPSocket(hooks, url) {
  40518. this.hooks = hooks;
  40519. this.session = randomNumber(1000) + "/" + randomString(8);
  40520. this.location = getLocation(url);
  40521. this.readyState = state.CONNECTING;
  40522. this.openStream();
  40523. }
  40524. HTTPSocket.prototype.send = function (payload) {
  40525. return this.sendRaw(JSON.stringify([payload]));
  40526. };
  40527. HTTPSocket.prototype.ping = function () {
  40528. this.hooks.sendHeartbeat(this);
  40529. };
  40530. HTTPSocket.prototype.close = function (code, reason) {
  40531. this.onClose(code, reason, true);
  40532. };
  40533. HTTPSocket.prototype.sendRaw = function (payload) {
  40534. if (this.readyState === state.OPEN) {
  40535. try {
  40536. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40537. return true;
  40538. }
  40539. catch (e) {
  40540. return false;
  40541. }
  40542. }
  40543. else {
  40544. return false;
  40545. }
  40546. };
  40547. HTTPSocket.prototype.reconnect = function () {
  40548. this.closeStream();
  40549. this.openStream();
  40550. };
  40551. ;
  40552. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40553. this.closeStream();
  40554. this.readyState = state.CLOSED;
  40555. if (this.onclose) {
  40556. this.onclose({
  40557. code: code,
  40558. reason: reason,
  40559. wasClean: wasClean
  40560. });
  40561. }
  40562. };
  40563. HTTPSocket.prototype.onChunk = function (chunk) {
  40564. if (chunk.status !== 200) {
  40565. return;
  40566. }
  40567. if (this.readyState === state.OPEN) {
  40568. this.onActivity();
  40569. }
  40570. var payload;
  40571. var type = chunk.data.slice(0, 1);
  40572. switch (type) {
  40573. case 'o':
  40574. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40575. this.onOpen(payload);
  40576. break;
  40577. case 'a':
  40578. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40579. for (var i = 0; i < payload.length; i++) {
  40580. this.onEvent(payload[i]);
  40581. }
  40582. break;
  40583. case 'm':
  40584. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40585. this.onEvent(payload);
  40586. break;
  40587. case 'h':
  40588. this.hooks.onHeartbeat(this);
  40589. break;
  40590. case 'c':
  40591. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40592. this.onClose(payload[0], payload[1], true);
  40593. break;
  40594. }
  40595. };
  40596. HTTPSocket.prototype.onOpen = function (options) {
  40597. if (this.readyState === state.CONNECTING) {
  40598. if (options && options.hostname) {
  40599. this.location.base = replaceHost(this.location.base, options.hostname);
  40600. }
  40601. this.readyState = state.OPEN;
  40602. if (this.onopen) {
  40603. this.onopen();
  40604. }
  40605. }
  40606. else {
  40607. this.onClose(1006, "Server lost session", true);
  40608. }
  40609. };
  40610. HTTPSocket.prototype.onEvent = function (event) {
  40611. if (this.readyState === state.OPEN && this.onmessage) {
  40612. this.onmessage({ data: event });
  40613. }
  40614. };
  40615. HTTPSocket.prototype.onActivity = function () {
  40616. if (this.onactivity) {
  40617. this.onactivity();
  40618. }
  40619. };
  40620. HTTPSocket.prototype.onError = function (error) {
  40621. if (this.onerror) {
  40622. this.onerror(error);
  40623. }
  40624. };
  40625. HTTPSocket.prototype.openStream = function () {
  40626. var _this = this;
  40627. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40628. this.stream.bind("chunk", function (chunk) {
  40629. _this.onChunk(chunk);
  40630. });
  40631. this.stream.bind("finished", function (status) {
  40632. _this.hooks.onFinished(_this, status);
  40633. });
  40634. this.stream.bind("buffer_too_long", function () {
  40635. _this.reconnect();
  40636. });
  40637. try {
  40638. this.stream.start();
  40639. }
  40640. catch (error) {
  40641. util.defer(function () {
  40642. _this.onError(error);
  40643. _this.onClose(1006, "Could not start streaming", false);
  40644. });
  40645. }
  40646. };
  40647. HTTPSocket.prototype.closeStream = function () {
  40648. if (this.stream) {
  40649. this.stream.unbind_all();
  40650. this.stream.close();
  40651. this.stream = null;
  40652. }
  40653. };
  40654. return HTTPSocket;
  40655. }());
  40656. function getLocation(url) {
  40657. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40658. return {
  40659. base: parts[1],
  40660. queryString: parts[2]
  40661. };
  40662. }
  40663. function getSendURL(url, session) {
  40664. return url.base + "/" + session + "/xhr_send";
  40665. }
  40666. function getUniqueURL(url) {
  40667. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40668. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40669. }
  40670. function replaceHost(url, hostname) {
  40671. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40672. return urlParts[1] + hostname + urlParts[3];
  40673. }
  40674. function randomNumber(max) {
  40675. return Math.floor(Math.random() * max);
  40676. }
  40677. function randomString(length) {
  40678. var result = [];
  40679. for (var i = 0; i < length; i++) {
  40680. result.push(randomNumber(32).toString(32));
  40681. }
  40682. return result.join('');
  40683. }
  40684. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40685. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40686. var http_streaming_socket_hooks = {
  40687. getReceiveURL: function (url, session) {
  40688. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40689. },
  40690. onHeartbeat: function (socket) {
  40691. socket.sendRaw("[]");
  40692. },
  40693. sendHeartbeat: function (socket) {
  40694. socket.sendRaw("[]");
  40695. },
  40696. onFinished: function (socket, status) {
  40697. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40698. }
  40699. };
  40700. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40701. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40702. var http_polling_socket_hooks = {
  40703. getReceiveURL: function (url, session) {
  40704. return url.base + "/" + session + "/xhr" + url.queryString;
  40705. },
  40706. onHeartbeat: function () {
  40707. },
  40708. sendHeartbeat: function (socket) {
  40709. socket.sendRaw("[]");
  40710. },
  40711. onFinished: function (socket, status) {
  40712. if (status === 200) {
  40713. socket.reconnect();
  40714. }
  40715. else {
  40716. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40717. }
  40718. }
  40719. };
  40720. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40721. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40722. var http_xhr_request_hooks = {
  40723. getRequest: function (socket) {
  40724. var Constructor = runtime.getXHRAPI();
  40725. var xhr = new Constructor();
  40726. xhr.onreadystatechange = xhr.onprogress = function () {
  40727. switch (xhr.readyState) {
  40728. case 3:
  40729. if (xhr.responseText && xhr.responseText.length > 0) {
  40730. socket.onChunk(xhr.status, xhr.responseText);
  40731. }
  40732. break;
  40733. case 4:
  40734. if (xhr.responseText && xhr.responseText.length > 0) {
  40735. socket.onChunk(xhr.status, xhr.responseText);
  40736. }
  40737. socket.emit("finished", xhr.status);
  40738. socket.close();
  40739. break;
  40740. }
  40741. };
  40742. return xhr;
  40743. },
  40744. abortRequest: function (xhr) {
  40745. xhr.onreadystatechange = null;
  40746. xhr.abort();
  40747. }
  40748. };
  40749. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40750. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40751. var HTTP = {
  40752. createStreamingSocket: function (url) {
  40753. return this.createSocket(http_streaming_socket, url);
  40754. },
  40755. createPollingSocket: function (url) {
  40756. return this.createSocket(http_polling_socket, url);
  40757. },
  40758. createSocket: function (hooks, url) {
  40759. return new http_socket(hooks, url);
  40760. },
  40761. createXHR: function (method, url) {
  40762. return this.createRequest(http_xhr_request, method, url);
  40763. },
  40764. createRequest: function (hooks, method, url) {
  40765. return new http_request(hooks, method, url);
  40766. }
  40767. };
  40768. /* harmony default export */ var http_http = (HTTP);
  40769. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40770. http_http.createXDR = function (method, url) {
  40771. return this.createRequest(http_xdomain_request, method, url);
  40772. };
  40773. /* harmony default export */ var web_http_http = (http_http);
  40774. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40775. var Runtime = {
  40776. nextAuthCallbackID: 1,
  40777. auth_callbacks: {},
  40778. ScriptReceivers: ScriptReceivers,
  40779. DependenciesReceivers: DependenciesReceivers,
  40780. getDefaultStrategy: default_strategy,
  40781. Transports: transports_transports,
  40782. transportConnectionInitializer: transport_connection_initializer,
  40783. HTTPFactory: web_http_http,
  40784. TimelineTransport: jsonp_timeline,
  40785. getXHRAPI: function () {
  40786. return window.XMLHttpRequest;
  40787. },
  40788. getWebSocketAPI: function () {
  40789. return window.WebSocket || window.MozWebSocket;
  40790. },
  40791. setup: function (PusherClass) {
  40792. var _this = this;
  40793. window.Pusher = PusherClass;
  40794. var initializeOnDocumentBody = function () {
  40795. _this.onDocumentBody(PusherClass.ready);
  40796. };
  40797. if (!window.JSON) {
  40798. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40799. }
  40800. else {
  40801. initializeOnDocumentBody();
  40802. }
  40803. },
  40804. getDocument: function () {
  40805. return document;
  40806. },
  40807. getProtocol: function () {
  40808. return this.getDocument().location.protocol;
  40809. },
  40810. getAuthorizers: function () {
  40811. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40812. },
  40813. onDocumentBody: function (callback) {
  40814. var _this = this;
  40815. if (document.body) {
  40816. callback();
  40817. }
  40818. else {
  40819. setTimeout(function () {
  40820. _this.onDocumentBody(callback);
  40821. }, 0);
  40822. }
  40823. },
  40824. createJSONPRequest: function (url, data) {
  40825. return new jsonp_request(url, data);
  40826. },
  40827. createScriptRequest: function (src) {
  40828. return new script_request(src);
  40829. },
  40830. getLocalStorage: function () {
  40831. try {
  40832. return window.localStorage;
  40833. }
  40834. catch (e) {
  40835. return undefined;
  40836. }
  40837. },
  40838. createXHR: function () {
  40839. if (this.getXHRAPI()) {
  40840. return this.createXMLHttpRequest();
  40841. }
  40842. else {
  40843. return this.createMicrosoftXHR();
  40844. }
  40845. },
  40846. createXMLHttpRequest: function () {
  40847. var Constructor = this.getXHRAPI();
  40848. return new Constructor();
  40849. },
  40850. createMicrosoftXHR: function () {
  40851. return new ActiveXObject("Microsoft.XMLHTTP");
  40852. },
  40853. getNetwork: function () {
  40854. return net_info_Network;
  40855. },
  40856. createWebSocket: function (url) {
  40857. var Constructor = this.getWebSocketAPI();
  40858. return new Constructor(url);
  40859. },
  40860. createSocketRequest: function (method, url) {
  40861. if (this.isXHRSupported()) {
  40862. return this.HTTPFactory.createXHR(method, url);
  40863. }
  40864. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40865. return this.HTTPFactory.createXDR(method, url);
  40866. }
  40867. else {
  40868. throw "Cross-origin HTTP requests are not supported";
  40869. }
  40870. },
  40871. isXHRSupported: function () {
  40872. var Constructor = this.getXHRAPI();
  40873. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40874. },
  40875. isXDRSupported: function (useTLS) {
  40876. var protocol = useTLS ? "https:" : "http:";
  40877. var documentProtocol = this.getProtocol();
  40878. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40879. },
  40880. addUnloadListener: function (listener) {
  40881. if (window.addEventListener !== undefined) {
  40882. window.addEventListener("unload", listener, false);
  40883. }
  40884. else if (window.attachEvent !== undefined) {
  40885. window.attachEvent("onunload", listener);
  40886. }
  40887. },
  40888. removeUnloadListener: function (listener) {
  40889. if (window.addEventListener !== undefined) {
  40890. window.removeEventListener("unload", listener, false);
  40891. }
  40892. else if (window.detachEvent !== undefined) {
  40893. window.detachEvent("onunload", listener);
  40894. }
  40895. }
  40896. };
  40897. /* harmony default export */ var runtime = (Runtime);
  40898. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40899. var TimelineLevel;
  40900. (function (TimelineLevel) {
  40901. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40902. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40903. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40904. })(TimelineLevel || (TimelineLevel = {}));
  40905. /* harmony default export */ var timeline_level = (TimelineLevel);
  40906. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40907. var timeline_Timeline = (function () {
  40908. function Timeline(key, session, options) {
  40909. this.key = key;
  40910. this.session = session;
  40911. this.events = [];
  40912. this.options = options || {};
  40913. this.sent = 0;
  40914. this.uniqueID = 0;
  40915. }
  40916. Timeline.prototype.log = function (level, event) {
  40917. if (level <= this.options.level) {
  40918. this.events.push(extend({}, event, { timestamp: util.now() }));
  40919. if (this.options.limit && this.events.length > this.options.limit) {
  40920. this.events.shift();
  40921. }
  40922. }
  40923. };
  40924. Timeline.prototype.error = function (event) {
  40925. this.log(timeline_level.ERROR, event);
  40926. };
  40927. Timeline.prototype.info = function (event) {
  40928. this.log(timeline_level.INFO, event);
  40929. };
  40930. Timeline.prototype.debug = function (event) {
  40931. this.log(timeline_level.DEBUG, event);
  40932. };
  40933. Timeline.prototype.isEmpty = function () {
  40934. return this.events.length === 0;
  40935. };
  40936. Timeline.prototype.send = function (sendfn, callback) {
  40937. var _this = this;
  40938. var data = extend({
  40939. session: this.session,
  40940. bundle: this.sent + 1,
  40941. key: this.key,
  40942. lib: "js",
  40943. version: this.options.version,
  40944. cluster: this.options.cluster,
  40945. features: this.options.features,
  40946. timeline: this.events
  40947. }, this.options.params);
  40948. this.events = [];
  40949. sendfn(data, function (error, result) {
  40950. if (!error) {
  40951. _this.sent++;
  40952. }
  40953. if (callback) {
  40954. callback(error, result);
  40955. }
  40956. });
  40957. return true;
  40958. };
  40959. Timeline.prototype.generateUniqueID = function () {
  40960. this.uniqueID++;
  40961. return this.uniqueID;
  40962. };
  40963. return Timeline;
  40964. }());
  40965. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  40966. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  40967. var transport_strategy_TransportStrategy = (function () {
  40968. function TransportStrategy(name, priority, transport, options) {
  40969. this.name = name;
  40970. this.priority = priority;
  40971. this.transport = transport;
  40972. this.options = options || {};
  40973. }
  40974. TransportStrategy.prototype.isSupported = function () {
  40975. return this.transport.isSupported({
  40976. useTLS: this.options.useTLS
  40977. });
  40978. };
  40979. TransportStrategy.prototype.connect = function (minPriority, callback) {
  40980. var _this = this;
  40981. if (!this.isSupported()) {
  40982. return failAttempt(new UnsupportedStrategy(), callback);
  40983. }
  40984. else if (this.priority < minPriority) {
  40985. return failAttempt(new TransportPriorityTooLow(), callback);
  40986. }
  40987. var connected = false;
  40988. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  40989. var handshake = null;
  40990. var onInitialized = function () {
  40991. transport.unbind("initialized", onInitialized);
  40992. transport.connect();
  40993. };
  40994. var onOpen = function () {
  40995. handshake = factory.createHandshake(transport, function (result) {
  40996. connected = true;
  40997. unbindListeners();
  40998. callback(null, result);
  40999. });
  41000. };
  41001. var onError = function (error) {
  41002. unbindListeners();
  41003. callback(error);
  41004. };
  41005. var onClosed = function () {
  41006. unbindListeners();
  41007. var serializedTransport;
  41008. serializedTransport = safeJSONStringify(transport);
  41009. callback(new TransportClosed(serializedTransport));
  41010. };
  41011. var unbindListeners = function () {
  41012. transport.unbind("initialized", onInitialized);
  41013. transport.unbind("open", onOpen);
  41014. transport.unbind("error", onError);
  41015. transport.unbind("closed", onClosed);
  41016. };
  41017. transport.bind("initialized", onInitialized);
  41018. transport.bind("open", onOpen);
  41019. transport.bind("error", onError);
  41020. transport.bind("closed", onClosed);
  41021. transport.initialize();
  41022. return {
  41023. abort: function () {
  41024. if (connected) {
  41025. return;
  41026. }
  41027. unbindListeners();
  41028. if (handshake) {
  41029. handshake.close();
  41030. }
  41031. else {
  41032. transport.close();
  41033. }
  41034. },
  41035. forceMinPriority: function (p) {
  41036. if (connected) {
  41037. return;
  41038. }
  41039. if (_this.priority < p) {
  41040. if (handshake) {
  41041. handshake.close();
  41042. }
  41043. else {
  41044. transport.close();
  41045. }
  41046. }
  41047. }
  41048. };
  41049. };
  41050. return TransportStrategy;
  41051. }());
  41052. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41053. function failAttempt(error, callback) {
  41054. util.defer(function () {
  41055. callback(error);
  41056. });
  41057. return {
  41058. abort: function () { },
  41059. forceMinPriority: function () { }
  41060. };
  41061. }
  41062. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41063. var strategy_builder_Transports = runtime.Transports;
  41064. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41065. var transportClass = strategy_builder_Transports[type];
  41066. if (!transportClass) {
  41067. throw new UnsupportedTransport(type);
  41068. }
  41069. var enabled = (!config.enabledTransports ||
  41070. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41071. (!config.disabledTransports ||
  41072. arrayIndexOf(config.disabledTransports, name) === -1);
  41073. var transport;
  41074. if (enabled) {
  41075. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41076. key: config.key,
  41077. useTLS: config.useTLS,
  41078. timeline: config.timeline,
  41079. ignoreNullOrigin: config.ignoreNullOrigin
  41080. }, options));
  41081. }
  41082. else {
  41083. transport = strategy_builder_UnsupportedStrategy;
  41084. }
  41085. return transport;
  41086. };
  41087. var strategy_builder_UnsupportedStrategy = {
  41088. isSupported: function () {
  41089. return false;
  41090. },
  41091. connect: function (_, callback) {
  41092. var deferred = util.defer(function () {
  41093. callback(new UnsupportedStrategy());
  41094. });
  41095. return {
  41096. abort: function () {
  41097. deferred.ensureAborted();
  41098. },
  41099. forceMinPriority: function () { }
  41100. };
  41101. }
  41102. };
  41103. // CONCATENATED MODULE: ./src/core/config.ts
  41104. var getGlobalConfig = function () {
  41105. return {
  41106. wsHost: defaults.host,
  41107. wsPort: defaults.ws_port,
  41108. wssPort: defaults.wss_port,
  41109. wsPath: defaults.ws_path,
  41110. httpHost: defaults.sockjs_host,
  41111. httpPort: defaults.sockjs_http_port,
  41112. httpsPort: defaults.sockjs_https_port,
  41113. httpPath: defaults.sockjs_path,
  41114. statsHost: defaults.stats_host,
  41115. authEndpoint: defaults.channel_auth_endpoint,
  41116. authTransport: defaults.channel_auth_transport,
  41117. activity_timeout: defaults.activity_timeout,
  41118. pong_timeout: defaults.pong_timeout,
  41119. unavailable_timeout: defaults.unavailable_timeout
  41120. };
  41121. };
  41122. var getClusterConfig = function (clusterName) {
  41123. return {
  41124. wsHost: 'ws-' + clusterName + '.pusher.com',
  41125. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41126. };
  41127. };
  41128. // CONCATENATED MODULE: ./src/core/pusher.ts
  41129. var pusher_Pusher = (function () {
  41130. function Pusher(app_key, options) {
  41131. var _this = this;
  41132. checkAppKey(app_key);
  41133. options = options || {};
  41134. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41135. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41136. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41137. }
  41138. this.key = app_key;
  41139. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41140. this.channels = factory.createChannels();
  41141. this.global_emitter = new dispatcher();
  41142. this.sessionID = Math.floor(Math.random() * 1000000000);
  41143. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41144. cluster: this.config.cluster,
  41145. features: Pusher.getClientFeatures(),
  41146. params: this.config.timelineParams || {},
  41147. limit: 50,
  41148. level: timeline_level.INFO,
  41149. version: defaults.VERSION
  41150. });
  41151. if (!this.config.disableStats) {
  41152. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41153. host: this.config.statsHost,
  41154. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41155. });
  41156. }
  41157. var getStrategy = function (options) {
  41158. var config = extend({}, _this.config, options);
  41159. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41160. };
  41161. this.connection = factory.createConnectionManager(this.key, extend({
  41162. getStrategy: getStrategy,
  41163. timeline: this.timeline,
  41164. activityTimeout: this.config.activity_timeout,
  41165. pongTimeout: this.config.pong_timeout,
  41166. unavailableTimeout: this.config.unavailable_timeout
  41167. }, this.config, { useTLS: this.shouldUseTLS() }));
  41168. this.connection.bind('connected', function () {
  41169. _this.subscribeAll();
  41170. if (_this.timelineSender) {
  41171. _this.timelineSender.send(_this.connection.isUsingTLS());
  41172. }
  41173. });
  41174. this.connection.bind('message', function (event) {
  41175. var eventName = event.event;
  41176. var internal = eventName.indexOf('pusher_internal:') === 0;
  41177. if (event.channel) {
  41178. var channel = _this.channel(event.channel);
  41179. if (channel) {
  41180. channel.handleEvent(event);
  41181. }
  41182. }
  41183. if (!internal) {
  41184. _this.global_emitter.emit(event.event, event.data);
  41185. }
  41186. });
  41187. this.connection.bind('connecting', function () {
  41188. _this.channels.disconnect();
  41189. });
  41190. this.connection.bind('disconnected', function () {
  41191. _this.channels.disconnect();
  41192. });
  41193. this.connection.bind('error', function (err) {
  41194. logger.warn(err);
  41195. });
  41196. Pusher.instances.push(this);
  41197. this.timeline.info({ instances: Pusher.instances.length });
  41198. if (Pusher.isReady) {
  41199. this.connect();
  41200. }
  41201. }
  41202. Pusher.ready = function () {
  41203. Pusher.isReady = true;
  41204. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41205. Pusher.instances[i].connect();
  41206. }
  41207. };
  41208. Pusher.getClientFeatures = function () {
  41209. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41210. return t.isSupported({});
  41211. }));
  41212. };
  41213. Pusher.prototype.channel = function (name) {
  41214. return this.channels.find(name);
  41215. };
  41216. Pusher.prototype.allChannels = function () {
  41217. return this.channels.all();
  41218. };
  41219. Pusher.prototype.connect = function () {
  41220. this.connection.connect();
  41221. if (this.timelineSender) {
  41222. if (!this.timelineSenderTimer) {
  41223. var usingTLS = this.connection.isUsingTLS();
  41224. var timelineSender = this.timelineSender;
  41225. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41226. timelineSender.send(usingTLS);
  41227. });
  41228. }
  41229. }
  41230. };
  41231. Pusher.prototype.disconnect = function () {
  41232. this.connection.disconnect();
  41233. if (this.timelineSenderTimer) {
  41234. this.timelineSenderTimer.ensureAborted();
  41235. this.timelineSenderTimer = null;
  41236. }
  41237. };
  41238. Pusher.prototype.bind = function (event_name, callback, context) {
  41239. this.global_emitter.bind(event_name, callback, context);
  41240. return this;
  41241. };
  41242. Pusher.prototype.unbind = function (event_name, callback, context) {
  41243. this.global_emitter.unbind(event_name, callback, context);
  41244. return this;
  41245. };
  41246. Pusher.prototype.bind_global = function (callback) {
  41247. this.global_emitter.bind_global(callback);
  41248. return this;
  41249. };
  41250. Pusher.prototype.unbind_global = function (callback) {
  41251. this.global_emitter.unbind_global(callback);
  41252. return this;
  41253. };
  41254. Pusher.prototype.unbind_all = function (callback) {
  41255. this.global_emitter.unbind_all();
  41256. return this;
  41257. };
  41258. Pusher.prototype.subscribeAll = function () {
  41259. var channelName;
  41260. for (channelName in this.channels.channels) {
  41261. if (this.channels.channels.hasOwnProperty(channelName)) {
  41262. this.subscribe(channelName);
  41263. }
  41264. }
  41265. };
  41266. Pusher.prototype.subscribe = function (channel_name) {
  41267. var channel = this.channels.add(channel_name, this);
  41268. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41269. channel.reinstateSubscription();
  41270. }
  41271. else if (!channel.subscriptionPending &&
  41272. this.connection.state === 'connected') {
  41273. channel.subscribe();
  41274. }
  41275. return channel;
  41276. };
  41277. Pusher.prototype.unsubscribe = function (channel_name) {
  41278. var channel = this.channels.find(channel_name);
  41279. if (channel && channel.subscriptionPending) {
  41280. channel.cancelSubscription();
  41281. }
  41282. else {
  41283. channel = this.channels.remove(channel_name);
  41284. if (channel && this.connection.state === 'connected') {
  41285. channel.unsubscribe();
  41286. }
  41287. }
  41288. };
  41289. Pusher.prototype.send_event = function (event_name, data, channel) {
  41290. return this.connection.send_event(event_name, data, channel);
  41291. };
  41292. Pusher.prototype.shouldUseTLS = function () {
  41293. if (runtime.getProtocol() === 'https:') {
  41294. return true;
  41295. }
  41296. else if (this.config.forceTLS === true) {
  41297. return true;
  41298. }
  41299. else {
  41300. return Boolean(this.config.encrypted);
  41301. }
  41302. };
  41303. Pusher.instances = [];
  41304. Pusher.isReady = false;
  41305. Pusher.logToConsole = false;
  41306. Pusher.Runtime = runtime;
  41307. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41308. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41309. Pusher.auth_callbacks = runtime.auth_callbacks;
  41310. return Pusher;
  41311. }());
  41312. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41313. function checkAppKey(key) {
  41314. if (key === null || key === undefined) {
  41315. throw 'You must pass your app key when you instantiate Pusher.';
  41316. }
  41317. }
  41318. runtime.setup(pusher_Pusher);
  41319. /***/ })
  41320. /******/ ]);
  41321. });
  41322. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41323. /***/ }),
  41324. /***/ "./node_modules/setimmediate/setImmediate.js":
  41325. /*!***************************************************!*\
  41326. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41327. \***************************************************/
  41328. /*! no static exports found */
  41329. /***/ (function(module, exports, __webpack_require__) {
  41330. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41331. "use strict";
  41332. if (global.setImmediate) {
  41333. return;
  41334. }
  41335. var nextHandle = 1; // Spec says greater than zero
  41336. var tasksByHandle = {};
  41337. var currentlyRunningATask = false;
  41338. var doc = global.document;
  41339. var registerImmediate;
  41340. function setImmediate(callback) {
  41341. // Callback can either be a function or a string
  41342. if (typeof callback !== "function") {
  41343. callback = new Function("" + callback);
  41344. }
  41345. // Copy function arguments
  41346. var args = new Array(arguments.length - 1);
  41347. for (var i = 0; i < args.length; i++) {
  41348. args[i] = arguments[i + 1];
  41349. }
  41350. // Store and register the task
  41351. var task = { callback: callback, args: args };
  41352. tasksByHandle[nextHandle] = task;
  41353. registerImmediate(nextHandle);
  41354. return nextHandle++;
  41355. }
  41356. function clearImmediate(handle) {
  41357. delete tasksByHandle[handle];
  41358. }
  41359. function run(task) {
  41360. var callback = task.callback;
  41361. var args = task.args;
  41362. switch (args.length) {
  41363. case 0:
  41364. callback();
  41365. break;
  41366. case 1:
  41367. callback(args[0]);
  41368. break;
  41369. case 2:
  41370. callback(args[0], args[1]);
  41371. break;
  41372. case 3:
  41373. callback(args[0], args[1], args[2]);
  41374. break;
  41375. default:
  41376. callback.apply(undefined, args);
  41377. break;
  41378. }
  41379. }
  41380. function runIfPresent(handle) {
  41381. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41382. // So if we're currently running a task, we'll need to delay this invocation.
  41383. if (currentlyRunningATask) {
  41384. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41385. // "too much recursion" error.
  41386. setTimeout(runIfPresent, 0, handle);
  41387. } else {
  41388. var task = tasksByHandle[handle];
  41389. if (task) {
  41390. currentlyRunningATask = true;
  41391. try {
  41392. run(task);
  41393. } finally {
  41394. clearImmediate(handle);
  41395. currentlyRunningATask = false;
  41396. }
  41397. }
  41398. }
  41399. }
  41400. function installNextTickImplementation() {
  41401. registerImmediate = function(handle) {
  41402. process.nextTick(function () { runIfPresent(handle); });
  41403. };
  41404. }
  41405. function canUsePostMessage() {
  41406. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41407. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41408. if (global.postMessage && !global.importScripts) {
  41409. var postMessageIsAsynchronous = true;
  41410. var oldOnMessage = global.onmessage;
  41411. global.onmessage = function() {
  41412. postMessageIsAsynchronous = false;
  41413. };
  41414. global.postMessage("", "*");
  41415. global.onmessage = oldOnMessage;
  41416. return postMessageIsAsynchronous;
  41417. }
  41418. }
  41419. function installPostMessageImplementation() {
  41420. // Installs an event handler on `global` for the `message` event: see
  41421. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41422. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41423. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41424. var onGlobalMessage = function(event) {
  41425. if (event.source === global &&
  41426. typeof event.data === "string" &&
  41427. event.data.indexOf(messagePrefix) === 0) {
  41428. runIfPresent(+event.data.slice(messagePrefix.length));
  41429. }
  41430. };
  41431. if (global.addEventListener) {
  41432. global.addEventListener("message", onGlobalMessage, false);
  41433. } else {
  41434. global.attachEvent("onmessage", onGlobalMessage);
  41435. }
  41436. registerImmediate = function(handle) {
  41437. global.postMessage(messagePrefix + handle, "*");
  41438. };
  41439. }
  41440. function installMessageChannelImplementation() {
  41441. var channel = new MessageChannel();
  41442. channel.port1.onmessage = function(event) {
  41443. var handle = event.data;
  41444. runIfPresent(handle);
  41445. };
  41446. registerImmediate = function(handle) {
  41447. channel.port2.postMessage(handle);
  41448. };
  41449. }
  41450. function installReadyStateChangeImplementation() {
  41451. var html = doc.documentElement;
  41452. registerImmediate = function(handle) {
  41453. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41454. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41455. var script = doc.createElement("script");
  41456. script.onreadystatechange = function () {
  41457. runIfPresent(handle);
  41458. script.onreadystatechange = null;
  41459. html.removeChild(script);
  41460. script = null;
  41461. };
  41462. html.appendChild(script);
  41463. };
  41464. }
  41465. function installSetTimeoutImplementation() {
  41466. registerImmediate = function(handle) {
  41467. setTimeout(runIfPresent, 0, handle);
  41468. };
  41469. }
  41470. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41471. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41472. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41473. // Don't get fooled by e.g. browserify environments.
  41474. if ({}.toString.call(global.process) === "[object process]") {
  41475. // For Node.js before 0.9
  41476. installNextTickImplementation();
  41477. } else if (canUsePostMessage()) {
  41478. // For non-IE10 modern browsers
  41479. installPostMessageImplementation();
  41480. } else if (global.MessageChannel) {
  41481. // For web workers, where supported
  41482. installMessageChannelImplementation();
  41483. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41484. // For IE 6–8
  41485. installReadyStateChangeImplementation();
  41486. } else {
  41487. // For older browsers
  41488. installSetTimeoutImplementation();
  41489. }
  41490. attachTo.setImmediate = setImmediate;
  41491. attachTo.clearImmediate = clearImmediate;
  41492. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41493. /* 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")))
  41494. /***/ }),
  41495. /***/ "./node_modules/timers-browserify/main.js":
  41496. /*!************************************************!*\
  41497. !*** ./node_modules/timers-browserify/main.js ***!
  41498. \************************************************/
  41499. /*! no static exports found */
  41500. /***/ (function(module, exports, __webpack_require__) {
  41501. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41502. (typeof self !== "undefined" && self) ||
  41503. window;
  41504. var apply = Function.prototype.apply;
  41505. // DOM APIs, for completeness
  41506. exports.setTimeout = function() {
  41507. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41508. };
  41509. exports.setInterval = function() {
  41510. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41511. };
  41512. exports.clearTimeout =
  41513. exports.clearInterval = function(timeout) {
  41514. if (timeout) {
  41515. timeout.close();
  41516. }
  41517. };
  41518. function Timeout(id, clearFn) {
  41519. this._id = id;
  41520. this._clearFn = clearFn;
  41521. }
  41522. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41523. Timeout.prototype.close = function() {
  41524. this._clearFn.call(scope, this._id);
  41525. };
  41526. // Does not start the time, just sets up the members needed.
  41527. exports.enroll = function(item, msecs) {
  41528. clearTimeout(item._idleTimeoutId);
  41529. item._idleTimeout = msecs;
  41530. };
  41531. exports.unenroll = function(item) {
  41532. clearTimeout(item._idleTimeoutId);
  41533. item._idleTimeout = -1;
  41534. };
  41535. exports._unrefActive = exports.active = function(item) {
  41536. clearTimeout(item._idleTimeoutId);
  41537. var msecs = item._idleTimeout;
  41538. if (msecs >= 0) {
  41539. item._idleTimeoutId = setTimeout(function onTimeout() {
  41540. if (item._onTimeout)
  41541. item._onTimeout();
  41542. }, msecs);
  41543. }
  41544. };
  41545. // setimmediate attaches itself to the global object
  41546. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41547. // On some exotic environments, it's not clear which object `setimmediate` was
  41548. // able to install onto. Search each possibility in the same order as the
  41549. // `setimmediate` library.
  41550. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41551. (typeof global !== "undefined" && global.setImmediate) ||
  41552. (this && this.setImmediate);
  41553. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41554. (typeof global !== "undefined" && global.clearImmediate) ||
  41555. (this && this.clearImmediate);
  41556. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41557. /***/ }),
  41558. /***/ "./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&":
  41559. /*!*******************************************************************************************************************************************************************************************************************!*\
  41560. !*** ./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& ***!
  41561. \*******************************************************************************************************************************************************************************************************************/
  41562. /*! exports provided: render, staticRenderFns */
  41563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41564. "use strict";
  41565. __webpack_require__.r(__webpack_exports__);
  41566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41568. var render = function() {
  41569. var _vm = this
  41570. var _h = _vm.$createElement
  41571. var _c = _vm._self._c || _h
  41572. return _vm._m(0)
  41573. }
  41574. var staticRenderFns = [
  41575. function() {
  41576. var _vm = this
  41577. var _h = _vm.$createElement
  41578. var _c = _vm._self._c || _h
  41579. return _c("div", { staticClass: "container" }, [
  41580. _c("div", { staticClass: "row justify-content-center" }, [
  41581. _c("div", { staticClass: "col-md-8" }, [
  41582. _c("div", { staticClass: "card" }, [
  41583. _c("div", { staticClass: "card-header" }, [
  41584. _vm._v("Example Component")
  41585. ]),
  41586. _vm._v(" "),
  41587. _c("div", { staticClass: "card-body" }, [
  41588. _vm._v(
  41589. "\n I'm an example component.\n "
  41590. )
  41591. ])
  41592. ])
  41593. ])
  41594. ])
  41595. ])
  41596. }
  41597. ]
  41598. render._withStripped = true
  41599. /***/ }),
  41600. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  41601. /*!************************************************************************************************************************************************************************************************************!*\
  41602. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  41603. \************************************************************************************************************************************************************************************************************/
  41604. /*! exports provided: render, staticRenderFns */
  41605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41606. "use strict";
  41607. __webpack_require__.r(__webpack_exports__);
  41608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41610. var render = function() {
  41611. var _vm = this
  41612. var _h = _vm.$createElement
  41613. var _c = _vm._self._c || _h
  41614. return _c("div", [
  41615. _c("p", [
  41616. _vm._v("PCID: "),
  41617. _c("span", { domProps: { textContent: _vm._s(this.data.pcid) } })
  41618. ]),
  41619. _vm._v(" "),
  41620. _c("p", [
  41621. _vm._v("Manufacturer: "),
  41622. _c("span", { domProps: { textContent: _vm._s(this.data.pcmanu) } })
  41623. ])
  41624. ])
  41625. }
  41626. var staticRenderFns = []
  41627. render._withStripped = true
  41628. /***/ }),
  41629. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  41630. /*!*********************************************************************************************************************************************************************************************************!*\
  41631. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  41632. \*********************************************************************************************************************************************************************************************************/
  41633. /*! exports provided: render, staticRenderFns */
  41634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41635. "use strict";
  41636. __webpack_require__.r(__webpack_exports__);
  41637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41639. var render = function() {
  41640. var _vm = this
  41641. var _h = _vm.$createElement
  41642. var _c = _vm._self._c || _h
  41643. return _c("div", [
  41644. _c("p", [
  41645. _vm._v("Problem Description: "),
  41646. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  41647. ]),
  41648. _vm._v(" "),
  41649. _c("p", [
  41650. _vm._v("Suggested Solution: "),
  41651. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  41652. ]),
  41653. _vm._v(" "),
  41654. _c("p", [
  41655. _vm._v("Work Order ID: "),
  41656. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  41657. ]),
  41658. _vm._v(" "),
  41659. _c("p", [
  41660. _vm._v("Store: "),
  41661. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  41662. ]),
  41663. _vm._v(" "),
  41664. _c("p", [
  41665. _vm._v("Check-in Date: "),
  41666. _c("span", { domProps: { textContent: _vm._s(this.data.dropdate) } })
  41667. ]),
  41668. _vm._v(" "),
  41669. _c("p", [
  41670. _vm._v("Check-out Date: "),
  41671. _c("span", { domProps: { textContent: _vm._s(this.data.pickupdate) } })
  41672. ]),
  41673. _vm._v(" "),
  41674. _c("p", [
  41675. _vm._v("Accessories: "),
  41676. _c("span", { domProps: { textContent: _vm._s(this.data.custassets) } })
  41677. ])
  41678. ])
  41679. }
  41680. var staticRenderFns = []
  41681. render._withStripped = true
  41682. /***/ }),
  41683. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41684. /*!********************************************************************!*\
  41685. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41686. \********************************************************************/
  41687. /*! exports provided: default */
  41688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41689. "use strict";
  41690. __webpack_require__.r(__webpack_exports__);
  41691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41692. /* globals __VUE_SSR_CONTEXT__ */
  41693. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41694. // This module is a runtime utility for cleaner component module output and will
  41695. // be included in the final webpack user bundle.
  41696. function normalizeComponent (
  41697. scriptExports,
  41698. render,
  41699. staticRenderFns,
  41700. functionalTemplate,
  41701. injectStyles,
  41702. scopeId,
  41703. moduleIdentifier, /* server only */
  41704. shadowMode /* vue-cli only */
  41705. ) {
  41706. // Vue.extend constructor export interop
  41707. var options = typeof scriptExports === 'function'
  41708. ? scriptExports.options
  41709. : scriptExports
  41710. // render functions
  41711. if (render) {
  41712. options.render = render
  41713. options.staticRenderFns = staticRenderFns
  41714. options._compiled = true
  41715. }
  41716. // functional template
  41717. if (functionalTemplate) {
  41718. options.functional = true
  41719. }
  41720. // scopedId
  41721. if (scopeId) {
  41722. options._scopeId = 'data-v-' + scopeId
  41723. }
  41724. var hook
  41725. if (moduleIdentifier) { // server build
  41726. hook = function (context) {
  41727. // 2.3 injection
  41728. context =
  41729. context || // cached call
  41730. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41731. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41732. // 2.2 with runInNewContext: true
  41733. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41734. context = __VUE_SSR_CONTEXT__
  41735. }
  41736. // inject component styles
  41737. if (injectStyles) {
  41738. injectStyles.call(this, context)
  41739. }
  41740. // register component module identifier for async chunk inferrence
  41741. if (context && context._registeredComponents) {
  41742. context._registeredComponents.add(moduleIdentifier)
  41743. }
  41744. }
  41745. // used by ssr in case component is cached and beforeCreate
  41746. // never gets called
  41747. options._ssrRegister = hook
  41748. } else if (injectStyles) {
  41749. hook = shadowMode
  41750. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41751. : injectStyles
  41752. }
  41753. if (hook) {
  41754. if (options.functional) {
  41755. // for template-only hot-reload because in that case the render fn doesn't
  41756. // go through the normalizer
  41757. options._injectStyles = hook
  41758. // register for functioal component in vue file
  41759. var originalRender = options.render
  41760. options.render = function renderWithStyleInjection (h, context) {
  41761. hook.call(context)
  41762. return originalRender(h, context)
  41763. }
  41764. } else {
  41765. // inject component registration as beforeCreate hook
  41766. var existing = options.beforeCreate
  41767. options.beforeCreate = existing
  41768. ? [].concat(existing, hook)
  41769. : [hook]
  41770. }
  41771. }
  41772. return {
  41773. exports: scriptExports,
  41774. options: options
  41775. }
  41776. }
  41777. /***/ }),
  41778. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41779. /*!*************************************************!*\
  41780. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41781. \*************************************************/
  41782. /*! no static exports found */
  41783. /***/ (function(module, exports, __webpack_require__) {
  41784. "use strict";
  41785. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41786. * Vue.js v2.6.11
  41787. * (c) 2014-2019 Evan You
  41788. * Released under the MIT License.
  41789. */
  41790. /* */
  41791. var emptyObject = Object.freeze({});
  41792. // These helpers produce better VM code in JS engines due to their
  41793. // explicitness and function inlining.
  41794. function isUndef (v) {
  41795. return v === undefined || v === null
  41796. }
  41797. function isDef (v) {
  41798. return v !== undefined && v !== null
  41799. }
  41800. function isTrue (v) {
  41801. return v === true
  41802. }
  41803. function isFalse (v) {
  41804. return v === false
  41805. }
  41806. /**
  41807. * Check if value is primitive.
  41808. */
  41809. function isPrimitive (value) {
  41810. return (
  41811. typeof value === 'string' ||
  41812. typeof value === 'number' ||
  41813. // $flow-disable-line
  41814. typeof value === 'symbol' ||
  41815. typeof value === 'boolean'
  41816. )
  41817. }
  41818. /**
  41819. * Quick object check - this is primarily used to tell
  41820. * Objects from primitive values when we know the value
  41821. * is a JSON-compliant type.
  41822. */
  41823. function isObject (obj) {
  41824. return obj !== null && typeof obj === 'object'
  41825. }
  41826. /**
  41827. * Get the raw type string of a value, e.g., [object Object].
  41828. */
  41829. var _toString = Object.prototype.toString;
  41830. function toRawType (value) {
  41831. return _toString.call(value).slice(8, -1)
  41832. }
  41833. /**
  41834. * Strict object type check. Only returns true
  41835. * for plain JavaScript objects.
  41836. */
  41837. function isPlainObject (obj) {
  41838. return _toString.call(obj) === '[object Object]'
  41839. }
  41840. function isRegExp (v) {
  41841. return _toString.call(v) === '[object RegExp]'
  41842. }
  41843. /**
  41844. * Check if val is a valid array index.
  41845. */
  41846. function isValidArrayIndex (val) {
  41847. var n = parseFloat(String(val));
  41848. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41849. }
  41850. function isPromise (val) {
  41851. return (
  41852. isDef(val) &&
  41853. typeof val.then === 'function' &&
  41854. typeof val.catch === 'function'
  41855. )
  41856. }
  41857. /**
  41858. * Convert a value to a string that is actually rendered.
  41859. */
  41860. function toString (val) {
  41861. return val == null
  41862. ? ''
  41863. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  41864. ? JSON.stringify(val, null, 2)
  41865. : String(val)
  41866. }
  41867. /**
  41868. * Convert an input value to a number for persistence.
  41869. * If the conversion fails, return original string.
  41870. */
  41871. function toNumber (val) {
  41872. var n = parseFloat(val);
  41873. return isNaN(n) ? val : n
  41874. }
  41875. /**
  41876. * Make a map and return a function for checking if a key
  41877. * is in that map.
  41878. */
  41879. function makeMap (
  41880. str,
  41881. expectsLowerCase
  41882. ) {
  41883. var map = Object.create(null);
  41884. var list = str.split(',');
  41885. for (var i = 0; i < list.length; i++) {
  41886. map[list[i]] = true;
  41887. }
  41888. return expectsLowerCase
  41889. ? function (val) { return map[val.toLowerCase()]; }
  41890. : function (val) { return map[val]; }
  41891. }
  41892. /**
  41893. * Check if a tag is a built-in tag.
  41894. */
  41895. var isBuiltInTag = makeMap('slot,component', true);
  41896. /**
  41897. * Check if an attribute is a reserved attribute.
  41898. */
  41899. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  41900. /**
  41901. * Remove an item from an array.
  41902. */
  41903. function remove (arr, item) {
  41904. if (arr.length) {
  41905. var index = arr.indexOf(item);
  41906. if (index > -1) {
  41907. return arr.splice(index, 1)
  41908. }
  41909. }
  41910. }
  41911. /**
  41912. * Check whether an object has the property.
  41913. */
  41914. var hasOwnProperty = Object.prototype.hasOwnProperty;
  41915. function hasOwn (obj, key) {
  41916. return hasOwnProperty.call(obj, key)
  41917. }
  41918. /**
  41919. * Create a cached version of a pure function.
  41920. */
  41921. function cached (fn) {
  41922. var cache = Object.create(null);
  41923. return (function cachedFn (str) {
  41924. var hit = cache[str];
  41925. return hit || (cache[str] = fn(str))
  41926. })
  41927. }
  41928. /**
  41929. * Camelize a hyphen-delimited string.
  41930. */
  41931. var camelizeRE = /-(\w)/g;
  41932. var camelize = cached(function (str) {
  41933. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  41934. });
  41935. /**
  41936. * Capitalize a string.
  41937. */
  41938. var capitalize = cached(function (str) {
  41939. return str.charAt(0).toUpperCase() + str.slice(1)
  41940. });
  41941. /**
  41942. * Hyphenate a camelCase string.
  41943. */
  41944. var hyphenateRE = /\B([A-Z])/g;
  41945. var hyphenate = cached(function (str) {
  41946. return str.replace(hyphenateRE, '-$1').toLowerCase()
  41947. });
  41948. /**
  41949. * Simple bind polyfill for environments that do not support it,
  41950. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  41951. * since native bind is now performant enough in most browsers.
  41952. * But removing it would mean breaking code that was able to run in
  41953. * PhantomJS 1.x, so this must be kept for backward compatibility.
  41954. */
  41955. /* istanbul ignore next */
  41956. function polyfillBind (fn, ctx) {
  41957. function boundFn (a) {
  41958. var l = arguments.length;
  41959. return l
  41960. ? l > 1
  41961. ? fn.apply(ctx, arguments)
  41962. : fn.call(ctx, a)
  41963. : fn.call(ctx)
  41964. }
  41965. boundFn._length = fn.length;
  41966. return boundFn
  41967. }
  41968. function nativeBind (fn, ctx) {
  41969. return fn.bind(ctx)
  41970. }
  41971. var bind = Function.prototype.bind
  41972. ? nativeBind
  41973. : polyfillBind;
  41974. /**
  41975. * Convert an Array-like object to a real Array.
  41976. */
  41977. function toArray (list, start) {
  41978. start = start || 0;
  41979. var i = list.length - start;
  41980. var ret = new Array(i);
  41981. while (i--) {
  41982. ret[i] = list[i + start];
  41983. }
  41984. return ret
  41985. }
  41986. /**
  41987. * Mix properties into target object.
  41988. */
  41989. function extend (to, _from) {
  41990. for (var key in _from) {
  41991. to[key] = _from[key];
  41992. }
  41993. return to
  41994. }
  41995. /**
  41996. * Merge an Array of Objects into a single Object.
  41997. */
  41998. function toObject (arr) {
  41999. var res = {};
  42000. for (var i = 0; i < arr.length; i++) {
  42001. if (arr[i]) {
  42002. extend(res, arr[i]);
  42003. }
  42004. }
  42005. return res
  42006. }
  42007. /* eslint-disable no-unused-vars */
  42008. /**
  42009. * Perform no operation.
  42010. * Stubbing args to make Flow happy without leaving useless transpiled code
  42011. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  42012. */
  42013. function noop (a, b, c) {}
  42014. /**
  42015. * Always return false.
  42016. */
  42017. var no = function (a, b, c) { return false; };
  42018. /* eslint-enable no-unused-vars */
  42019. /**
  42020. * Return the same value.
  42021. */
  42022. var identity = function (_) { return _; };
  42023. /**
  42024. * Generate a string containing static keys from compiler modules.
  42025. */
  42026. function genStaticKeys (modules) {
  42027. return modules.reduce(function (keys, m) {
  42028. return keys.concat(m.staticKeys || [])
  42029. }, []).join(',')
  42030. }
  42031. /**
  42032. * Check if two values are loosely equal - that is,
  42033. * if they are plain objects, do they have the same shape?
  42034. */
  42035. function looseEqual (a, b) {
  42036. if (a === b) { return true }
  42037. var isObjectA = isObject(a);
  42038. var isObjectB = isObject(b);
  42039. if (isObjectA && isObjectB) {
  42040. try {
  42041. var isArrayA = Array.isArray(a);
  42042. var isArrayB = Array.isArray(b);
  42043. if (isArrayA && isArrayB) {
  42044. return a.length === b.length && a.every(function (e, i) {
  42045. return looseEqual(e, b[i])
  42046. })
  42047. } else if (a instanceof Date && b instanceof Date) {
  42048. return a.getTime() === b.getTime()
  42049. } else if (!isArrayA && !isArrayB) {
  42050. var keysA = Object.keys(a);
  42051. var keysB = Object.keys(b);
  42052. return keysA.length === keysB.length && keysA.every(function (key) {
  42053. return looseEqual(a[key], b[key])
  42054. })
  42055. } else {
  42056. /* istanbul ignore next */
  42057. return false
  42058. }
  42059. } catch (e) {
  42060. /* istanbul ignore next */
  42061. return false
  42062. }
  42063. } else if (!isObjectA && !isObjectB) {
  42064. return String(a) === String(b)
  42065. } else {
  42066. return false
  42067. }
  42068. }
  42069. /**
  42070. * Return the first index at which a loosely equal value can be
  42071. * found in the array (if value is a plain object, the array must
  42072. * contain an object of the same shape), or -1 if it is not present.
  42073. */
  42074. function looseIndexOf (arr, val) {
  42075. for (var i = 0; i < arr.length; i++) {
  42076. if (looseEqual(arr[i], val)) { return i }
  42077. }
  42078. return -1
  42079. }
  42080. /**
  42081. * Ensure a function is called only once.
  42082. */
  42083. function once (fn) {
  42084. var called = false;
  42085. return function () {
  42086. if (!called) {
  42087. called = true;
  42088. fn.apply(this, arguments);
  42089. }
  42090. }
  42091. }
  42092. var SSR_ATTR = 'data-server-rendered';
  42093. var ASSET_TYPES = [
  42094. 'component',
  42095. 'directive',
  42096. 'filter'
  42097. ];
  42098. var LIFECYCLE_HOOKS = [
  42099. 'beforeCreate',
  42100. 'created',
  42101. 'beforeMount',
  42102. 'mounted',
  42103. 'beforeUpdate',
  42104. 'updated',
  42105. 'beforeDestroy',
  42106. 'destroyed',
  42107. 'activated',
  42108. 'deactivated',
  42109. 'errorCaptured',
  42110. 'serverPrefetch'
  42111. ];
  42112. /* */
  42113. var config = ({
  42114. /**
  42115. * Option merge strategies (used in core/util/options)
  42116. */
  42117. // $flow-disable-line
  42118. optionMergeStrategies: Object.create(null),
  42119. /**
  42120. * Whether to suppress warnings.
  42121. */
  42122. silent: false,
  42123. /**
  42124. * Show production mode tip message on boot?
  42125. */
  42126. productionTip: "development" !== 'production',
  42127. /**
  42128. * Whether to enable devtools
  42129. */
  42130. devtools: "development" !== 'production',
  42131. /**
  42132. * Whether to record perf
  42133. */
  42134. performance: false,
  42135. /**
  42136. * Error handler for watcher errors
  42137. */
  42138. errorHandler: null,
  42139. /**
  42140. * Warn handler for watcher warns
  42141. */
  42142. warnHandler: null,
  42143. /**
  42144. * Ignore certain custom elements
  42145. */
  42146. ignoredElements: [],
  42147. /**
  42148. * Custom user key aliases for v-on
  42149. */
  42150. // $flow-disable-line
  42151. keyCodes: Object.create(null),
  42152. /**
  42153. * Check if a tag is reserved so that it cannot be registered as a
  42154. * component. This is platform-dependent and may be overwritten.
  42155. */
  42156. isReservedTag: no,
  42157. /**
  42158. * Check if an attribute is reserved so that it cannot be used as a component
  42159. * prop. This is platform-dependent and may be overwritten.
  42160. */
  42161. isReservedAttr: no,
  42162. /**
  42163. * Check if a tag is an unknown element.
  42164. * Platform-dependent.
  42165. */
  42166. isUnknownElement: no,
  42167. /**
  42168. * Get the namespace of an element
  42169. */
  42170. getTagNamespace: noop,
  42171. /**
  42172. * Parse the real tag name for the specific platform.
  42173. */
  42174. parsePlatformTagName: identity,
  42175. /**
  42176. * Check if an attribute must be bound using property, e.g. value
  42177. * Platform-dependent.
  42178. */
  42179. mustUseProp: no,
  42180. /**
  42181. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42182. * This will significantly reduce performance if set to false.
  42183. */
  42184. async: true,
  42185. /**
  42186. * Exposed for legacy reasons
  42187. */
  42188. _lifecycleHooks: LIFECYCLE_HOOKS
  42189. });
  42190. /* */
  42191. /**
  42192. * unicode letters used for parsing html tags, component names and property paths.
  42193. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42194. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42195. */
  42196. 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/;
  42197. /**
  42198. * Check if a string starts with $ or _
  42199. */
  42200. function isReserved (str) {
  42201. var c = (str + '').charCodeAt(0);
  42202. return c === 0x24 || c === 0x5F
  42203. }
  42204. /**
  42205. * Define a property.
  42206. */
  42207. function def (obj, key, val, enumerable) {
  42208. Object.defineProperty(obj, key, {
  42209. value: val,
  42210. enumerable: !!enumerable,
  42211. writable: true,
  42212. configurable: true
  42213. });
  42214. }
  42215. /**
  42216. * Parse simple path.
  42217. */
  42218. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42219. function parsePath (path) {
  42220. if (bailRE.test(path)) {
  42221. return
  42222. }
  42223. var segments = path.split('.');
  42224. return function (obj) {
  42225. for (var i = 0; i < segments.length; i++) {
  42226. if (!obj) { return }
  42227. obj = obj[segments[i]];
  42228. }
  42229. return obj
  42230. }
  42231. }
  42232. /* */
  42233. // can we use __proto__?
  42234. var hasProto = '__proto__' in {};
  42235. // Browser environment sniffing
  42236. var inBrowser = typeof window !== 'undefined';
  42237. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42238. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42239. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42240. var isIE = UA && /msie|trident/.test(UA);
  42241. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42242. var isEdge = UA && UA.indexOf('edge/') > 0;
  42243. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42244. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42245. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42246. var isPhantomJS = UA && /phantomjs/.test(UA);
  42247. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42248. // Firefox has a "watch" function on Object.prototype...
  42249. var nativeWatch = ({}).watch;
  42250. var supportsPassive = false;
  42251. if (inBrowser) {
  42252. try {
  42253. var opts = {};
  42254. Object.defineProperty(opts, 'passive', ({
  42255. get: function get () {
  42256. /* istanbul ignore next */
  42257. supportsPassive = true;
  42258. }
  42259. })); // https://github.com/facebook/flow/issues/285
  42260. window.addEventListener('test-passive', null, opts);
  42261. } catch (e) {}
  42262. }
  42263. // this needs to be lazy-evaled because vue may be required before
  42264. // vue-server-renderer can set VUE_ENV
  42265. var _isServer;
  42266. var isServerRendering = function () {
  42267. if (_isServer === undefined) {
  42268. /* istanbul ignore if */
  42269. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42270. // detect presence of vue-server-renderer and avoid
  42271. // Webpack shimming the process
  42272. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42273. } else {
  42274. _isServer = false;
  42275. }
  42276. }
  42277. return _isServer
  42278. };
  42279. // detect devtools
  42280. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42281. /* istanbul ignore next */
  42282. function isNative (Ctor) {
  42283. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42284. }
  42285. var hasSymbol =
  42286. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42287. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42288. var _Set;
  42289. /* istanbul ignore if */ // $flow-disable-line
  42290. if (typeof Set !== 'undefined' && isNative(Set)) {
  42291. // use native Set when available.
  42292. _Set = Set;
  42293. } else {
  42294. // a non-standard Set polyfill that only works with primitive keys.
  42295. _Set = /*@__PURE__*/(function () {
  42296. function Set () {
  42297. this.set = Object.create(null);
  42298. }
  42299. Set.prototype.has = function has (key) {
  42300. return this.set[key] === true
  42301. };
  42302. Set.prototype.add = function add (key) {
  42303. this.set[key] = true;
  42304. };
  42305. Set.prototype.clear = function clear () {
  42306. this.set = Object.create(null);
  42307. };
  42308. return Set;
  42309. }());
  42310. }
  42311. /* */
  42312. var warn = noop;
  42313. var tip = noop;
  42314. var generateComponentTrace = (noop); // work around flow check
  42315. var formatComponentName = (noop);
  42316. {
  42317. var hasConsole = typeof console !== 'undefined';
  42318. var classifyRE = /(?:^|[-_])(\w)/g;
  42319. var classify = function (str) { return str
  42320. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42321. .replace(/[-_]/g, ''); };
  42322. warn = function (msg, vm) {
  42323. var trace = vm ? generateComponentTrace(vm) : '';
  42324. if (config.warnHandler) {
  42325. config.warnHandler.call(null, msg, vm, trace);
  42326. } else if (hasConsole && (!config.silent)) {
  42327. console.error(("[Vue warn]: " + msg + trace));
  42328. }
  42329. };
  42330. tip = function (msg, vm) {
  42331. if (hasConsole && (!config.silent)) {
  42332. console.warn("[Vue tip]: " + msg + (
  42333. vm ? generateComponentTrace(vm) : ''
  42334. ));
  42335. }
  42336. };
  42337. formatComponentName = function (vm, includeFile) {
  42338. if (vm.$root === vm) {
  42339. return '<Root>'
  42340. }
  42341. var options = typeof vm === 'function' && vm.cid != null
  42342. ? vm.options
  42343. : vm._isVue
  42344. ? vm.$options || vm.constructor.options
  42345. : vm;
  42346. var name = options.name || options._componentTag;
  42347. var file = options.__file;
  42348. if (!name && file) {
  42349. var match = file.match(/([^/\\]+)\.vue$/);
  42350. name = match && match[1];
  42351. }
  42352. return (
  42353. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42354. (file && includeFile !== false ? (" at " + file) : '')
  42355. )
  42356. };
  42357. var repeat = function (str, n) {
  42358. var res = '';
  42359. while (n) {
  42360. if (n % 2 === 1) { res += str; }
  42361. if (n > 1) { str += str; }
  42362. n >>= 1;
  42363. }
  42364. return res
  42365. };
  42366. generateComponentTrace = function (vm) {
  42367. if (vm._isVue && vm.$parent) {
  42368. var tree = [];
  42369. var currentRecursiveSequence = 0;
  42370. while (vm) {
  42371. if (tree.length > 0) {
  42372. var last = tree[tree.length - 1];
  42373. if (last.constructor === vm.constructor) {
  42374. currentRecursiveSequence++;
  42375. vm = vm.$parent;
  42376. continue
  42377. } else if (currentRecursiveSequence > 0) {
  42378. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42379. currentRecursiveSequence = 0;
  42380. }
  42381. }
  42382. tree.push(vm);
  42383. vm = vm.$parent;
  42384. }
  42385. return '\n\nfound in\n\n' + tree
  42386. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42387. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42388. : formatComponentName(vm))); })
  42389. .join('\n')
  42390. } else {
  42391. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42392. }
  42393. };
  42394. }
  42395. /* */
  42396. var uid = 0;
  42397. /**
  42398. * A dep is an observable that can have multiple
  42399. * directives subscribing to it.
  42400. */
  42401. var Dep = function Dep () {
  42402. this.id = uid++;
  42403. this.subs = [];
  42404. };
  42405. Dep.prototype.addSub = function addSub (sub) {
  42406. this.subs.push(sub);
  42407. };
  42408. Dep.prototype.removeSub = function removeSub (sub) {
  42409. remove(this.subs, sub);
  42410. };
  42411. Dep.prototype.depend = function depend () {
  42412. if (Dep.target) {
  42413. Dep.target.addDep(this);
  42414. }
  42415. };
  42416. Dep.prototype.notify = function notify () {
  42417. // stabilize the subscriber list first
  42418. var subs = this.subs.slice();
  42419. if (!config.async) {
  42420. // subs aren't sorted in scheduler if not running async
  42421. // we need to sort them now to make sure they fire in correct
  42422. // order
  42423. subs.sort(function (a, b) { return a.id - b.id; });
  42424. }
  42425. for (var i = 0, l = subs.length; i < l; i++) {
  42426. subs[i].update();
  42427. }
  42428. };
  42429. // The current target watcher being evaluated.
  42430. // This is globally unique because only one watcher
  42431. // can be evaluated at a time.
  42432. Dep.target = null;
  42433. var targetStack = [];
  42434. function pushTarget (target) {
  42435. targetStack.push(target);
  42436. Dep.target = target;
  42437. }
  42438. function popTarget () {
  42439. targetStack.pop();
  42440. Dep.target = targetStack[targetStack.length - 1];
  42441. }
  42442. /* */
  42443. var VNode = function VNode (
  42444. tag,
  42445. data,
  42446. children,
  42447. text,
  42448. elm,
  42449. context,
  42450. componentOptions,
  42451. asyncFactory
  42452. ) {
  42453. this.tag = tag;
  42454. this.data = data;
  42455. this.children = children;
  42456. this.text = text;
  42457. this.elm = elm;
  42458. this.ns = undefined;
  42459. this.context = context;
  42460. this.fnContext = undefined;
  42461. this.fnOptions = undefined;
  42462. this.fnScopeId = undefined;
  42463. this.key = data && data.key;
  42464. this.componentOptions = componentOptions;
  42465. this.componentInstance = undefined;
  42466. this.parent = undefined;
  42467. this.raw = false;
  42468. this.isStatic = false;
  42469. this.isRootInsert = true;
  42470. this.isComment = false;
  42471. this.isCloned = false;
  42472. this.isOnce = false;
  42473. this.asyncFactory = asyncFactory;
  42474. this.asyncMeta = undefined;
  42475. this.isAsyncPlaceholder = false;
  42476. };
  42477. var prototypeAccessors = { child: { configurable: true } };
  42478. // DEPRECATED: alias for componentInstance for backwards compat.
  42479. /* istanbul ignore next */
  42480. prototypeAccessors.child.get = function () {
  42481. return this.componentInstance
  42482. };
  42483. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42484. var createEmptyVNode = function (text) {
  42485. if ( text === void 0 ) text = '';
  42486. var node = new VNode();
  42487. node.text = text;
  42488. node.isComment = true;
  42489. return node
  42490. };
  42491. function createTextVNode (val) {
  42492. return new VNode(undefined, undefined, undefined, String(val))
  42493. }
  42494. // optimized shallow clone
  42495. // used for static nodes and slot nodes because they may be reused across
  42496. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42497. // on their elm reference.
  42498. function cloneVNode (vnode) {
  42499. var cloned = new VNode(
  42500. vnode.tag,
  42501. vnode.data,
  42502. // #7975
  42503. // clone children array to avoid mutating original in case of cloning
  42504. // a child.
  42505. vnode.children && vnode.children.slice(),
  42506. vnode.text,
  42507. vnode.elm,
  42508. vnode.context,
  42509. vnode.componentOptions,
  42510. vnode.asyncFactory
  42511. );
  42512. cloned.ns = vnode.ns;
  42513. cloned.isStatic = vnode.isStatic;
  42514. cloned.key = vnode.key;
  42515. cloned.isComment = vnode.isComment;
  42516. cloned.fnContext = vnode.fnContext;
  42517. cloned.fnOptions = vnode.fnOptions;
  42518. cloned.fnScopeId = vnode.fnScopeId;
  42519. cloned.asyncMeta = vnode.asyncMeta;
  42520. cloned.isCloned = true;
  42521. return cloned
  42522. }
  42523. /*
  42524. * not type checking this file because flow doesn't play well with
  42525. * dynamically accessing methods on Array prototype
  42526. */
  42527. var arrayProto = Array.prototype;
  42528. var arrayMethods = Object.create(arrayProto);
  42529. var methodsToPatch = [
  42530. 'push',
  42531. 'pop',
  42532. 'shift',
  42533. 'unshift',
  42534. 'splice',
  42535. 'sort',
  42536. 'reverse'
  42537. ];
  42538. /**
  42539. * Intercept mutating methods and emit events
  42540. */
  42541. methodsToPatch.forEach(function (method) {
  42542. // cache original method
  42543. var original = arrayProto[method];
  42544. def(arrayMethods, method, function mutator () {
  42545. var args = [], len = arguments.length;
  42546. while ( len-- ) args[ len ] = arguments[ len ];
  42547. var result = original.apply(this, args);
  42548. var ob = this.__ob__;
  42549. var inserted;
  42550. switch (method) {
  42551. case 'push':
  42552. case 'unshift':
  42553. inserted = args;
  42554. break
  42555. case 'splice':
  42556. inserted = args.slice(2);
  42557. break
  42558. }
  42559. if (inserted) { ob.observeArray(inserted); }
  42560. // notify change
  42561. ob.dep.notify();
  42562. return result
  42563. });
  42564. });
  42565. /* */
  42566. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42567. /**
  42568. * In some cases we may want to disable observation inside a component's
  42569. * update computation.
  42570. */
  42571. var shouldObserve = true;
  42572. function toggleObserving (value) {
  42573. shouldObserve = value;
  42574. }
  42575. /**
  42576. * Observer class that is attached to each observed
  42577. * object. Once attached, the observer converts the target
  42578. * object's property keys into getter/setters that
  42579. * collect dependencies and dispatch updates.
  42580. */
  42581. var Observer = function Observer (value) {
  42582. this.value = value;
  42583. this.dep = new Dep();
  42584. this.vmCount = 0;
  42585. def(value, '__ob__', this);
  42586. if (Array.isArray(value)) {
  42587. if (hasProto) {
  42588. protoAugment(value, arrayMethods);
  42589. } else {
  42590. copyAugment(value, arrayMethods, arrayKeys);
  42591. }
  42592. this.observeArray(value);
  42593. } else {
  42594. this.walk(value);
  42595. }
  42596. };
  42597. /**
  42598. * Walk through all properties and convert them into
  42599. * getter/setters. This method should only be called when
  42600. * value type is Object.
  42601. */
  42602. Observer.prototype.walk = function walk (obj) {
  42603. var keys = Object.keys(obj);
  42604. for (var i = 0; i < keys.length; i++) {
  42605. defineReactive$$1(obj, keys[i]);
  42606. }
  42607. };
  42608. /**
  42609. * Observe a list of Array items.
  42610. */
  42611. Observer.prototype.observeArray = function observeArray (items) {
  42612. for (var i = 0, l = items.length; i < l; i++) {
  42613. observe(items[i]);
  42614. }
  42615. };
  42616. // helpers
  42617. /**
  42618. * Augment a target Object or Array by intercepting
  42619. * the prototype chain using __proto__
  42620. */
  42621. function protoAugment (target, src) {
  42622. /* eslint-disable no-proto */
  42623. target.__proto__ = src;
  42624. /* eslint-enable no-proto */
  42625. }
  42626. /**
  42627. * Augment a target Object or Array by defining
  42628. * hidden properties.
  42629. */
  42630. /* istanbul ignore next */
  42631. function copyAugment (target, src, keys) {
  42632. for (var i = 0, l = keys.length; i < l; i++) {
  42633. var key = keys[i];
  42634. def(target, key, src[key]);
  42635. }
  42636. }
  42637. /**
  42638. * Attempt to create an observer instance for a value,
  42639. * returns the new observer if successfully observed,
  42640. * or the existing observer if the value already has one.
  42641. */
  42642. function observe (value, asRootData) {
  42643. if (!isObject(value) || value instanceof VNode) {
  42644. return
  42645. }
  42646. var ob;
  42647. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42648. ob = value.__ob__;
  42649. } else if (
  42650. shouldObserve &&
  42651. !isServerRendering() &&
  42652. (Array.isArray(value) || isPlainObject(value)) &&
  42653. Object.isExtensible(value) &&
  42654. !value._isVue
  42655. ) {
  42656. ob = new Observer(value);
  42657. }
  42658. if (asRootData && ob) {
  42659. ob.vmCount++;
  42660. }
  42661. return ob
  42662. }
  42663. /**
  42664. * Define a reactive property on an Object.
  42665. */
  42666. function defineReactive$$1 (
  42667. obj,
  42668. key,
  42669. val,
  42670. customSetter,
  42671. shallow
  42672. ) {
  42673. var dep = new Dep();
  42674. var property = Object.getOwnPropertyDescriptor(obj, key);
  42675. if (property && property.configurable === false) {
  42676. return
  42677. }
  42678. // cater for pre-defined getter/setters
  42679. var getter = property && property.get;
  42680. var setter = property && property.set;
  42681. if ((!getter || setter) && arguments.length === 2) {
  42682. val = obj[key];
  42683. }
  42684. var childOb = !shallow && observe(val);
  42685. Object.defineProperty(obj, key, {
  42686. enumerable: true,
  42687. configurable: true,
  42688. get: function reactiveGetter () {
  42689. var value = getter ? getter.call(obj) : val;
  42690. if (Dep.target) {
  42691. dep.depend();
  42692. if (childOb) {
  42693. childOb.dep.depend();
  42694. if (Array.isArray(value)) {
  42695. dependArray(value);
  42696. }
  42697. }
  42698. }
  42699. return value
  42700. },
  42701. set: function reactiveSetter (newVal) {
  42702. var value = getter ? getter.call(obj) : val;
  42703. /* eslint-disable no-self-compare */
  42704. if (newVal === value || (newVal !== newVal && value !== value)) {
  42705. return
  42706. }
  42707. /* eslint-enable no-self-compare */
  42708. if (customSetter) {
  42709. customSetter();
  42710. }
  42711. // #7981: for accessor properties without setter
  42712. if (getter && !setter) { return }
  42713. if (setter) {
  42714. setter.call(obj, newVal);
  42715. } else {
  42716. val = newVal;
  42717. }
  42718. childOb = !shallow && observe(newVal);
  42719. dep.notify();
  42720. }
  42721. });
  42722. }
  42723. /**
  42724. * Set a property on an object. Adds the new property and
  42725. * triggers change notification if the property doesn't
  42726. * already exist.
  42727. */
  42728. function set (target, key, val) {
  42729. if (isUndef(target) || isPrimitive(target)
  42730. ) {
  42731. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42732. }
  42733. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42734. target.length = Math.max(target.length, key);
  42735. target.splice(key, 1, val);
  42736. return val
  42737. }
  42738. if (key in target && !(key in Object.prototype)) {
  42739. target[key] = val;
  42740. return val
  42741. }
  42742. var ob = (target).__ob__;
  42743. if (target._isVue || (ob && ob.vmCount)) {
  42744. warn(
  42745. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42746. 'at runtime - declare it upfront in the data option.'
  42747. );
  42748. return val
  42749. }
  42750. if (!ob) {
  42751. target[key] = val;
  42752. return val
  42753. }
  42754. defineReactive$$1(ob.value, key, val);
  42755. ob.dep.notify();
  42756. return val
  42757. }
  42758. /**
  42759. * Delete a property and trigger change if necessary.
  42760. */
  42761. function del (target, key) {
  42762. if (isUndef(target) || isPrimitive(target)
  42763. ) {
  42764. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42765. }
  42766. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42767. target.splice(key, 1);
  42768. return
  42769. }
  42770. var ob = (target).__ob__;
  42771. if (target._isVue || (ob && ob.vmCount)) {
  42772. warn(
  42773. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42774. '- just set it to null.'
  42775. );
  42776. return
  42777. }
  42778. if (!hasOwn(target, key)) {
  42779. return
  42780. }
  42781. delete target[key];
  42782. if (!ob) {
  42783. return
  42784. }
  42785. ob.dep.notify();
  42786. }
  42787. /**
  42788. * Collect dependencies on array elements when the array is touched, since
  42789. * we cannot intercept array element access like property getters.
  42790. */
  42791. function dependArray (value) {
  42792. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42793. e = value[i];
  42794. e && e.__ob__ && e.__ob__.dep.depend();
  42795. if (Array.isArray(e)) {
  42796. dependArray(e);
  42797. }
  42798. }
  42799. }
  42800. /* */
  42801. /**
  42802. * Option overwriting strategies are functions that handle
  42803. * how to merge a parent option value and a child option
  42804. * value into the final value.
  42805. */
  42806. var strats = config.optionMergeStrategies;
  42807. /**
  42808. * Options with restrictions
  42809. */
  42810. {
  42811. strats.el = strats.propsData = function (parent, child, vm, key) {
  42812. if (!vm) {
  42813. warn(
  42814. "option \"" + key + "\" can only be used during instance " +
  42815. 'creation with the `new` keyword.'
  42816. );
  42817. }
  42818. return defaultStrat(parent, child)
  42819. };
  42820. }
  42821. /**
  42822. * Helper that recursively merges two data objects together.
  42823. */
  42824. function mergeData (to, from) {
  42825. if (!from) { return to }
  42826. var key, toVal, fromVal;
  42827. var keys = hasSymbol
  42828. ? Reflect.ownKeys(from)
  42829. : Object.keys(from);
  42830. for (var i = 0; i < keys.length; i++) {
  42831. key = keys[i];
  42832. // in case the object is already observed...
  42833. if (key === '__ob__') { continue }
  42834. toVal = to[key];
  42835. fromVal = from[key];
  42836. if (!hasOwn(to, key)) {
  42837. set(to, key, fromVal);
  42838. } else if (
  42839. toVal !== fromVal &&
  42840. isPlainObject(toVal) &&
  42841. isPlainObject(fromVal)
  42842. ) {
  42843. mergeData(toVal, fromVal);
  42844. }
  42845. }
  42846. return to
  42847. }
  42848. /**
  42849. * Data
  42850. */
  42851. function mergeDataOrFn (
  42852. parentVal,
  42853. childVal,
  42854. vm
  42855. ) {
  42856. if (!vm) {
  42857. // in a Vue.extend merge, both should be functions
  42858. if (!childVal) {
  42859. return parentVal
  42860. }
  42861. if (!parentVal) {
  42862. return childVal
  42863. }
  42864. // when parentVal & childVal are both present,
  42865. // we need to return a function that returns the
  42866. // merged result of both functions... no need to
  42867. // check if parentVal is a function here because
  42868. // it has to be a function to pass previous merges.
  42869. return function mergedDataFn () {
  42870. return mergeData(
  42871. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  42872. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  42873. )
  42874. }
  42875. } else {
  42876. return function mergedInstanceDataFn () {
  42877. // instance merge
  42878. var instanceData = typeof childVal === 'function'
  42879. ? childVal.call(vm, vm)
  42880. : childVal;
  42881. var defaultData = typeof parentVal === 'function'
  42882. ? parentVal.call(vm, vm)
  42883. : parentVal;
  42884. if (instanceData) {
  42885. return mergeData(instanceData, defaultData)
  42886. } else {
  42887. return defaultData
  42888. }
  42889. }
  42890. }
  42891. }
  42892. strats.data = function (
  42893. parentVal,
  42894. childVal,
  42895. vm
  42896. ) {
  42897. if (!vm) {
  42898. if (childVal && typeof childVal !== 'function') {
  42899. warn(
  42900. 'The "data" option should be a function ' +
  42901. 'that returns a per-instance value in component ' +
  42902. 'definitions.',
  42903. vm
  42904. );
  42905. return parentVal
  42906. }
  42907. return mergeDataOrFn(parentVal, childVal)
  42908. }
  42909. return mergeDataOrFn(parentVal, childVal, vm)
  42910. };
  42911. /**
  42912. * Hooks and props are merged as arrays.
  42913. */
  42914. function mergeHook (
  42915. parentVal,
  42916. childVal
  42917. ) {
  42918. var res = childVal
  42919. ? parentVal
  42920. ? parentVal.concat(childVal)
  42921. : Array.isArray(childVal)
  42922. ? childVal
  42923. : [childVal]
  42924. : parentVal;
  42925. return res
  42926. ? dedupeHooks(res)
  42927. : res
  42928. }
  42929. function dedupeHooks (hooks) {
  42930. var res = [];
  42931. for (var i = 0; i < hooks.length; i++) {
  42932. if (res.indexOf(hooks[i]) === -1) {
  42933. res.push(hooks[i]);
  42934. }
  42935. }
  42936. return res
  42937. }
  42938. LIFECYCLE_HOOKS.forEach(function (hook) {
  42939. strats[hook] = mergeHook;
  42940. });
  42941. /**
  42942. * Assets
  42943. *
  42944. * When a vm is present (instance creation), we need to do
  42945. * a three-way merge between constructor options, instance
  42946. * options and parent options.
  42947. */
  42948. function mergeAssets (
  42949. parentVal,
  42950. childVal,
  42951. vm,
  42952. key
  42953. ) {
  42954. var res = Object.create(parentVal || null);
  42955. if (childVal) {
  42956. assertObjectType(key, childVal, vm);
  42957. return extend(res, childVal)
  42958. } else {
  42959. return res
  42960. }
  42961. }
  42962. ASSET_TYPES.forEach(function (type) {
  42963. strats[type + 's'] = mergeAssets;
  42964. });
  42965. /**
  42966. * Watchers.
  42967. *
  42968. * Watchers hashes should not overwrite one
  42969. * another, so we merge them as arrays.
  42970. */
  42971. strats.watch = function (
  42972. parentVal,
  42973. childVal,
  42974. vm,
  42975. key
  42976. ) {
  42977. // work around Firefox's Object.prototype.watch...
  42978. if (parentVal === nativeWatch) { parentVal = undefined; }
  42979. if (childVal === nativeWatch) { childVal = undefined; }
  42980. /* istanbul ignore if */
  42981. if (!childVal) { return Object.create(parentVal || null) }
  42982. {
  42983. assertObjectType(key, childVal, vm);
  42984. }
  42985. if (!parentVal) { return childVal }
  42986. var ret = {};
  42987. extend(ret, parentVal);
  42988. for (var key$1 in childVal) {
  42989. var parent = ret[key$1];
  42990. var child = childVal[key$1];
  42991. if (parent && !Array.isArray(parent)) {
  42992. parent = [parent];
  42993. }
  42994. ret[key$1] = parent
  42995. ? parent.concat(child)
  42996. : Array.isArray(child) ? child : [child];
  42997. }
  42998. return ret
  42999. };
  43000. /**
  43001. * Other object hashes.
  43002. */
  43003. strats.props =
  43004. strats.methods =
  43005. strats.inject =
  43006. strats.computed = function (
  43007. parentVal,
  43008. childVal,
  43009. vm,
  43010. key
  43011. ) {
  43012. if (childVal && "development" !== 'production') {
  43013. assertObjectType(key, childVal, vm);
  43014. }
  43015. if (!parentVal) { return childVal }
  43016. var ret = Object.create(null);
  43017. extend(ret, parentVal);
  43018. if (childVal) { extend(ret, childVal); }
  43019. return ret
  43020. };
  43021. strats.provide = mergeDataOrFn;
  43022. /**
  43023. * Default strategy.
  43024. */
  43025. var defaultStrat = function (parentVal, childVal) {
  43026. return childVal === undefined
  43027. ? parentVal
  43028. : childVal
  43029. };
  43030. /**
  43031. * Validate component names
  43032. */
  43033. function checkComponents (options) {
  43034. for (var key in options.components) {
  43035. validateComponentName(key);
  43036. }
  43037. }
  43038. function validateComponentName (name) {
  43039. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  43040. warn(
  43041. 'Invalid component name: "' + name + '". Component names ' +
  43042. 'should conform to valid custom element name in html5 specification.'
  43043. );
  43044. }
  43045. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  43046. warn(
  43047. 'Do not use built-in or reserved HTML elements as component ' +
  43048. 'id: ' + name
  43049. );
  43050. }
  43051. }
  43052. /**
  43053. * Ensure all props option syntax are normalized into the
  43054. * Object-based format.
  43055. */
  43056. function normalizeProps (options, vm) {
  43057. var props = options.props;
  43058. if (!props) { return }
  43059. var res = {};
  43060. var i, val, name;
  43061. if (Array.isArray(props)) {
  43062. i = props.length;
  43063. while (i--) {
  43064. val = props[i];
  43065. if (typeof val === 'string') {
  43066. name = camelize(val);
  43067. res[name] = { type: null };
  43068. } else {
  43069. warn('props must be strings when using array syntax.');
  43070. }
  43071. }
  43072. } else if (isPlainObject(props)) {
  43073. for (var key in props) {
  43074. val = props[key];
  43075. name = camelize(key);
  43076. res[name] = isPlainObject(val)
  43077. ? val
  43078. : { type: val };
  43079. }
  43080. } else {
  43081. warn(
  43082. "Invalid value for option \"props\": expected an Array or an Object, " +
  43083. "but got " + (toRawType(props)) + ".",
  43084. vm
  43085. );
  43086. }
  43087. options.props = res;
  43088. }
  43089. /**
  43090. * Normalize all injections into Object-based format
  43091. */
  43092. function normalizeInject (options, vm) {
  43093. var inject = options.inject;
  43094. if (!inject) { return }
  43095. var normalized = options.inject = {};
  43096. if (Array.isArray(inject)) {
  43097. for (var i = 0; i < inject.length; i++) {
  43098. normalized[inject[i]] = { from: inject[i] };
  43099. }
  43100. } else if (isPlainObject(inject)) {
  43101. for (var key in inject) {
  43102. var val = inject[key];
  43103. normalized[key] = isPlainObject(val)
  43104. ? extend({ from: key }, val)
  43105. : { from: val };
  43106. }
  43107. } else {
  43108. warn(
  43109. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43110. "but got " + (toRawType(inject)) + ".",
  43111. vm
  43112. );
  43113. }
  43114. }
  43115. /**
  43116. * Normalize raw function directives into object format.
  43117. */
  43118. function normalizeDirectives (options) {
  43119. var dirs = options.directives;
  43120. if (dirs) {
  43121. for (var key in dirs) {
  43122. var def$$1 = dirs[key];
  43123. if (typeof def$$1 === 'function') {
  43124. dirs[key] = { bind: def$$1, update: def$$1 };
  43125. }
  43126. }
  43127. }
  43128. }
  43129. function assertObjectType (name, value, vm) {
  43130. if (!isPlainObject(value)) {
  43131. warn(
  43132. "Invalid value for option \"" + name + "\": expected an Object, " +
  43133. "but got " + (toRawType(value)) + ".",
  43134. vm
  43135. );
  43136. }
  43137. }
  43138. /**
  43139. * Merge two option objects into a new one.
  43140. * Core utility used in both instantiation and inheritance.
  43141. */
  43142. function mergeOptions (
  43143. parent,
  43144. child,
  43145. vm
  43146. ) {
  43147. {
  43148. checkComponents(child);
  43149. }
  43150. if (typeof child === 'function') {
  43151. child = child.options;
  43152. }
  43153. normalizeProps(child, vm);
  43154. normalizeInject(child, vm);
  43155. normalizeDirectives(child);
  43156. // Apply extends and mixins on the child options,
  43157. // but only if it is a raw options object that isn't
  43158. // the result of another mergeOptions call.
  43159. // Only merged options has the _base property.
  43160. if (!child._base) {
  43161. if (child.extends) {
  43162. parent = mergeOptions(parent, child.extends, vm);
  43163. }
  43164. if (child.mixins) {
  43165. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43166. parent = mergeOptions(parent, child.mixins[i], vm);
  43167. }
  43168. }
  43169. }
  43170. var options = {};
  43171. var key;
  43172. for (key in parent) {
  43173. mergeField(key);
  43174. }
  43175. for (key in child) {
  43176. if (!hasOwn(parent, key)) {
  43177. mergeField(key);
  43178. }
  43179. }
  43180. function mergeField (key) {
  43181. var strat = strats[key] || defaultStrat;
  43182. options[key] = strat(parent[key], child[key], vm, key);
  43183. }
  43184. return options
  43185. }
  43186. /**
  43187. * Resolve an asset.
  43188. * This function is used because child instances need access
  43189. * to assets defined in its ancestor chain.
  43190. */
  43191. function resolveAsset (
  43192. options,
  43193. type,
  43194. id,
  43195. warnMissing
  43196. ) {
  43197. /* istanbul ignore if */
  43198. if (typeof id !== 'string') {
  43199. return
  43200. }
  43201. var assets = options[type];
  43202. // check local registration variations first
  43203. if (hasOwn(assets, id)) { return assets[id] }
  43204. var camelizedId = camelize(id);
  43205. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43206. var PascalCaseId = capitalize(camelizedId);
  43207. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43208. // fallback to prototype chain
  43209. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43210. if (warnMissing && !res) {
  43211. warn(
  43212. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43213. options
  43214. );
  43215. }
  43216. return res
  43217. }
  43218. /* */
  43219. function validateProp (
  43220. key,
  43221. propOptions,
  43222. propsData,
  43223. vm
  43224. ) {
  43225. var prop = propOptions[key];
  43226. var absent = !hasOwn(propsData, key);
  43227. var value = propsData[key];
  43228. // boolean casting
  43229. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43230. if (booleanIndex > -1) {
  43231. if (absent && !hasOwn(prop, 'default')) {
  43232. value = false;
  43233. } else if (value === '' || value === hyphenate(key)) {
  43234. // only cast empty string / same name to boolean if
  43235. // boolean has higher priority
  43236. var stringIndex = getTypeIndex(String, prop.type);
  43237. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43238. value = true;
  43239. }
  43240. }
  43241. }
  43242. // check default value
  43243. if (value === undefined) {
  43244. value = getPropDefaultValue(vm, prop, key);
  43245. // since the default value is a fresh copy,
  43246. // make sure to observe it.
  43247. var prevShouldObserve = shouldObserve;
  43248. toggleObserving(true);
  43249. observe(value);
  43250. toggleObserving(prevShouldObserve);
  43251. }
  43252. {
  43253. assertProp(prop, key, value, vm, absent);
  43254. }
  43255. return value
  43256. }
  43257. /**
  43258. * Get the default value of a prop.
  43259. */
  43260. function getPropDefaultValue (vm, prop, key) {
  43261. // no default, return undefined
  43262. if (!hasOwn(prop, 'default')) {
  43263. return undefined
  43264. }
  43265. var def = prop.default;
  43266. // warn against non-factory defaults for Object & Array
  43267. if (isObject(def)) {
  43268. warn(
  43269. 'Invalid default value for prop "' + key + '": ' +
  43270. 'Props with type Object/Array must use a factory function ' +
  43271. 'to return the default value.',
  43272. vm
  43273. );
  43274. }
  43275. // the raw prop value was also undefined from previous render,
  43276. // return previous default value to avoid unnecessary watcher trigger
  43277. if (vm && vm.$options.propsData &&
  43278. vm.$options.propsData[key] === undefined &&
  43279. vm._props[key] !== undefined
  43280. ) {
  43281. return vm._props[key]
  43282. }
  43283. // call factory function for non-Function types
  43284. // a value is Function if its prototype is function even across different execution context
  43285. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43286. ? def.call(vm)
  43287. : def
  43288. }
  43289. /**
  43290. * Assert whether a prop is valid.
  43291. */
  43292. function assertProp (
  43293. prop,
  43294. name,
  43295. value,
  43296. vm,
  43297. absent
  43298. ) {
  43299. if (prop.required && absent) {
  43300. warn(
  43301. 'Missing required prop: "' + name + '"',
  43302. vm
  43303. );
  43304. return
  43305. }
  43306. if (value == null && !prop.required) {
  43307. return
  43308. }
  43309. var type = prop.type;
  43310. var valid = !type || type === true;
  43311. var expectedTypes = [];
  43312. if (type) {
  43313. if (!Array.isArray(type)) {
  43314. type = [type];
  43315. }
  43316. for (var i = 0; i < type.length && !valid; i++) {
  43317. var assertedType = assertType(value, type[i]);
  43318. expectedTypes.push(assertedType.expectedType || '');
  43319. valid = assertedType.valid;
  43320. }
  43321. }
  43322. if (!valid) {
  43323. warn(
  43324. getInvalidTypeMessage(name, value, expectedTypes),
  43325. vm
  43326. );
  43327. return
  43328. }
  43329. var validator = prop.validator;
  43330. if (validator) {
  43331. if (!validator(value)) {
  43332. warn(
  43333. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43334. vm
  43335. );
  43336. }
  43337. }
  43338. }
  43339. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43340. function assertType (value, type) {
  43341. var valid;
  43342. var expectedType = getType(type);
  43343. if (simpleCheckRE.test(expectedType)) {
  43344. var t = typeof value;
  43345. valid = t === expectedType.toLowerCase();
  43346. // for primitive wrapper objects
  43347. if (!valid && t === 'object') {
  43348. valid = value instanceof type;
  43349. }
  43350. } else if (expectedType === 'Object') {
  43351. valid = isPlainObject(value);
  43352. } else if (expectedType === 'Array') {
  43353. valid = Array.isArray(value);
  43354. } else {
  43355. valid = value instanceof type;
  43356. }
  43357. return {
  43358. valid: valid,
  43359. expectedType: expectedType
  43360. }
  43361. }
  43362. /**
  43363. * Use function string name to check built-in types,
  43364. * because a simple equality check will fail when running
  43365. * across different vms / iframes.
  43366. */
  43367. function getType (fn) {
  43368. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43369. return match ? match[1] : ''
  43370. }
  43371. function isSameType (a, b) {
  43372. return getType(a) === getType(b)
  43373. }
  43374. function getTypeIndex (type, expectedTypes) {
  43375. if (!Array.isArray(expectedTypes)) {
  43376. return isSameType(expectedTypes, type) ? 0 : -1
  43377. }
  43378. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43379. if (isSameType(expectedTypes[i], type)) {
  43380. return i
  43381. }
  43382. }
  43383. return -1
  43384. }
  43385. function getInvalidTypeMessage (name, value, expectedTypes) {
  43386. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43387. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43388. var expectedType = expectedTypes[0];
  43389. var receivedType = toRawType(value);
  43390. var expectedValue = styleValue(value, expectedType);
  43391. var receivedValue = styleValue(value, receivedType);
  43392. // check if we need to specify expected value
  43393. if (expectedTypes.length === 1 &&
  43394. isExplicable(expectedType) &&
  43395. !isBoolean(expectedType, receivedType)) {
  43396. message += " with value " + expectedValue;
  43397. }
  43398. message += ", got " + receivedType + " ";
  43399. // check if we need to specify received value
  43400. if (isExplicable(receivedType)) {
  43401. message += "with value " + receivedValue + ".";
  43402. }
  43403. return message
  43404. }
  43405. function styleValue (value, type) {
  43406. if (type === 'String') {
  43407. return ("\"" + value + "\"")
  43408. } else if (type === 'Number') {
  43409. return ("" + (Number(value)))
  43410. } else {
  43411. return ("" + value)
  43412. }
  43413. }
  43414. function isExplicable (value) {
  43415. var explicitTypes = ['string', 'number', 'boolean'];
  43416. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43417. }
  43418. function isBoolean () {
  43419. var args = [], len = arguments.length;
  43420. while ( len-- ) args[ len ] = arguments[ len ];
  43421. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43422. }
  43423. /* */
  43424. function handleError (err, vm, info) {
  43425. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43426. // See: https://github.com/vuejs/vuex/issues/1505
  43427. pushTarget();
  43428. try {
  43429. if (vm) {
  43430. var cur = vm;
  43431. while ((cur = cur.$parent)) {
  43432. var hooks = cur.$options.errorCaptured;
  43433. if (hooks) {
  43434. for (var i = 0; i < hooks.length; i++) {
  43435. try {
  43436. var capture = hooks[i].call(cur, err, vm, info) === false;
  43437. if (capture) { return }
  43438. } catch (e) {
  43439. globalHandleError(e, cur, 'errorCaptured hook');
  43440. }
  43441. }
  43442. }
  43443. }
  43444. }
  43445. globalHandleError(err, vm, info);
  43446. } finally {
  43447. popTarget();
  43448. }
  43449. }
  43450. function invokeWithErrorHandling (
  43451. handler,
  43452. context,
  43453. args,
  43454. vm,
  43455. info
  43456. ) {
  43457. var res;
  43458. try {
  43459. res = args ? handler.apply(context, args) : handler.call(context);
  43460. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43461. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43462. // issue #9511
  43463. // avoid catch triggering multiple times when nested calls
  43464. res._handled = true;
  43465. }
  43466. } catch (e) {
  43467. handleError(e, vm, info);
  43468. }
  43469. return res
  43470. }
  43471. function globalHandleError (err, vm, info) {
  43472. if (config.errorHandler) {
  43473. try {
  43474. return config.errorHandler.call(null, err, vm, info)
  43475. } catch (e) {
  43476. // if the user intentionally throws the original error in the handler,
  43477. // do not log it twice
  43478. if (e !== err) {
  43479. logError(e, null, 'config.errorHandler');
  43480. }
  43481. }
  43482. }
  43483. logError(err, vm, info);
  43484. }
  43485. function logError (err, vm, info) {
  43486. {
  43487. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43488. }
  43489. /* istanbul ignore else */
  43490. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43491. console.error(err);
  43492. } else {
  43493. throw err
  43494. }
  43495. }
  43496. /* */
  43497. var isUsingMicroTask = false;
  43498. var callbacks = [];
  43499. var pending = false;
  43500. function flushCallbacks () {
  43501. pending = false;
  43502. var copies = callbacks.slice(0);
  43503. callbacks.length = 0;
  43504. for (var i = 0; i < copies.length; i++) {
  43505. copies[i]();
  43506. }
  43507. }
  43508. // Here we have async deferring wrappers using microtasks.
  43509. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43510. // However, it has subtle problems when state is changed right before repaint
  43511. // (e.g. #6813, out-in transitions).
  43512. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43513. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43514. // So we now use microtasks everywhere, again.
  43515. // A major drawback of this tradeoff is that there are some scenarios
  43516. // where microtasks have too high a priority and fire in between supposedly
  43517. // sequential events (e.g. #4521, #6690, which have workarounds)
  43518. // or even between bubbling of the same event (#6566).
  43519. var timerFunc;
  43520. // The nextTick behavior leverages the microtask queue, which can be accessed
  43521. // via either native Promise.then or MutationObserver.
  43522. // MutationObserver has wider support, however it is seriously bugged in
  43523. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43524. // completely stops working after triggering a few times... so, if native
  43525. // Promise is available, we will use it:
  43526. /* istanbul ignore next, $flow-disable-line */
  43527. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43528. var p = Promise.resolve();
  43529. timerFunc = function () {
  43530. p.then(flushCallbacks);
  43531. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43532. // it can get stuck in a weird state where callbacks are pushed into the
  43533. // microtask queue but the queue isn't being flushed, until the browser
  43534. // needs to do some other work, e.g. handle a timer. Therefore we can
  43535. // "force" the microtask queue to be flushed by adding an empty timer.
  43536. if (isIOS) { setTimeout(noop); }
  43537. };
  43538. isUsingMicroTask = true;
  43539. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43540. isNative(MutationObserver) ||
  43541. // PhantomJS and iOS 7.x
  43542. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43543. )) {
  43544. // Use MutationObserver where native Promise is not available,
  43545. // e.g. PhantomJS, iOS7, Android 4.4
  43546. // (#6466 MutationObserver is unreliable in IE11)
  43547. var counter = 1;
  43548. var observer = new MutationObserver(flushCallbacks);
  43549. var textNode = document.createTextNode(String(counter));
  43550. observer.observe(textNode, {
  43551. characterData: true
  43552. });
  43553. timerFunc = function () {
  43554. counter = (counter + 1) % 2;
  43555. textNode.data = String(counter);
  43556. };
  43557. isUsingMicroTask = true;
  43558. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43559. // Fallback to setImmediate.
  43560. // Technically it leverages the (macro) task queue,
  43561. // but it is still a better choice than setTimeout.
  43562. timerFunc = function () {
  43563. setImmediate(flushCallbacks);
  43564. };
  43565. } else {
  43566. // Fallback to setTimeout.
  43567. timerFunc = function () {
  43568. setTimeout(flushCallbacks, 0);
  43569. };
  43570. }
  43571. function nextTick (cb, ctx) {
  43572. var _resolve;
  43573. callbacks.push(function () {
  43574. if (cb) {
  43575. try {
  43576. cb.call(ctx);
  43577. } catch (e) {
  43578. handleError(e, ctx, 'nextTick');
  43579. }
  43580. } else if (_resolve) {
  43581. _resolve(ctx);
  43582. }
  43583. });
  43584. if (!pending) {
  43585. pending = true;
  43586. timerFunc();
  43587. }
  43588. // $flow-disable-line
  43589. if (!cb && typeof Promise !== 'undefined') {
  43590. return new Promise(function (resolve) {
  43591. _resolve = resolve;
  43592. })
  43593. }
  43594. }
  43595. /* */
  43596. var mark;
  43597. var measure;
  43598. {
  43599. var perf = inBrowser && window.performance;
  43600. /* istanbul ignore if */
  43601. if (
  43602. perf &&
  43603. perf.mark &&
  43604. perf.measure &&
  43605. perf.clearMarks &&
  43606. perf.clearMeasures
  43607. ) {
  43608. mark = function (tag) { return perf.mark(tag); };
  43609. measure = function (name, startTag, endTag) {
  43610. perf.measure(name, startTag, endTag);
  43611. perf.clearMarks(startTag);
  43612. perf.clearMarks(endTag);
  43613. // perf.clearMeasures(name)
  43614. };
  43615. }
  43616. }
  43617. /* not type checking this file because flow doesn't play well with Proxy */
  43618. var initProxy;
  43619. {
  43620. var allowedGlobals = makeMap(
  43621. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43622. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43623. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43624. 'require' // for Webpack/Browserify
  43625. );
  43626. var warnNonPresent = function (target, key) {
  43627. warn(
  43628. "Property or method \"" + key + "\" is not defined on the instance but " +
  43629. 'referenced during render. Make sure that this property is reactive, ' +
  43630. 'either in the data option, or for class-based components, by ' +
  43631. 'initializing the property. ' +
  43632. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43633. target
  43634. );
  43635. };
  43636. var warnReservedPrefix = function (target, key) {
  43637. warn(
  43638. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43639. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43640. 'prevent conflicts with Vue internals. ' +
  43641. 'See: https://vuejs.org/v2/api/#data',
  43642. target
  43643. );
  43644. };
  43645. var hasProxy =
  43646. typeof Proxy !== 'undefined' && isNative(Proxy);
  43647. if (hasProxy) {
  43648. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43649. config.keyCodes = new Proxy(config.keyCodes, {
  43650. set: function set (target, key, value) {
  43651. if (isBuiltInModifier(key)) {
  43652. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43653. return false
  43654. } else {
  43655. target[key] = value;
  43656. return true
  43657. }
  43658. }
  43659. });
  43660. }
  43661. var hasHandler = {
  43662. has: function has (target, key) {
  43663. var has = key in target;
  43664. var isAllowed = allowedGlobals(key) ||
  43665. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43666. if (!has && !isAllowed) {
  43667. if (key in target.$data) { warnReservedPrefix(target, key); }
  43668. else { warnNonPresent(target, key); }
  43669. }
  43670. return has || !isAllowed
  43671. }
  43672. };
  43673. var getHandler = {
  43674. get: function get (target, key) {
  43675. if (typeof key === 'string' && !(key in target)) {
  43676. if (key in target.$data) { warnReservedPrefix(target, key); }
  43677. else { warnNonPresent(target, key); }
  43678. }
  43679. return target[key]
  43680. }
  43681. };
  43682. initProxy = function initProxy (vm) {
  43683. if (hasProxy) {
  43684. // determine which proxy handler to use
  43685. var options = vm.$options;
  43686. var handlers = options.render && options.render._withStripped
  43687. ? getHandler
  43688. : hasHandler;
  43689. vm._renderProxy = new Proxy(vm, handlers);
  43690. } else {
  43691. vm._renderProxy = vm;
  43692. }
  43693. };
  43694. }
  43695. /* */
  43696. var seenObjects = new _Set();
  43697. /**
  43698. * Recursively traverse an object to evoke all converted
  43699. * getters, so that every nested property inside the object
  43700. * is collected as a "deep" dependency.
  43701. */
  43702. function traverse (val) {
  43703. _traverse(val, seenObjects);
  43704. seenObjects.clear();
  43705. }
  43706. function _traverse (val, seen) {
  43707. var i, keys;
  43708. var isA = Array.isArray(val);
  43709. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43710. return
  43711. }
  43712. if (val.__ob__) {
  43713. var depId = val.__ob__.dep.id;
  43714. if (seen.has(depId)) {
  43715. return
  43716. }
  43717. seen.add(depId);
  43718. }
  43719. if (isA) {
  43720. i = val.length;
  43721. while (i--) { _traverse(val[i], seen); }
  43722. } else {
  43723. keys = Object.keys(val);
  43724. i = keys.length;
  43725. while (i--) { _traverse(val[keys[i]], seen); }
  43726. }
  43727. }
  43728. /* */
  43729. var normalizeEvent = cached(function (name) {
  43730. var passive = name.charAt(0) === '&';
  43731. name = passive ? name.slice(1) : name;
  43732. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43733. name = once$$1 ? name.slice(1) : name;
  43734. var capture = name.charAt(0) === '!';
  43735. name = capture ? name.slice(1) : name;
  43736. return {
  43737. name: name,
  43738. once: once$$1,
  43739. capture: capture,
  43740. passive: passive
  43741. }
  43742. });
  43743. function createFnInvoker (fns, vm) {
  43744. function invoker () {
  43745. var arguments$1 = arguments;
  43746. var fns = invoker.fns;
  43747. if (Array.isArray(fns)) {
  43748. var cloned = fns.slice();
  43749. for (var i = 0; i < cloned.length; i++) {
  43750. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43751. }
  43752. } else {
  43753. // return handler return value for single handlers
  43754. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43755. }
  43756. }
  43757. invoker.fns = fns;
  43758. return invoker
  43759. }
  43760. function updateListeners (
  43761. on,
  43762. oldOn,
  43763. add,
  43764. remove$$1,
  43765. createOnceHandler,
  43766. vm
  43767. ) {
  43768. var name, def$$1, cur, old, event;
  43769. for (name in on) {
  43770. def$$1 = cur = on[name];
  43771. old = oldOn[name];
  43772. event = normalizeEvent(name);
  43773. if (isUndef(cur)) {
  43774. warn(
  43775. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43776. vm
  43777. );
  43778. } else if (isUndef(old)) {
  43779. if (isUndef(cur.fns)) {
  43780. cur = on[name] = createFnInvoker(cur, vm);
  43781. }
  43782. if (isTrue(event.once)) {
  43783. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43784. }
  43785. add(event.name, cur, event.capture, event.passive, event.params);
  43786. } else if (cur !== old) {
  43787. old.fns = cur;
  43788. on[name] = old;
  43789. }
  43790. }
  43791. for (name in oldOn) {
  43792. if (isUndef(on[name])) {
  43793. event = normalizeEvent(name);
  43794. remove$$1(event.name, oldOn[name], event.capture);
  43795. }
  43796. }
  43797. }
  43798. /* */
  43799. function mergeVNodeHook (def, hookKey, hook) {
  43800. if (def instanceof VNode) {
  43801. def = def.data.hook || (def.data.hook = {});
  43802. }
  43803. var invoker;
  43804. var oldHook = def[hookKey];
  43805. function wrappedHook () {
  43806. hook.apply(this, arguments);
  43807. // important: remove merged hook to ensure it's called only once
  43808. // and prevent memory leak
  43809. remove(invoker.fns, wrappedHook);
  43810. }
  43811. if (isUndef(oldHook)) {
  43812. // no existing hook
  43813. invoker = createFnInvoker([wrappedHook]);
  43814. } else {
  43815. /* istanbul ignore if */
  43816. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43817. // already a merged invoker
  43818. invoker = oldHook;
  43819. invoker.fns.push(wrappedHook);
  43820. } else {
  43821. // existing plain hook
  43822. invoker = createFnInvoker([oldHook, wrappedHook]);
  43823. }
  43824. }
  43825. invoker.merged = true;
  43826. def[hookKey] = invoker;
  43827. }
  43828. /* */
  43829. function extractPropsFromVNodeData (
  43830. data,
  43831. Ctor,
  43832. tag
  43833. ) {
  43834. // we are only extracting raw values here.
  43835. // validation and default values are handled in the child
  43836. // component itself.
  43837. var propOptions = Ctor.options.props;
  43838. if (isUndef(propOptions)) {
  43839. return
  43840. }
  43841. var res = {};
  43842. var attrs = data.attrs;
  43843. var props = data.props;
  43844. if (isDef(attrs) || isDef(props)) {
  43845. for (var key in propOptions) {
  43846. var altKey = hyphenate(key);
  43847. {
  43848. var keyInLowerCase = key.toLowerCase();
  43849. if (
  43850. key !== keyInLowerCase &&
  43851. attrs && hasOwn(attrs, keyInLowerCase)
  43852. ) {
  43853. tip(
  43854. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43855. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43856. " \"" + key + "\". " +
  43857. "Note that HTML attributes are case-insensitive and camelCased " +
  43858. "props need to use their kebab-case equivalents when using in-DOM " +
  43859. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  43860. );
  43861. }
  43862. }
  43863. checkProp(res, props, key, altKey, true) ||
  43864. checkProp(res, attrs, key, altKey, false);
  43865. }
  43866. }
  43867. return res
  43868. }
  43869. function checkProp (
  43870. res,
  43871. hash,
  43872. key,
  43873. altKey,
  43874. preserve
  43875. ) {
  43876. if (isDef(hash)) {
  43877. if (hasOwn(hash, key)) {
  43878. res[key] = hash[key];
  43879. if (!preserve) {
  43880. delete hash[key];
  43881. }
  43882. return true
  43883. } else if (hasOwn(hash, altKey)) {
  43884. res[key] = hash[altKey];
  43885. if (!preserve) {
  43886. delete hash[altKey];
  43887. }
  43888. return true
  43889. }
  43890. }
  43891. return false
  43892. }
  43893. /* */
  43894. // The template compiler attempts to minimize the need for normalization by
  43895. // statically analyzing the template at compile time.
  43896. //
  43897. // For plain HTML markup, normalization can be completely skipped because the
  43898. // generated render function is guaranteed to return Array<VNode>. There are
  43899. // two cases where extra normalization is needed:
  43900. // 1. When the children contains components - because a functional component
  43901. // may return an Array instead of a single root. In this case, just a simple
  43902. // normalization is needed - if any child is an Array, we flatten the whole
  43903. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  43904. // because functional components already normalize their own children.
  43905. function simpleNormalizeChildren (children) {
  43906. for (var i = 0; i < children.length; i++) {
  43907. if (Array.isArray(children[i])) {
  43908. return Array.prototype.concat.apply([], children)
  43909. }
  43910. }
  43911. return children
  43912. }
  43913. // 2. When the children contains constructs that always generated nested Arrays,
  43914. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  43915. // with hand-written render functions / JSX. In such cases a full normalization
  43916. // is needed to cater to all possible types of children values.
  43917. function normalizeChildren (children) {
  43918. return isPrimitive(children)
  43919. ? [createTextVNode(children)]
  43920. : Array.isArray(children)
  43921. ? normalizeArrayChildren(children)
  43922. : undefined
  43923. }
  43924. function isTextNode (node) {
  43925. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  43926. }
  43927. function normalizeArrayChildren (children, nestedIndex) {
  43928. var res = [];
  43929. var i, c, lastIndex, last;
  43930. for (i = 0; i < children.length; i++) {
  43931. c = children[i];
  43932. if (isUndef(c) || typeof c === 'boolean') { continue }
  43933. lastIndex = res.length - 1;
  43934. last = res[lastIndex];
  43935. // nested
  43936. if (Array.isArray(c)) {
  43937. if (c.length > 0) {
  43938. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  43939. // merge adjacent text nodes
  43940. if (isTextNode(c[0]) && isTextNode(last)) {
  43941. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  43942. c.shift();
  43943. }
  43944. res.push.apply(res, c);
  43945. }
  43946. } else if (isPrimitive(c)) {
  43947. if (isTextNode(last)) {
  43948. // merge adjacent text nodes
  43949. // this is necessary for SSR hydration because text nodes are
  43950. // essentially merged when rendered to HTML strings
  43951. res[lastIndex] = createTextVNode(last.text + c);
  43952. } else if (c !== '') {
  43953. // convert primitive to vnode
  43954. res.push(createTextVNode(c));
  43955. }
  43956. } else {
  43957. if (isTextNode(c) && isTextNode(last)) {
  43958. // merge adjacent text nodes
  43959. res[lastIndex] = createTextVNode(last.text + c.text);
  43960. } else {
  43961. // default key for nested array children (likely generated by v-for)
  43962. if (isTrue(children._isVList) &&
  43963. isDef(c.tag) &&
  43964. isUndef(c.key) &&
  43965. isDef(nestedIndex)) {
  43966. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  43967. }
  43968. res.push(c);
  43969. }
  43970. }
  43971. }
  43972. return res
  43973. }
  43974. /* */
  43975. function initProvide (vm) {
  43976. var provide = vm.$options.provide;
  43977. if (provide) {
  43978. vm._provided = typeof provide === 'function'
  43979. ? provide.call(vm)
  43980. : provide;
  43981. }
  43982. }
  43983. function initInjections (vm) {
  43984. var result = resolveInject(vm.$options.inject, vm);
  43985. if (result) {
  43986. toggleObserving(false);
  43987. Object.keys(result).forEach(function (key) {
  43988. /* istanbul ignore else */
  43989. {
  43990. defineReactive$$1(vm, key, result[key], function () {
  43991. warn(
  43992. "Avoid mutating an injected value directly since the changes will be " +
  43993. "overwritten whenever the provided component re-renders. " +
  43994. "injection being mutated: \"" + key + "\"",
  43995. vm
  43996. );
  43997. });
  43998. }
  43999. });
  44000. toggleObserving(true);
  44001. }
  44002. }
  44003. function resolveInject (inject, vm) {
  44004. if (inject) {
  44005. // inject is :any because flow is not smart enough to figure out cached
  44006. var result = Object.create(null);
  44007. var keys = hasSymbol
  44008. ? Reflect.ownKeys(inject)
  44009. : Object.keys(inject);
  44010. for (var i = 0; i < keys.length; i++) {
  44011. var key = keys[i];
  44012. // #6574 in case the inject object is observed...
  44013. if (key === '__ob__') { continue }
  44014. var provideKey = inject[key].from;
  44015. var source = vm;
  44016. while (source) {
  44017. if (source._provided && hasOwn(source._provided, provideKey)) {
  44018. result[key] = source._provided[provideKey];
  44019. break
  44020. }
  44021. source = source.$parent;
  44022. }
  44023. if (!source) {
  44024. if ('default' in inject[key]) {
  44025. var provideDefault = inject[key].default;
  44026. result[key] = typeof provideDefault === 'function'
  44027. ? provideDefault.call(vm)
  44028. : provideDefault;
  44029. } else {
  44030. warn(("Injection \"" + key + "\" not found"), vm);
  44031. }
  44032. }
  44033. }
  44034. return result
  44035. }
  44036. }
  44037. /* */
  44038. /**
  44039. * Runtime helper for resolving raw children VNodes into a slot object.
  44040. */
  44041. function resolveSlots (
  44042. children,
  44043. context
  44044. ) {
  44045. if (!children || !children.length) {
  44046. return {}
  44047. }
  44048. var slots = {};
  44049. for (var i = 0, l = children.length; i < l; i++) {
  44050. var child = children[i];
  44051. var data = child.data;
  44052. // remove slot attribute if the node is resolved as a Vue slot node
  44053. if (data && data.attrs && data.attrs.slot) {
  44054. delete data.attrs.slot;
  44055. }
  44056. // named slots should only be respected if the vnode was rendered in the
  44057. // same context.
  44058. if ((child.context === context || child.fnContext === context) &&
  44059. data && data.slot != null
  44060. ) {
  44061. var name = data.slot;
  44062. var slot = (slots[name] || (slots[name] = []));
  44063. if (child.tag === 'template') {
  44064. slot.push.apply(slot, child.children || []);
  44065. } else {
  44066. slot.push(child);
  44067. }
  44068. } else {
  44069. (slots.default || (slots.default = [])).push(child);
  44070. }
  44071. }
  44072. // ignore slots that contains only whitespace
  44073. for (var name$1 in slots) {
  44074. if (slots[name$1].every(isWhitespace)) {
  44075. delete slots[name$1];
  44076. }
  44077. }
  44078. return slots
  44079. }
  44080. function isWhitespace (node) {
  44081. return (node.isComment && !node.asyncFactory) || node.text === ' '
  44082. }
  44083. /* */
  44084. function normalizeScopedSlots (
  44085. slots,
  44086. normalSlots,
  44087. prevSlots
  44088. ) {
  44089. var res;
  44090. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44091. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44092. var key = slots && slots.$key;
  44093. if (!slots) {
  44094. res = {};
  44095. } else if (slots._normalized) {
  44096. // fast path 1: child component re-render only, parent did not change
  44097. return slots._normalized
  44098. } else if (
  44099. isStable &&
  44100. prevSlots &&
  44101. prevSlots !== emptyObject &&
  44102. key === prevSlots.$key &&
  44103. !hasNormalSlots &&
  44104. !prevSlots.$hasNormal
  44105. ) {
  44106. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44107. // only need to normalize once
  44108. return prevSlots
  44109. } else {
  44110. res = {};
  44111. for (var key$1 in slots) {
  44112. if (slots[key$1] && key$1[0] !== '$') {
  44113. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44114. }
  44115. }
  44116. }
  44117. // expose normal slots on scopedSlots
  44118. for (var key$2 in normalSlots) {
  44119. if (!(key$2 in res)) {
  44120. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44121. }
  44122. }
  44123. // avoriaz seems to mock a non-extensible $scopedSlots object
  44124. // and when that is passed down this would cause an error
  44125. if (slots && Object.isExtensible(slots)) {
  44126. (slots)._normalized = res;
  44127. }
  44128. def(res, '$stable', isStable);
  44129. def(res, '$key', key);
  44130. def(res, '$hasNormal', hasNormalSlots);
  44131. return res
  44132. }
  44133. function normalizeScopedSlot(normalSlots, key, fn) {
  44134. var normalized = function () {
  44135. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44136. res = res && typeof res === 'object' && !Array.isArray(res)
  44137. ? [res] // single vnode
  44138. : normalizeChildren(res);
  44139. return res && (
  44140. res.length === 0 ||
  44141. (res.length === 1 && res[0].isComment) // #9658
  44142. ) ? undefined
  44143. : res
  44144. };
  44145. // this is a slot using the new v-slot syntax without scope. although it is
  44146. // compiled as a scoped slot, render fn users would expect it to be present
  44147. // on this.$slots because the usage is semantically a normal slot.
  44148. if (fn.proxy) {
  44149. Object.defineProperty(normalSlots, key, {
  44150. get: normalized,
  44151. enumerable: true,
  44152. configurable: true
  44153. });
  44154. }
  44155. return normalized
  44156. }
  44157. function proxyNormalSlot(slots, key) {
  44158. return function () { return slots[key]; }
  44159. }
  44160. /* */
  44161. /**
  44162. * Runtime helper for rendering v-for lists.
  44163. */
  44164. function renderList (
  44165. val,
  44166. render
  44167. ) {
  44168. var ret, i, l, keys, key;
  44169. if (Array.isArray(val) || typeof val === 'string') {
  44170. ret = new Array(val.length);
  44171. for (i = 0, l = val.length; i < l; i++) {
  44172. ret[i] = render(val[i], i);
  44173. }
  44174. } else if (typeof val === 'number') {
  44175. ret = new Array(val);
  44176. for (i = 0; i < val; i++) {
  44177. ret[i] = render(i + 1, i);
  44178. }
  44179. } else if (isObject(val)) {
  44180. if (hasSymbol && val[Symbol.iterator]) {
  44181. ret = [];
  44182. var iterator = val[Symbol.iterator]();
  44183. var result = iterator.next();
  44184. while (!result.done) {
  44185. ret.push(render(result.value, ret.length));
  44186. result = iterator.next();
  44187. }
  44188. } else {
  44189. keys = Object.keys(val);
  44190. ret = new Array(keys.length);
  44191. for (i = 0, l = keys.length; i < l; i++) {
  44192. key = keys[i];
  44193. ret[i] = render(val[key], key, i);
  44194. }
  44195. }
  44196. }
  44197. if (!isDef(ret)) {
  44198. ret = [];
  44199. }
  44200. (ret)._isVList = true;
  44201. return ret
  44202. }
  44203. /* */
  44204. /**
  44205. * Runtime helper for rendering <slot>
  44206. */
  44207. function renderSlot (
  44208. name,
  44209. fallback,
  44210. props,
  44211. bindObject
  44212. ) {
  44213. var scopedSlotFn = this.$scopedSlots[name];
  44214. var nodes;
  44215. if (scopedSlotFn) { // scoped slot
  44216. props = props || {};
  44217. if (bindObject) {
  44218. if (!isObject(bindObject)) {
  44219. warn(
  44220. 'slot v-bind without argument expects an Object',
  44221. this
  44222. );
  44223. }
  44224. props = extend(extend({}, bindObject), props);
  44225. }
  44226. nodes = scopedSlotFn(props) || fallback;
  44227. } else {
  44228. nodes = this.$slots[name] || fallback;
  44229. }
  44230. var target = props && props.slot;
  44231. if (target) {
  44232. return this.$createElement('template', { slot: target }, nodes)
  44233. } else {
  44234. return nodes
  44235. }
  44236. }
  44237. /* */
  44238. /**
  44239. * Runtime helper for resolving filters
  44240. */
  44241. function resolveFilter (id) {
  44242. return resolveAsset(this.$options, 'filters', id, true) || identity
  44243. }
  44244. /* */
  44245. function isKeyNotMatch (expect, actual) {
  44246. if (Array.isArray(expect)) {
  44247. return expect.indexOf(actual) === -1
  44248. } else {
  44249. return expect !== actual
  44250. }
  44251. }
  44252. /**
  44253. * Runtime helper for checking keyCodes from config.
  44254. * exposed as Vue.prototype._k
  44255. * passing in eventKeyName as last argument separately for backwards compat
  44256. */
  44257. function checkKeyCodes (
  44258. eventKeyCode,
  44259. key,
  44260. builtInKeyCode,
  44261. eventKeyName,
  44262. builtInKeyName
  44263. ) {
  44264. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44265. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44266. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44267. } else if (mappedKeyCode) {
  44268. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44269. } else if (eventKeyName) {
  44270. return hyphenate(eventKeyName) !== key
  44271. }
  44272. }
  44273. /* */
  44274. /**
  44275. * Runtime helper for merging v-bind="object" into a VNode's data.
  44276. */
  44277. function bindObjectProps (
  44278. data,
  44279. tag,
  44280. value,
  44281. asProp,
  44282. isSync
  44283. ) {
  44284. if (value) {
  44285. if (!isObject(value)) {
  44286. warn(
  44287. 'v-bind without argument expects an Object or Array value',
  44288. this
  44289. );
  44290. } else {
  44291. if (Array.isArray(value)) {
  44292. value = toObject(value);
  44293. }
  44294. var hash;
  44295. var loop = function ( key ) {
  44296. if (
  44297. key === 'class' ||
  44298. key === 'style' ||
  44299. isReservedAttribute(key)
  44300. ) {
  44301. hash = data;
  44302. } else {
  44303. var type = data.attrs && data.attrs.type;
  44304. hash = asProp || config.mustUseProp(tag, type, key)
  44305. ? data.domProps || (data.domProps = {})
  44306. : data.attrs || (data.attrs = {});
  44307. }
  44308. var camelizedKey = camelize(key);
  44309. var hyphenatedKey = hyphenate(key);
  44310. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44311. hash[key] = value[key];
  44312. if (isSync) {
  44313. var on = data.on || (data.on = {});
  44314. on[("update:" + key)] = function ($event) {
  44315. value[key] = $event;
  44316. };
  44317. }
  44318. }
  44319. };
  44320. for (var key in value) loop( key );
  44321. }
  44322. }
  44323. return data
  44324. }
  44325. /* */
  44326. /**
  44327. * Runtime helper for rendering static trees.
  44328. */
  44329. function renderStatic (
  44330. index,
  44331. isInFor
  44332. ) {
  44333. var cached = this._staticTrees || (this._staticTrees = []);
  44334. var tree = cached[index];
  44335. // if has already-rendered static tree and not inside v-for,
  44336. // we can reuse the same tree.
  44337. if (tree && !isInFor) {
  44338. return tree
  44339. }
  44340. // otherwise, render a fresh tree.
  44341. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44342. this._renderProxy,
  44343. null,
  44344. this // for render fns generated for functional component templates
  44345. );
  44346. markStatic(tree, ("__static__" + index), false);
  44347. return tree
  44348. }
  44349. /**
  44350. * Runtime helper for v-once.
  44351. * Effectively it means marking the node as static with a unique key.
  44352. */
  44353. function markOnce (
  44354. tree,
  44355. index,
  44356. key
  44357. ) {
  44358. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44359. return tree
  44360. }
  44361. function markStatic (
  44362. tree,
  44363. key,
  44364. isOnce
  44365. ) {
  44366. if (Array.isArray(tree)) {
  44367. for (var i = 0; i < tree.length; i++) {
  44368. if (tree[i] && typeof tree[i] !== 'string') {
  44369. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44370. }
  44371. }
  44372. } else {
  44373. markStaticNode(tree, key, isOnce);
  44374. }
  44375. }
  44376. function markStaticNode (node, key, isOnce) {
  44377. node.isStatic = true;
  44378. node.key = key;
  44379. node.isOnce = isOnce;
  44380. }
  44381. /* */
  44382. function bindObjectListeners (data, value) {
  44383. if (value) {
  44384. if (!isPlainObject(value)) {
  44385. warn(
  44386. 'v-on without argument expects an Object value',
  44387. this
  44388. );
  44389. } else {
  44390. var on = data.on = data.on ? extend({}, data.on) : {};
  44391. for (var key in value) {
  44392. var existing = on[key];
  44393. var ours = value[key];
  44394. on[key] = existing ? [].concat(existing, ours) : ours;
  44395. }
  44396. }
  44397. }
  44398. return data
  44399. }
  44400. /* */
  44401. function resolveScopedSlots (
  44402. fns, // see flow/vnode
  44403. res,
  44404. // the following are added in 2.6
  44405. hasDynamicKeys,
  44406. contentHashKey
  44407. ) {
  44408. res = res || { $stable: !hasDynamicKeys };
  44409. for (var i = 0; i < fns.length; i++) {
  44410. var slot = fns[i];
  44411. if (Array.isArray(slot)) {
  44412. resolveScopedSlots(slot, res, hasDynamicKeys);
  44413. } else if (slot) {
  44414. // marker for reverse proxying v-slot without scope on this.$slots
  44415. if (slot.proxy) {
  44416. slot.fn.proxy = true;
  44417. }
  44418. res[slot.key] = slot.fn;
  44419. }
  44420. }
  44421. if (contentHashKey) {
  44422. (res).$key = contentHashKey;
  44423. }
  44424. return res
  44425. }
  44426. /* */
  44427. function bindDynamicKeys (baseObj, values) {
  44428. for (var i = 0; i < values.length; i += 2) {
  44429. var key = values[i];
  44430. if (typeof key === 'string' && key) {
  44431. baseObj[values[i]] = values[i + 1];
  44432. } else if (key !== '' && key !== null) {
  44433. // null is a special value for explicitly removing a binding
  44434. warn(
  44435. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44436. this
  44437. );
  44438. }
  44439. }
  44440. return baseObj
  44441. }
  44442. // helper to dynamically append modifier runtime markers to event names.
  44443. // ensure only append when value is already string, otherwise it will be cast
  44444. // to string and cause the type check to miss.
  44445. function prependModifier (value, symbol) {
  44446. return typeof value === 'string' ? symbol + value : value
  44447. }
  44448. /* */
  44449. function installRenderHelpers (target) {
  44450. target._o = markOnce;
  44451. target._n = toNumber;
  44452. target._s = toString;
  44453. target._l = renderList;
  44454. target._t = renderSlot;
  44455. target._q = looseEqual;
  44456. target._i = looseIndexOf;
  44457. target._m = renderStatic;
  44458. target._f = resolveFilter;
  44459. target._k = checkKeyCodes;
  44460. target._b = bindObjectProps;
  44461. target._v = createTextVNode;
  44462. target._e = createEmptyVNode;
  44463. target._u = resolveScopedSlots;
  44464. target._g = bindObjectListeners;
  44465. target._d = bindDynamicKeys;
  44466. target._p = prependModifier;
  44467. }
  44468. /* */
  44469. function FunctionalRenderContext (
  44470. data,
  44471. props,
  44472. children,
  44473. parent,
  44474. Ctor
  44475. ) {
  44476. var this$1 = this;
  44477. var options = Ctor.options;
  44478. // ensure the createElement function in functional components
  44479. // gets a unique context - this is necessary for correct named slot check
  44480. var contextVm;
  44481. if (hasOwn(parent, '_uid')) {
  44482. contextVm = Object.create(parent);
  44483. // $flow-disable-line
  44484. contextVm._original = parent;
  44485. } else {
  44486. // the context vm passed in is a functional context as well.
  44487. // in this case we want to make sure we are able to get a hold to the
  44488. // real context instance.
  44489. contextVm = parent;
  44490. // $flow-disable-line
  44491. parent = parent._original;
  44492. }
  44493. var isCompiled = isTrue(options._compiled);
  44494. var needNormalization = !isCompiled;
  44495. this.data = data;
  44496. this.props = props;
  44497. this.children = children;
  44498. this.parent = parent;
  44499. this.listeners = data.on || emptyObject;
  44500. this.injections = resolveInject(options.inject, parent);
  44501. this.slots = function () {
  44502. if (!this$1.$slots) {
  44503. normalizeScopedSlots(
  44504. data.scopedSlots,
  44505. this$1.$slots = resolveSlots(children, parent)
  44506. );
  44507. }
  44508. return this$1.$slots
  44509. };
  44510. Object.defineProperty(this, 'scopedSlots', ({
  44511. enumerable: true,
  44512. get: function get () {
  44513. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44514. }
  44515. }));
  44516. // support for compiled functional template
  44517. if (isCompiled) {
  44518. // exposing $options for renderStatic()
  44519. this.$options = options;
  44520. // pre-resolve slots for renderSlot()
  44521. this.$slots = this.slots();
  44522. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44523. }
  44524. if (options._scopeId) {
  44525. this._c = function (a, b, c, d) {
  44526. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44527. if (vnode && !Array.isArray(vnode)) {
  44528. vnode.fnScopeId = options._scopeId;
  44529. vnode.fnContext = parent;
  44530. }
  44531. return vnode
  44532. };
  44533. } else {
  44534. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44535. }
  44536. }
  44537. installRenderHelpers(FunctionalRenderContext.prototype);
  44538. function createFunctionalComponent (
  44539. Ctor,
  44540. propsData,
  44541. data,
  44542. contextVm,
  44543. children
  44544. ) {
  44545. var options = Ctor.options;
  44546. var props = {};
  44547. var propOptions = options.props;
  44548. if (isDef(propOptions)) {
  44549. for (var key in propOptions) {
  44550. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44551. }
  44552. } else {
  44553. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44554. if (isDef(data.props)) { mergeProps(props, data.props); }
  44555. }
  44556. var renderContext = new FunctionalRenderContext(
  44557. data,
  44558. props,
  44559. children,
  44560. contextVm,
  44561. Ctor
  44562. );
  44563. var vnode = options.render.call(null, renderContext._c, renderContext);
  44564. if (vnode instanceof VNode) {
  44565. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44566. } else if (Array.isArray(vnode)) {
  44567. var vnodes = normalizeChildren(vnode) || [];
  44568. var res = new Array(vnodes.length);
  44569. for (var i = 0; i < vnodes.length; i++) {
  44570. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44571. }
  44572. return res
  44573. }
  44574. }
  44575. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44576. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44577. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44578. // that should not be matched to match.
  44579. var clone = cloneVNode(vnode);
  44580. clone.fnContext = contextVm;
  44581. clone.fnOptions = options;
  44582. {
  44583. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44584. }
  44585. if (data.slot) {
  44586. (clone.data || (clone.data = {})).slot = data.slot;
  44587. }
  44588. return clone
  44589. }
  44590. function mergeProps (to, from) {
  44591. for (var key in from) {
  44592. to[camelize(key)] = from[key];
  44593. }
  44594. }
  44595. /* */
  44596. /* */
  44597. /* */
  44598. /* */
  44599. // inline hooks to be invoked on component VNodes during patch
  44600. var componentVNodeHooks = {
  44601. init: function init (vnode, hydrating) {
  44602. if (
  44603. vnode.componentInstance &&
  44604. !vnode.componentInstance._isDestroyed &&
  44605. vnode.data.keepAlive
  44606. ) {
  44607. // kept-alive components, treat as a patch
  44608. var mountedNode = vnode; // work around flow
  44609. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44610. } else {
  44611. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44612. vnode,
  44613. activeInstance
  44614. );
  44615. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44616. }
  44617. },
  44618. prepatch: function prepatch (oldVnode, vnode) {
  44619. var options = vnode.componentOptions;
  44620. var child = vnode.componentInstance = oldVnode.componentInstance;
  44621. updateChildComponent(
  44622. child,
  44623. options.propsData, // updated props
  44624. options.listeners, // updated listeners
  44625. vnode, // new parent vnode
  44626. options.children // new children
  44627. );
  44628. },
  44629. insert: function insert (vnode) {
  44630. var context = vnode.context;
  44631. var componentInstance = vnode.componentInstance;
  44632. if (!componentInstance._isMounted) {
  44633. componentInstance._isMounted = true;
  44634. callHook(componentInstance, 'mounted');
  44635. }
  44636. if (vnode.data.keepAlive) {
  44637. if (context._isMounted) {
  44638. // vue-router#1212
  44639. // During updates, a kept-alive component's child components may
  44640. // change, so directly walking the tree here may call activated hooks
  44641. // on incorrect children. Instead we push them into a queue which will
  44642. // be processed after the whole patch process ended.
  44643. queueActivatedComponent(componentInstance);
  44644. } else {
  44645. activateChildComponent(componentInstance, true /* direct */);
  44646. }
  44647. }
  44648. },
  44649. destroy: function destroy (vnode) {
  44650. var componentInstance = vnode.componentInstance;
  44651. if (!componentInstance._isDestroyed) {
  44652. if (!vnode.data.keepAlive) {
  44653. componentInstance.$destroy();
  44654. } else {
  44655. deactivateChildComponent(componentInstance, true /* direct */);
  44656. }
  44657. }
  44658. }
  44659. };
  44660. var hooksToMerge = Object.keys(componentVNodeHooks);
  44661. function createComponent (
  44662. Ctor,
  44663. data,
  44664. context,
  44665. children,
  44666. tag
  44667. ) {
  44668. if (isUndef(Ctor)) {
  44669. return
  44670. }
  44671. var baseCtor = context.$options._base;
  44672. // plain options object: turn it into a constructor
  44673. if (isObject(Ctor)) {
  44674. Ctor = baseCtor.extend(Ctor);
  44675. }
  44676. // if at this stage it's not a constructor or an async component factory,
  44677. // reject.
  44678. if (typeof Ctor !== 'function') {
  44679. {
  44680. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44681. }
  44682. return
  44683. }
  44684. // async component
  44685. var asyncFactory;
  44686. if (isUndef(Ctor.cid)) {
  44687. asyncFactory = Ctor;
  44688. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44689. if (Ctor === undefined) {
  44690. // return a placeholder node for async component, which is rendered
  44691. // as a comment node but preserves all the raw information for the node.
  44692. // the information will be used for async server-rendering and hydration.
  44693. return createAsyncPlaceholder(
  44694. asyncFactory,
  44695. data,
  44696. context,
  44697. children,
  44698. tag
  44699. )
  44700. }
  44701. }
  44702. data = data || {};
  44703. // resolve constructor options in case global mixins are applied after
  44704. // component constructor creation
  44705. resolveConstructorOptions(Ctor);
  44706. // transform component v-model data into props & events
  44707. if (isDef(data.model)) {
  44708. transformModel(Ctor.options, data);
  44709. }
  44710. // extract props
  44711. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44712. // functional component
  44713. if (isTrue(Ctor.options.functional)) {
  44714. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44715. }
  44716. // extract listeners, since these needs to be treated as
  44717. // child component listeners instead of DOM listeners
  44718. var listeners = data.on;
  44719. // replace with listeners with .native modifier
  44720. // so it gets processed during parent component patch.
  44721. data.on = data.nativeOn;
  44722. if (isTrue(Ctor.options.abstract)) {
  44723. // abstract components do not keep anything
  44724. // other than props & listeners & slot
  44725. // work around flow
  44726. var slot = data.slot;
  44727. data = {};
  44728. if (slot) {
  44729. data.slot = slot;
  44730. }
  44731. }
  44732. // install component management hooks onto the placeholder node
  44733. installComponentHooks(data);
  44734. // return a placeholder vnode
  44735. var name = Ctor.options.name || tag;
  44736. var vnode = new VNode(
  44737. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44738. data, undefined, undefined, undefined, context,
  44739. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44740. asyncFactory
  44741. );
  44742. return vnode
  44743. }
  44744. function createComponentInstanceForVnode (
  44745. vnode, // we know it's MountedComponentVNode but flow doesn't
  44746. parent // activeInstance in lifecycle state
  44747. ) {
  44748. var options = {
  44749. _isComponent: true,
  44750. _parentVnode: vnode,
  44751. parent: parent
  44752. };
  44753. // check inline-template render functions
  44754. var inlineTemplate = vnode.data.inlineTemplate;
  44755. if (isDef(inlineTemplate)) {
  44756. options.render = inlineTemplate.render;
  44757. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44758. }
  44759. return new vnode.componentOptions.Ctor(options)
  44760. }
  44761. function installComponentHooks (data) {
  44762. var hooks = data.hook || (data.hook = {});
  44763. for (var i = 0; i < hooksToMerge.length; i++) {
  44764. var key = hooksToMerge[i];
  44765. var existing = hooks[key];
  44766. var toMerge = componentVNodeHooks[key];
  44767. if (existing !== toMerge && !(existing && existing._merged)) {
  44768. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44769. }
  44770. }
  44771. }
  44772. function mergeHook$1 (f1, f2) {
  44773. var merged = function (a, b) {
  44774. // flow complains about extra args which is why we use any
  44775. f1(a, b);
  44776. f2(a, b);
  44777. };
  44778. merged._merged = true;
  44779. return merged
  44780. }
  44781. // transform component v-model info (value and callback) into
  44782. // prop and event handler respectively.
  44783. function transformModel (options, data) {
  44784. var prop = (options.model && options.model.prop) || 'value';
  44785. var event = (options.model && options.model.event) || 'input'
  44786. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44787. var on = data.on || (data.on = {});
  44788. var existing = on[event];
  44789. var callback = data.model.callback;
  44790. if (isDef(existing)) {
  44791. if (
  44792. Array.isArray(existing)
  44793. ? existing.indexOf(callback) === -1
  44794. : existing !== callback
  44795. ) {
  44796. on[event] = [callback].concat(existing);
  44797. }
  44798. } else {
  44799. on[event] = callback;
  44800. }
  44801. }
  44802. /* */
  44803. var SIMPLE_NORMALIZE = 1;
  44804. var ALWAYS_NORMALIZE = 2;
  44805. // wrapper function for providing a more flexible interface
  44806. // without getting yelled at by flow
  44807. function createElement (
  44808. context,
  44809. tag,
  44810. data,
  44811. children,
  44812. normalizationType,
  44813. alwaysNormalize
  44814. ) {
  44815. if (Array.isArray(data) || isPrimitive(data)) {
  44816. normalizationType = children;
  44817. children = data;
  44818. data = undefined;
  44819. }
  44820. if (isTrue(alwaysNormalize)) {
  44821. normalizationType = ALWAYS_NORMALIZE;
  44822. }
  44823. return _createElement(context, tag, data, children, normalizationType)
  44824. }
  44825. function _createElement (
  44826. context,
  44827. tag,
  44828. data,
  44829. children,
  44830. normalizationType
  44831. ) {
  44832. if (isDef(data) && isDef((data).__ob__)) {
  44833. warn(
  44834. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44835. 'Always create fresh vnode data objects in each render!',
  44836. context
  44837. );
  44838. return createEmptyVNode()
  44839. }
  44840. // object syntax in v-bind
  44841. if (isDef(data) && isDef(data.is)) {
  44842. tag = data.is;
  44843. }
  44844. if (!tag) {
  44845. // in case of component :is set to falsy value
  44846. return createEmptyVNode()
  44847. }
  44848. // warn against non-primitive key
  44849. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44850. ) {
  44851. {
  44852. warn(
  44853. 'Avoid using non-primitive value as key, ' +
  44854. 'use string/number value instead.',
  44855. context
  44856. );
  44857. }
  44858. }
  44859. // support single function children as default scoped slot
  44860. if (Array.isArray(children) &&
  44861. typeof children[0] === 'function'
  44862. ) {
  44863. data = data || {};
  44864. data.scopedSlots = { default: children[0] };
  44865. children.length = 0;
  44866. }
  44867. if (normalizationType === ALWAYS_NORMALIZE) {
  44868. children = normalizeChildren(children);
  44869. } else if (normalizationType === SIMPLE_NORMALIZE) {
  44870. children = simpleNormalizeChildren(children);
  44871. }
  44872. var vnode, ns;
  44873. if (typeof tag === 'string') {
  44874. var Ctor;
  44875. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  44876. if (config.isReservedTag(tag)) {
  44877. // platform built-in elements
  44878. if (isDef(data) && isDef(data.nativeOn)) {
  44879. warn(
  44880. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  44881. context
  44882. );
  44883. }
  44884. vnode = new VNode(
  44885. config.parsePlatformTagName(tag), data, children,
  44886. undefined, undefined, context
  44887. );
  44888. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  44889. // component
  44890. vnode = createComponent(Ctor, data, context, children, tag);
  44891. } else {
  44892. // unknown or unlisted namespaced elements
  44893. // check at runtime because it may get assigned a namespace when its
  44894. // parent normalizes children
  44895. vnode = new VNode(
  44896. tag, data, children,
  44897. undefined, undefined, context
  44898. );
  44899. }
  44900. } else {
  44901. // direct component options / constructor
  44902. vnode = createComponent(tag, data, context, children);
  44903. }
  44904. if (Array.isArray(vnode)) {
  44905. return vnode
  44906. } else if (isDef(vnode)) {
  44907. if (isDef(ns)) { applyNS(vnode, ns); }
  44908. if (isDef(data)) { registerDeepBindings(data); }
  44909. return vnode
  44910. } else {
  44911. return createEmptyVNode()
  44912. }
  44913. }
  44914. function applyNS (vnode, ns, force) {
  44915. vnode.ns = ns;
  44916. if (vnode.tag === 'foreignObject') {
  44917. // use default namespace inside foreignObject
  44918. ns = undefined;
  44919. force = true;
  44920. }
  44921. if (isDef(vnode.children)) {
  44922. for (var i = 0, l = vnode.children.length; i < l; i++) {
  44923. var child = vnode.children[i];
  44924. if (isDef(child.tag) && (
  44925. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  44926. applyNS(child, ns, force);
  44927. }
  44928. }
  44929. }
  44930. }
  44931. // ref #5318
  44932. // necessary to ensure parent re-render when deep bindings like :style and
  44933. // :class are used on slot nodes
  44934. function registerDeepBindings (data) {
  44935. if (isObject(data.style)) {
  44936. traverse(data.style);
  44937. }
  44938. if (isObject(data.class)) {
  44939. traverse(data.class);
  44940. }
  44941. }
  44942. /* */
  44943. function initRender (vm) {
  44944. vm._vnode = null; // the root of the child tree
  44945. vm._staticTrees = null; // v-once cached trees
  44946. var options = vm.$options;
  44947. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  44948. var renderContext = parentVnode && parentVnode.context;
  44949. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  44950. vm.$scopedSlots = emptyObject;
  44951. // bind the createElement fn to this instance
  44952. // so that we get proper render context inside it.
  44953. // args order: tag, data, children, normalizationType, alwaysNormalize
  44954. // internal version is used by render functions compiled from templates
  44955. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  44956. // normalization is always applied for the public version, used in
  44957. // user-written render functions.
  44958. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  44959. // $attrs & $listeners are exposed for easier HOC creation.
  44960. // they need to be reactive so that HOCs using them are always updated
  44961. var parentData = parentVnode && parentVnode.data;
  44962. /* istanbul ignore else */
  44963. {
  44964. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  44965. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  44966. }, true);
  44967. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  44968. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  44969. }, true);
  44970. }
  44971. }
  44972. var currentRenderingInstance = null;
  44973. function renderMixin (Vue) {
  44974. // install runtime convenience helpers
  44975. installRenderHelpers(Vue.prototype);
  44976. Vue.prototype.$nextTick = function (fn) {
  44977. return nextTick(fn, this)
  44978. };
  44979. Vue.prototype._render = function () {
  44980. var vm = this;
  44981. var ref = vm.$options;
  44982. var render = ref.render;
  44983. var _parentVnode = ref._parentVnode;
  44984. if (_parentVnode) {
  44985. vm.$scopedSlots = normalizeScopedSlots(
  44986. _parentVnode.data.scopedSlots,
  44987. vm.$slots,
  44988. vm.$scopedSlots
  44989. );
  44990. }
  44991. // set parent vnode. this allows render functions to have access
  44992. // to the data on the placeholder node.
  44993. vm.$vnode = _parentVnode;
  44994. // render self
  44995. var vnode;
  44996. try {
  44997. // There's no need to maintain a stack because all render fns are called
  44998. // separately from one another. Nested component's render fns are called
  44999. // when parent component is patched.
  45000. currentRenderingInstance = vm;
  45001. vnode = render.call(vm._renderProxy, vm.$createElement);
  45002. } catch (e) {
  45003. handleError(e, vm, "render");
  45004. // return error render result,
  45005. // or previous vnode to prevent render error causing blank component
  45006. /* istanbul ignore else */
  45007. if (vm.$options.renderError) {
  45008. try {
  45009. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  45010. } catch (e) {
  45011. handleError(e, vm, "renderError");
  45012. vnode = vm._vnode;
  45013. }
  45014. } else {
  45015. vnode = vm._vnode;
  45016. }
  45017. } finally {
  45018. currentRenderingInstance = null;
  45019. }
  45020. // if the returned array contains only a single node, allow it
  45021. if (Array.isArray(vnode) && vnode.length === 1) {
  45022. vnode = vnode[0];
  45023. }
  45024. // return empty vnode in case the render function errored out
  45025. if (!(vnode instanceof VNode)) {
  45026. if (Array.isArray(vnode)) {
  45027. warn(
  45028. 'Multiple root nodes returned from render function. Render function ' +
  45029. 'should return a single root node.',
  45030. vm
  45031. );
  45032. }
  45033. vnode = createEmptyVNode();
  45034. }
  45035. // set parent
  45036. vnode.parent = _parentVnode;
  45037. return vnode
  45038. };
  45039. }
  45040. /* */
  45041. function ensureCtor (comp, base) {
  45042. if (
  45043. comp.__esModule ||
  45044. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  45045. ) {
  45046. comp = comp.default;
  45047. }
  45048. return isObject(comp)
  45049. ? base.extend(comp)
  45050. : comp
  45051. }
  45052. function createAsyncPlaceholder (
  45053. factory,
  45054. data,
  45055. context,
  45056. children,
  45057. tag
  45058. ) {
  45059. var node = createEmptyVNode();
  45060. node.asyncFactory = factory;
  45061. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  45062. return node
  45063. }
  45064. function resolveAsyncComponent (
  45065. factory,
  45066. baseCtor
  45067. ) {
  45068. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  45069. return factory.errorComp
  45070. }
  45071. if (isDef(factory.resolved)) {
  45072. return factory.resolved
  45073. }
  45074. var owner = currentRenderingInstance;
  45075. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  45076. // already pending
  45077. factory.owners.push(owner);
  45078. }
  45079. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  45080. return factory.loadingComp
  45081. }
  45082. if (owner && !isDef(factory.owners)) {
  45083. var owners = factory.owners = [owner];
  45084. var sync = true;
  45085. var timerLoading = null;
  45086. var timerTimeout = null
  45087. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  45088. var forceRender = function (renderCompleted) {
  45089. for (var i = 0, l = owners.length; i < l; i++) {
  45090. (owners[i]).$forceUpdate();
  45091. }
  45092. if (renderCompleted) {
  45093. owners.length = 0;
  45094. if (timerLoading !== null) {
  45095. clearTimeout(timerLoading);
  45096. timerLoading = null;
  45097. }
  45098. if (timerTimeout !== null) {
  45099. clearTimeout(timerTimeout);
  45100. timerTimeout = null;
  45101. }
  45102. }
  45103. };
  45104. var resolve = once(function (res) {
  45105. // cache resolved
  45106. factory.resolved = ensureCtor(res, baseCtor);
  45107. // invoke callbacks only if this is not a synchronous resolve
  45108. // (async resolves are shimmed as synchronous during SSR)
  45109. if (!sync) {
  45110. forceRender(true);
  45111. } else {
  45112. owners.length = 0;
  45113. }
  45114. });
  45115. var reject = once(function (reason) {
  45116. warn(
  45117. "Failed to resolve async component: " + (String(factory)) +
  45118. (reason ? ("\nReason: " + reason) : '')
  45119. );
  45120. if (isDef(factory.errorComp)) {
  45121. factory.error = true;
  45122. forceRender(true);
  45123. }
  45124. });
  45125. var res = factory(resolve, reject);
  45126. if (isObject(res)) {
  45127. if (isPromise(res)) {
  45128. // () => Promise
  45129. if (isUndef(factory.resolved)) {
  45130. res.then(resolve, reject);
  45131. }
  45132. } else if (isPromise(res.component)) {
  45133. res.component.then(resolve, reject);
  45134. if (isDef(res.error)) {
  45135. factory.errorComp = ensureCtor(res.error, baseCtor);
  45136. }
  45137. if (isDef(res.loading)) {
  45138. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45139. if (res.delay === 0) {
  45140. factory.loading = true;
  45141. } else {
  45142. timerLoading = setTimeout(function () {
  45143. timerLoading = null;
  45144. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45145. factory.loading = true;
  45146. forceRender(false);
  45147. }
  45148. }, res.delay || 200);
  45149. }
  45150. }
  45151. if (isDef(res.timeout)) {
  45152. timerTimeout = setTimeout(function () {
  45153. timerTimeout = null;
  45154. if (isUndef(factory.resolved)) {
  45155. reject(
  45156. "timeout (" + (res.timeout) + "ms)"
  45157. );
  45158. }
  45159. }, res.timeout);
  45160. }
  45161. }
  45162. }
  45163. sync = false;
  45164. // return in case resolved synchronously
  45165. return factory.loading
  45166. ? factory.loadingComp
  45167. : factory.resolved
  45168. }
  45169. }
  45170. /* */
  45171. function isAsyncPlaceholder (node) {
  45172. return node.isComment && node.asyncFactory
  45173. }
  45174. /* */
  45175. function getFirstComponentChild (children) {
  45176. if (Array.isArray(children)) {
  45177. for (var i = 0; i < children.length; i++) {
  45178. var c = children[i];
  45179. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45180. return c
  45181. }
  45182. }
  45183. }
  45184. }
  45185. /* */
  45186. /* */
  45187. function initEvents (vm) {
  45188. vm._events = Object.create(null);
  45189. vm._hasHookEvent = false;
  45190. // init parent attached events
  45191. var listeners = vm.$options._parentListeners;
  45192. if (listeners) {
  45193. updateComponentListeners(vm, listeners);
  45194. }
  45195. }
  45196. var target;
  45197. function add (event, fn) {
  45198. target.$on(event, fn);
  45199. }
  45200. function remove$1 (event, fn) {
  45201. target.$off(event, fn);
  45202. }
  45203. function createOnceHandler (event, fn) {
  45204. var _target = target;
  45205. return function onceHandler () {
  45206. var res = fn.apply(null, arguments);
  45207. if (res !== null) {
  45208. _target.$off(event, onceHandler);
  45209. }
  45210. }
  45211. }
  45212. function updateComponentListeners (
  45213. vm,
  45214. listeners,
  45215. oldListeners
  45216. ) {
  45217. target = vm;
  45218. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45219. target = undefined;
  45220. }
  45221. function eventsMixin (Vue) {
  45222. var hookRE = /^hook:/;
  45223. Vue.prototype.$on = function (event, fn) {
  45224. var vm = this;
  45225. if (Array.isArray(event)) {
  45226. for (var i = 0, l = event.length; i < l; i++) {
  45227. vm.$on(event[i], fn);
  45228. }
  45229. } else {
  45230. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45231. // optimize hook:event cost by using a boolean flag marked at registration
  45232. // instead of a hash lookup
  45233. if (hookRE.test(event)) {
  45234. vm._hasHookEvent = true;
  45235. }
  45236. }
  45237. return vm
  45238. };
  45239. Vue.prototype.$once = function (event, fn) {
  45240. var vm = this;
  45241. function on () {
  45242. vm.$off(event, on);
  45243. fn.apply(vm, arguments);
  45244. }
  45245. on.fn = fn;
  45246. vm.$on(event, on);
  45247. return vm
  45248. };
  45249. Vue.prototype.$off = function (event, fn) {
  45250. var vm = this;
  45251. // all
  45252. if (!arguments.length) {
  45253. vm._events = Object.create(null);
  45254. return vm
  45255. }
  45256. // array of events
  45257. if (Array.isArray(event)) {
  45258. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45259. vm.$off(event[i$1], fn);
  45260. }
  45261. return vm
  45262. }
  45263. // specific event
  45264. var cbs = vm._events[event];
  45265. if (!cbs) {
  45266. return vm
  45267. }
  45268. if (!fn) {
  45269. vm._events[event] = null;
  45270. return vm
  45271. }
  45272. // specific handler
  45273. var cb;
  45274. var i = cbs.length;
  45275. while (i--) {
  45276. cb = cbs[i];
  45277. if (cb === fn || cb.fn === fn) {
  45278. cbs.splice(i, 1);
  45279. break
  45280. }
  45281. }
  45282. return vm
  45283. };
  45284. Vue.prototype.$emit = function (event) {
  45285. var vm = this;
  45286. {
  45287. var lowerCaseEvent = event.toLowerCase();
  45288. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45289. tip(
  45290. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45291. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45292. "Note that HTML attributes are case-insensitive and you cannot use " +
  45293. "v-on to listen to camelCase events when using in-DOM templates. " +
  45294. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45295. );
  45296. }
  45297. }
  45298. var cbs = vm._events[event];
  45299. if (cbs) {
  45300. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45301. var args = toArray(arguments, 1);
  45302. var info = "event handler for \"" + event + "\"";
  45303. for (var i = 0, l = cbs.length; i < l; i++) {
  45304. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45305. }
  45306. }
  45307. return vm
  45308. };
  45309. }
  45310. /* */
  45311. var activeInstance = null;
  45312. var isUpdatingChildComponent = false;
  45313. function setActiveInstance(vm) {
  45314. var prevActiveInstance = activeInstance;
  45315. activeInstance = vm;
  45316. return function () {
  45317. activeInstance = prevActiveInstance;
  45318. }
  45319. }
  45320. function initLifecycle (vm) {
  45321. var options = vm.$options;
  45322. // locate first non-abstract parent
  45323. var parent = options.parent;
  45324. if (parent && !options.abstract) {
  45325. while (parent.$options.abstract && parent.$parent) {
  45326. parent = parent.$parent;
  45327. }
  45328. parent.$children.push(vm);
  45329. }
  45330. vm.$parent = parent;
  45331. vm.$root = parent ? parent.$root : vm;
  45332. vm.$children = [];
  45333. vm.$refs = {};
  45334. vm._watcher = null;
  45335. vm._inactive = null;
  45336. vm._directInactive = false;
  45337. vm._isMounted = false;
  45338. vm._isDestroyed = false;
  45339. vm._isBeingDestroyed = false;
  45340. }
  45341. function lifecycleMixin (Vue) {
  45342. Vue.prototype._update = function (vnode, hydrating) {
  45343. var vm = this;
  45344. var prevEl = vm.$el;
  45345. var prevVnode = vm._vnode;
  45346. var restoreActiveInstance = setActiveInstance(vm);
  45347. vm._vnode = vnode;
  45348. // Vue.prototype.__patch__ is injected in entry points
  45349. // based on the rendering backend used.
  45350. if (!prevVnode) {
  45351. // initial render
  45352. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45353. } else {
  45354. // updates
  45355. vm.$el = vm.__patch__(prevVnode, vnode);
  45356. }
  45357. restoreActiveInstance();
  45358. // update __vue__ reference
  45359. if (prevEl) {
  45360. prevEl.__vue__ = null;
  45361. }
  45362. if (vm.$el) {
  45363. vm.$el.__vue__ = vm;
  45364. }
  45365. // if parent is an HOC, update its $el as well
  45366. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45367. vm.$parent.$el = vm.$el;
  45368. }
  45369. // updated hook is called by the scheduler to ensure that children are
  45370. // updated in a parent's updated hook.
  45371. };
  45372. Vue.prototype.$forceUpdate = function () {
  45373. var vm = this;
  45374. if (vm._watcher) {
  45375. vm._watcher.update();
  45376. }
  45377. };
  45378. Vue.prototype.$destroy = function () {
  45379. var vm = this;
  45380. if (vm._isBeingDestroyed) {
  45381. return
  45382. }
  45383. callHook(vm, 'beforeDestroy');
  45384. vm._isBeingDestroyed = true;
  45385. // remove self from parent
  45386. var parent = vm.$parent;
  45387. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45388. remove(parent.$children, vm);
  45389. }
  45390. // teardown watchers
  45391. if (vm._watcher) {
  45392. vm._watcher.teardown();
  45393. }
  45394. var i = vm._watchers.length;
  45395. while (i--) {
  45396. vm._watchers[i].teardown();
  45397. }
  45398. // remove reference from data ob
  45399. // frozen object may not have observer.
  45400. if (vm._data.__ob__) {
  45401. vm._data.__ob__.vmCount--;
  45402. }
  45403. // call the last hook...
  45404. vm._isDestroyed = true;
  45405. // invoke destroy hooks on current rendered tree
  45406. vm.__patch__(vm._vnode, null);
  45407. // fire destroyed hook
  45408. callHook(vm, 'destroyed');
  45409. // turn off all instance listeners.
  45410. vm.$off();
  45411. // remove __vue__ reference
  45412. if (vm.$el) {
  45413. vm.$el.__vue__ = null;
  45414. }
  45415. // release circular reference (#6759)
  45416. if (vm.$vnode) {
  45417. vm.$vnode.parent = null;
  45418. }
  45419. };
  45420. }
  45421. function mountComponent (
  45422. vm,
  45423. el,
  45424. hydrating
  45425. ) {
  45426. vm.$el = el;
  45427. if (!vm.$options.render) {
  45428. vm.$options.render = createEmptyVNode;
  45429. {
  45430. /* istanbul ignore if */
  45431. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45432. vm.$options.el || el) {
  45433. warn(
  45434. 'You are using the runtime-only build of Vue where the template ' +
  45435. 'compiler is not available. Either pre-compile the templates into ' +
  45436. 'render functions, or use the compiler-included build.',
  45437. vm
  45438. );
  45439. } else {
  45440. warn(
  45441. 'Failed to mount component: template or render function not defined.',
  45442. vm
  45443. );
  45444. }
  45445. }
  45446. }
  45447. callHook(vm, 'beforeMount');
  45448. var updateComponent;
  45449. /* istanbul ignore if */
  45450. if (config.performance && mark) {
  45451. updateComponent = function () {
  45452. var name = vm._name;
  45453. var id = vm._uid;
  45454. var startTag = "vue-perf-start:" + id;
  45455. var endTag = "vue-perf-end:" + id;
  45456. mark(startTag);
  45457. var vnode = vm._render();
  45458. mark(endTag);
  45459. measure(("vue " + name + " render"), startTag, endTag);
  45460. mark(startTag);
  45461. vm._update(vnode, hydrating);
  45462. mark(endTag);
  45463. measure(("vue " + name + " patch"), startTag, endTag);
  45464. };
  45465. } else {
  45466. updateComponent = function () {
  45467. vm._update(vm._render(), hydrating);
  45468. };
  45469. }
  45470. // we set this to vm._watcher inside the watcher's constructor
  45471. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45472. // component's mounted hook), which relies on vm._watcher being already defined
  45473. new Watcher(vm, updateComponent, noop, {
  45474. before: function before () {
  45475. if (vm._isMounted && !vm._isDestroyed) {
  45476. callHook(vm, 'beforeUpdate');
  45477. }
  45478. }
  45479. }, true /* isRenderWatcher */);
  45480. hydrating = false;
  45481. // manually mounted instance, call mounted on self
  45482. // mounted is called for render-created child components in its inserted hook
  45483. if (vm.$vnode == null) {
  45484. vm._isMounted = true;
  45485. callHook(vm, 'mounted');
  45486. }
  45487. return vm
  45488. }
  45489. function updateChildComponent (
  45490. vm,
  45491. propsData,
  45492. listeners,
  45493. parentVnode,
  45494. renderChildren
  45495. ) {
  45496. {
  45497. isUpdatingChildComponent = true;
  45498. }
  45499. // determine whether component has slot children
  45500. // we need to do this before overwriting $options._renderChildren.
  45501. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45502. // dynamic slot names). Static scoped slots compiled from template has the
  45503. // "$stable" marker.
  45504. var newScopedSlots = parentVnode.data.scopedSlots;
  45505. var oldScopedSlots = vm.$scopedSlots;
  45506. var hasDynamicScopedSlot = !!(
  45507. (newScopedSlots && !newScopedSlots.$stable) ||
  45508. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45509. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45510. );
  45511. // Any static slot children from the parent may have changed during parent's
  45512. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45513. // update is necessary to ensure correctness.
  45514. var needsForceUpdate = !!(
  45515. renderChildren || // has new static slots
  45516. vm.$options._renderChildren || // has old static slots
  45517. hasDynamicScopedSlot
  45518. );
  45519. vm.$options._parentVnode = parentVnode;
  45520. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45521. if (vm._vnode) { // update child tree's parent
  45522. vm._vnode.parent = parentVnode;
  45523. }
  45524. vm.$options._renderChildren = renderChildren;
  45525. // update $attrs and $listeners hash
  45526. // these are also reactive so they may trigger child update if the child
  45527. // used them during render
  45528. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45529. vm.$listeners = listeners || emptyObject;
  45530. // update props
  45531. if (propsData && vm.$options.props) {
  45532. toggleObserving(false);
  45533. var props = vm._props;
  45534. var propKeys = vm.$options._propKeys || [];
  45535. for (var i = 0; i < propKeys.length; i++) {
  45536. var key = propKeys[i];
  45537. var propOptions = vm.$options.props; // wtf flow?
  45538. props[key] = validateProp(key, propOptions, propsData, vm);
  45539. }
  45540. toggleObserving(true);
  45541. // keep a copy of raw propsData
  45542. vm.$options.propsData = propsData;
  45543. }
  45544. // update listeners
  45545. listeners = listeners || emptyObject;
  45546. var oldListeners = vm.$options._parentListeners;
  45547. vm.$options._parentListeners = listeners;
  45548. updateComponentListeners(vm, listeners, oldListeners);
  45549. // resolve slots + force update if has children
  45550. if (needsForceUpdate) {
  45551. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45552. vm.$forceUpdate();
  45553. }
  45554. {
  45555. isUpdatingChildComponent = false;
  45556. }
  45557. }
  45558. function isInInactiveTree (vm) {
  45559. while (vm && (vm = vm.$parent)) {
  45560. if (vm._inactive) { return true }
  45561. }
  45562. return false
  45563. }
  45564. function activateChildComponent (vm, direct) {
  45565. if (direct) {
  45566. vm._directInactive = false;
  45567. if (isInInactiveTree(vm)) {
  45568. return
  45569. }
  45570. } else if (vm._directInactive) {
  45571. return
  45572. }
  45573. if (vm._inactive || vm._inactive === null) {
  45574. vm._inactive = false;
  45575. for (var i = 0; i < vm.$children.length; i++) {
  45576. activateChildComponent(vm.$children[i]);
  45577. }
  45578. callHook(vm, 'activated');
  45579. }
  45580. }
  45581. function deactivateChildComponent (vm, direct) {
  45582. if (direct) {
  45583. vm._directInactive = true;
  45584. if (isInInactiveTree(vm)) {
  45585. return
  45586. }
  45587. }
  45588. if (!vm._inactive) {
  45589. vm._inactive = true;
  45590. for (var i = 0; i < vm.$children.length; i++) {
  45591. deactivateChildComponent(vm.$children[i]);
  45592. }
  45593. callHook(vm, 'deactivated');
  45594. }
  45595. }
  45596. function callHook (vm, hook) {
  45597. // #7573 disable dep collection when invoking lifecycle hooks
  45598. pushTarget();
  45599. var handlers = vm.$options[hook];
  45600. var info = hook + " hook";
  45601. if (handlers) {
  45602. for (var i = 0, j = handlers.length; i < j; i++) {
  45603. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45604. }
  45605. }
  45606. if (vm._hasHookEvent) {
  45607. vm.$emit('hook:' + hook);
  45608. }
  45609. popTarget();
  45610. }
  45611. /* */
  45612. var MAX_UPDATE_COUNT = 100;
  45613. var queue = [];
  45614. var activatedChildren = [];
  45615. var has = {};
  45616. var circular = {};
  45617. var waiting = false;
  45618. var flushing = false;
  45619. var index = 0;
  45620. /**
  45621. * Reset the scheduler's state.
  45622. */
  45623. function resetSchedulerState () {
  45624. index = queue.length = activatedChildren.length = 0;
  45625. has = {};
  45626. {
  45627. circular = {};
  45628. }
  45629. waiting = flushing = false;
  45630. }
  45631. // Async edge case #6566 requires saving the timestamp when event listeners are
  45632. // attached. However, calling performance.now() has a perf overhead especially
  45633. // if the page has thousands of event listeners. Instead, we take a timestamp
  45634. // every time the scheduler flushes and use that for all event listeners
  45635. // attached during that flush.
  45636. var currentFlushTimestamp = 0;
  45637. // Async edge case fix requires storing an event listener's attach timestamp.
  45638. var getNow = Date.now;
  45639. // Determine what event timestamp the browser is using. Annoyingly, the
  45640. // timestamp can either be hi-res (relative to page load) or low-res
  45641. // (relative to UNIX epoch), so in order to compare time we have to use the
  45642. // same timestamp type when saving the flush timestamp.
  45643. // All IE versions use low-res event timestamps, and have problematic clock
  45644. // implementations (#9632)
  45645. if (inBrowser && !isIE) {
  45646. var performance = window.performance;
  45647. if (
  45648. performance &&
  45649. typeof performance.now === 'function' &&
  45650. getNow() > document.createEvent('Event').timeStamp
  45651. ) {
  45652. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45653. // smaller than it, it means the event is using a hi-res timestamp,
  45654. // and we need to use the hi-res version for event listener timestamps as
  45655. // well.
  45656. getNow = function () { return performance.now(); };
  45657. }
  45658. }
  45659. /**
  45660. * Flush both queues and run the watchers.
  45661. */
  45662. function flushSchedulerQueue () {
  45663. currentFlushTimestamp = getNow();
  45664. flushing = true;
  45665. var watcher, id;
  45666. // Sort queue before flush.
  45667. // This ensures that:
  45668. // 1. Components are updated from parent to child. (because parent is always
  45669. // created before the child)
  45670. // 2. A component's user watchers are run before its render watcher (because
  45671. // user watchers are created before the render watcher)
  45672. // 3. If a component is destroyed during a parent component's watcher run,
  45673. // its watchers can be skipped.
  45674. queue.sort(function (a, b) { return a.id - b.id; });
  45675. // do not cache length because more watchers might be pushed
  45676. // as we run existing watchers
  45677. for (index = 0; index < queue.length; index++) {
  45678. watcher = queue[index];
  45679. if (watcher.before) {
  45680. watcher.before();
  45681. }
  45682. id = watcher.id;
  45683. has[id] = null;
  45684. watcher.run();
  45685. // in dev build, check and stop circular updates.
  45686. if (has[id] != null) {
  45687. circular[id] = (circular[id] || 0) + 1;
  45688. if (circular[id] > MAX_UPDATE_COUNT) {
  45689. warn(
  45690. 'You may have an infinite update loop ' + (
  45691. watcher.user
  45692. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45693. : "in a component render function."
  45694. ),
  45695. watcher.vm
  45696. );
  45697. break
  45698. }
  45699. }
  45700. }
  45701. // keep copies of post queues before resetting state
  45702. var activatedQueue = activatedChildren.slice();
  45703. var updatedQueue = queue.slice();
  45704. resetSchedulerState();
  45705. // call component updated and activated hooks
  45706. callActivatedHooks(activatedQueue);
  45707. callUpdatedHooks(updatedQueue);
  45708. // devtool hook
  45709. /* istanbul ignore if */
  45710. if (devtools && config.devtools) {
  45711. devtools.emit('flush');
  45712. }
  45713. }
  45714. function callUpdatedHooks (queue) {
  45715. var i = queue.length;
  45716. while (i--) {
  45717. var watcher = queue[i];
  45718. var vm = watcher.vm;
  45719. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45720. callHook(vm, 'updated');
  45721. }
  45722. }
  45723. }
  45724. /**
  45725. * Queue a kept-alive component that was activated during patch.
  45726. * The queue will be processed after the entire tree has been patched.
  45727. */
  45728. function queueActivatedComponent (vm) {
  45729. // setting _inactive to false here so that a render function can
  45730. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45731. vm._inactive = false;
  45732. activatedChildren.push(vm);
  45733. }
  45734. function callActivatedHooks (queue) {
  45735. for (var i = 0; i < queue.length; i++) {
  45736. queue[i]._inactive = true;
  45737. activateChildComponent(queue[i], true /* true */);
  45738. }
  45739. }
  45740. /**
  45741. * Push a watcher into the watcher queue.
  45742. * Jobs with duplicate IDs will be skipped unless it's
  45743. * pushed when the queue is being flushed.
  45744. */
  45745. function queueWatcher (watcher) {
  45746. var id = watcher.id;
  45747. if (has[id] == null) {
  45748. has[id] = true;
  45749. if (!flushing) {
  45750. queue.push(watcher);
  45751. } else {
  45752. // if already flushing, splice the watcher based on its id
  45753. // if already past its id, it will be run next immediately.
  45754. var i = queue.length - 1;
  45755. while (i > index && queue[i].id > watcher.id) {
  45756. i--;
  45757. }
  45758. queue.splice(i + 1, 0, watcher);
  45759. }
  45760. // queue the flush
  45761. if (!waiting) {
  45762. waiting = true;
  45763. if (!config.async) {
  45764. flushSchedulerQueue();
  45765. return
  45766. }
  45767. nextTick(flushSchedulerQueue);
  45768. }
  45769. }
  45770. }
  45771. /* */
  45772. var uid$2 = 0;
  45773. /**
  45774. * A watcher parses an expression, collects dependencies,
  45775. * and fires callback when the expression value changes.
  45776. * This is used for both the $watch() api and directives.
  45777. */
  45778. var Watcher = function Watcher (
  45779. vm,
  45780. expOrFn,
  45781. cb,
  45782. options,
  45783. isRenderWatcher
  45784. ) {
  45785. this.vm = vm;
  45786. if (isRenderWatcher) {
  45787. vm._watcher = this;
  45788. }
  45789. vm._watchers.push(this);
  45790. // options
  45791. if (options) {
  45792. this.deep = !!options.deep;
  45793. this.user = !!options.user;
  45794. this.lazy = !!options.lazy;
  45795. this.sync = !!options.sync;
  45796. this.before = options.before;
  45797. } else {
  45798. this.deep = this.user = this.lazy = this.sync = false;
  45799. }
  45800. this.cb = cb;
  45801. this.id = ++uid$2; // uid for batching
  45802. this.active = true;
  45803. this.dirty = this.lazy; // for lazy watchers
  45804. this.deps = [];
  45805. this.newDeps = [];
  45806. this.depIds = new _Set();
  45807. this.newDepIds = new _Set();
  45808. this.expression = expOrFn.toString();
  45809. // parse expression for getter
  45810. if (typeof expOrFn === 'function') {
  45811. this.getter = expOrFn;
  45812. } else {
  45813. this.getter = parsePath(expOrFn);
  45814. if (!this.getter) {
  45815. this.getter = noop;
  45816. warn(
  45817. "Failed watching path: \"" + expOrFn + "\" " +
  45818. 'Watcher only accepts simple dot-delimited paths. ' +
  45819. 'For full control, use a function instead.',
  45820. vm
  45821. );
  45822. }
  45823. }
  45824. this.value = this.lazy
  45825. ? undefined
  45826. : this.get();
  45827. };
  45828. /**
  45829. * Evaluate the getter, and re-collect dependencies.
  45830. */
  45831. Watcher.prototype.get = function get () {
  45832. pushTarget(this);
  45833. var value;
  45834. var vm = this.vm;
  45835. try {
  45836. value = this.getter.call(vm, vm);
  45837. } catch (e) {
  45838. if (this.user) {
  45839. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45840. } else {
  45841. throw e
  45842. }
  45843. } finally {
  45844. // "touch" every property so they are all tracked as
  45845. // dependencies for deep watching
  45846. if (this.deep) {
  45847. traverse(value);
  45848. }
  45849. popTarget();
  45850. this.cleanupDeps();
  45851. }
  45852. return value
  45853. };
  45854. /**
  45855. * Add a dependency to this directive.
  45856. */
  45857. Watcher.prototype.addDep = function addDep (dep) {
  45858. var id = dep.id;
  45859. if (!this.newDepIds.has(id)) {
  45860. this.newDepIds.add(id);
  45861. this.newDeps.push(dep);
  45862. if (!this.depIds.has(id)) {
  45863. dep.addSub(this);
  45864. }
  45865. }
  45866. };
  45867. /**
  45868. * Clean up for dependency collection.
  45869. */
  45870. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  45871. var i = this.deps.length;
  45872. while (i--) {
  45873. var dep = this.deps[i];
  45874. if (!this.newDepIds.has(dep.id)) {
  45875. dep.removeSub(this);
  45876. }
  45877. }
  45878. var tmp = this.depIds;
  45879. this.depIds = this.newDepIds;
  45880. this.newDepIds = tmp;
  45881. this.newDepIds.clear();
  45882. tmp = this.deps;
  45883. this.deps = this.newDeps;
  45884. this.newDeps = tmp;
  45885. this.newDeps.length = 0;
  45886. };
  45887. /**
  45888. * Subscriber interface.
  45889. * Will be called when a dependency changes.
  45890. */
  45891. Watcher.prototype.update = function update () {
  45892. /* istanbul ignore else */
  45893. if (this.lazy) {
  45894. this.dirty = true;
  45895. } else if (this.sync) {
  45896. this.run();
  45897. } else {
  45898. queueWatcher(this);
  45899. }
  45900. };
  45901. /**
  45902. * Scheduler job interface.
  45903. * Will be called by the scheduler.
  45904. */
  45905. Watcher.prototype.run = function run () {
  45906. if (this.active) {
  45907. var value = this.get();
  45908. if (
  45909. value !== this.value ||
  45910. // Deep watchers and watchers on Object/Arrays should fire even
  45911. // when the value is the same, because the value may
  45912. // have mutated.
  45913. isObject(value) ||
  45914. this.deep
  45915. ) {
  45916. // set new value
  45917. var oldValue = this.value;
  45918. this.value = value;
  45919. if (this.user) {
  45920. try {
  45921. this.cb.call(this.vm, value, oldValue);
  45922. } catch (e) {
  45923. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  45924. }
  45925. } else {
  45926. this.cb.call(this.vm, value, oldValue);
  45927. }
  45928. }
  45929. }
  45930. };
  45931. /**
  45932. * Evaluate the value of the watcher.
  45933. * This only gets called for lazy watchers.
  45934. */
  45935. Watcher.prototype.evaluate = function evaluate () {
  45936. this.value = this.get();
  45937. this.dirty = false;
  45938. };
  45939. /**
  45940. * Depend on all deps collected by this watcher.
  45941. */
  45942. Watcher.prototype.depend = function depend () {
  45943. var i = this.deps.length;
  45944. while (i--) {
  45945. this.deps[i].depend();
  45946. }
  45947. };
  45948. /**
  45949. * Remove self from all dependencies' subscriber list.
  45950. */
  45951. Watcher.prototype.teardown = function teardown () {
  45952. if (this.active) {
  45953. // remove self from vm's watcher list
  45954. // this is a somewhat expensive operation so we skip it
  45955. // if the vm is being destroyed.
  45956. if (!this.vm._isBeingDestroyed) {
  45957. remove(this.vm._watchers, this);
  45958. }
  45959. var i = this.deps.length;
  45960. while (i--) {
  45961. this.deps[i].removeSub(this);
  45962. }
  45963. this.active = false;
  45964. }
  45965. };
  45966. /* */
  45967. var sharedPropertyDefinition = {
  45968. enumerable: true,
  45969. configurable: true,
  45970. get: noop,
  45971. set: noop
  45972. };
  45973. function proxy (target, sourceKey, key) {
  45974. sharedPropertyDefinition.get = function proxyGetter () {
  45975. return this[sourceKey][key]
  45976. };
  45977. sharedPropertyDefinition.set = function proxySetter (val) {
  45978. this[sourceKey][key] = val;
  45979. };
  45980. Object.defineProperty(target, key, sharedPropertyDefinition);
  45981. }
  45982. function initState (vm) {
  45983. vm._watchers = [];
  45984. var opts = vm.$options;
  45985. if (opts.props) { initProps(vm, opts.props); }
  45986. if (opts.methods) { initMethods(vm, opts.methods); }
  45987. if (opts.data) {
  45988. initData(vm);
  45989. } else {
  45990. observe(vm._data = {}, true /* asRootData */);
  45991. }
  45992. if (opts.computed) { initComputed(vm, opts.computed); }
  45993. if (opts.watch && opts.watch !== nativeWatch) {
  45994. initWatch(vm, opts.watch);
  45995. }
  45996. }
  45997. function initProps (vm, propsOptions) {
  45998. var propsData = vm.$options.propsData || {};
  45999. var props = vm._props = {};
  46000. // cache prop keys so that future props updates can iterate using Array
  46001. // instead of dynamic object key enumeration.
  46002. var keys = vm.$options._propKeys = [];
  46003. var isRoot = !vm.$parent;
  46004. // root instance props should be converted
  46005. if (!isRoot) {
  46006. toggleObserving(false);
  46007. }
  46008. var loop = function ( key ) {
  46009. keys.push(key);
  46010. var value = validateProp(key, propsOptions, propsData, vm);
  46011. /* istanbul ignore else */
  46012. {
  46013. var hyphenatedKey = hyphenate(key);
  46014. if (isReservedAttribute(hyphenatedKey) ||
  46015. config.isReservedAttr(hyphenatedKey)) {
  46016. warn(
  46017. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  46018. vm
  46019. );
  46020. }
  46021. defineReactive$$1(props, key, value, function () {
  46022. if (!isRoot && !isUpdatingChildComponent) {
  46023. warn(
  46024. "Avoid mutating a prop directly since the value will be " +
  46025. "overwritten whenever the parent component re-renders. " +
  46026. "Instead, use a data or computed property based on the prop's " +
  46027. "value. Prop being mutated: \"" + key + "\"",
  46028. vm
  46029. );
  46030. }
  46031. });
  46032. }
  46033. // static props are already proxied on the component's prototype
  46034. // during Vue.extend(). We only need to proxy props defined at
  46035. // instantiation here.
  46036. if (!(key in vm)) {
  46037. proxy(vm, "_props", key);
  46038. }
  46039. };
  46040. for (var key in propsOptions) loop( key );
  46041. toggleObserving(true);
  46042. }
  46043. function initData (vm) {
  46044. var data = vm.$options.data;
  46045. data = vm._data = typeof data === 'function'
  46046. ? getData(data, vm)
  46047. : data || {};
  46048. if (!isPlainObject(data)) {
  46049. data = {};
  46050. warn(
  46051. 'data functions should return an object:\n' +
  46052. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  46053. vm
  46054. );
  46055. }
  46056. // proxy data on instance
  46057. var keys = Object.keys(data);
  46058. var props = vm.$options.props;
  46059. var methods = vm.$options.methods;
  46060. var i = keys.length;
  46061. while (i--) {
  46062. var key = keys[i];
  46063. {
  46064. if (methods && hasOwn(methods, key)) {
  46065. warn(
  46066. ("Method \"" + key + "\" has already been defined as a data property."),
  46067. vm
  46068. );
  46069. }
  46070. }
  46071. if (props && hasOwn(props, key)) {
  46072. warn(
  46073. "The data property \"" + key + "\" is already declared as a prop. " +
  46074. "Use prop default value instead.",
  46075. vm
  46076. );
  46077. } else if (!isReserved(key)) {
  46078. proxy(vm, "_data", key);
  46079. }
  46080. }
  46081. // observe data
  46082. observe(data, true /* asRootData */);
  46083. }
  46084. function getData (data, vm) {
  46085. // #7573 disable dep collection when invoking data getters
  46086. pushTarget();
  46087. try {
  46088. return data.call(vm, vm)
  46089. } catch (e) {
  46090. handleError(e, vm, "data()");
  46091. return {}
  46092. } finally {
  46093. popTarget();
  46094. }
  46095. }
  46096. var computedWatcherOptions = { lazy: true };
  46097. function initComputed (vm, computed) {
  46098. // $flow-disable-line
  46099. var watchers = vm._computedWatchers = Object.create(null);
  46100. // computed properties are just getters during SSR
  46101. var isSSR = isServerRendering();
  46102. for (var key in computed) {
  46103. var userDef = computed[key];
  46104. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46105. if (getter == null) {
  46106. warn(
  46107. ("Getter is missing for computed property \"" + key + "\"."),
  46108. vm
  46109. );
  46110. }
  46111. if (!isSSR) {
  46112. // create internal watcher for the computed property.
  46113. watchers[key] = new Watcher(
  46114. vm,
  46115. getter || noop,
  46116. noop,
  46117. computedWatcherOptions
  46118. );
  46119. }
  46120. // component-defined computed properties are already defined on the
  46121. // component prototype. We only need to define computed properties defined
  46122. // at instantiation here.
  46123. if (!(key in vm)) {
  46124. defineComputed(vm, key, userDef);
  46125. } else {
  46126. if (key in vm.$data) {
  46127. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46128. } else if (vm.$options.props && key in vm.$options.props) {
  46129. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46130. }
  46131. }
  46132. }
  46133. }
  46134. function defineComputed (
  46135. target,
  46136. key,
  46137. userDef
  46138. ) {
  46139. var shouldCache = !isServerRendering();
  46140. if (typeof userDef === 'function') {
  46141. sharedPropertyDefinition.get = shouldCache
  46142. ? createComputedGetter(key)
  46143. : createGetterInvoker(userDef);
  46144. sharedPropertyDefinition.set = noop;
  46145. } else {
  46146. sharedPropertyDefinition.get = userDef.get
  46147. ? shouldCache && userDef.cache !== false
  46148. ? createComputedGetter(key)
  46149. : createGetterInvoker(userDef.get)
  46150. : noop;
  46151. sharedPropertyDefinition.set = userDef.set || noop;
  46152. }
  46153. if (sharedPropertyDefinition.set === noop) {
  46154. sharedPropertyDefinition.set = function () {
  46155. warn(
  46156. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46157. this
  46158. );
  46159. };
  46160. }
  46161. Object.defineProperty(target, key, sharedPropertyDefinition);
  46162. }
  46163. function createComputedGetter (key) {
  46164. return function computedGetter () {
  46165. var watcher = this._computedWatchers && this._computedWatchers[key];
  46166. if (watcher) {
  46167. if (watcher.dirty) {
  46168. watcher.evaluate();
  46169. }
  46170. if (Dep.target) {
  46171. watcher.depend();
  46172. }
  46173. return watcher.value
  46174. }
  46175. }
  46176. }
  46177. function createGetterInvoker(fn) {
  46178. return function computedGetter () {
  46179. return fn.call(this, this)
  46180. }
  46181. }
  46182. function initMethods (vm, methods) {
  46183. var props = vm.$options.props;
  46184. for (var key in methods) {
  46185. {
  46186. if (typeof methods[key] !== 'function') {
  46187. warn(
  46188. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46189. "Did you reference the function correctly?",
  46190. vm
  46191. );
  46192. }
  46193. if (props && hasOwn(props, key)) {
  46194. warn(
  46195. ("Method \"" + key + "\" has already been defined as a prop."),
  46196. vm
  46197. );
  46198. }
  46199. if ((key in vm) && isReserved(key)) {
  46200. warn(
  46201. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46202. "Avoid defining component methods that start with _ or $."
  46203. );
  46204. }
  46205. }
  46206. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46207. }
  46208. }
  46209. function initWatch (vm, watch) {
  46210. for (var key in watch) {
  46211. var handler = watch[key];
  46212. if (Array.isArray(handler)) {
  46213. for (var i = 0; i < handler.length; i++) {
  46214. createWatcher(vm, key, handler[i]);
  46215. }
  46216. } else {
  46217. createWatcher(vm, key, handler);
  46218. }
  46219. }
  46220. }
  46221. function createWatcher (
  46222. vm,
  46223. expOrFn,
  46224. handler,
  46225. options
  46226. ) {
  46227. if (isPlainObject(handler)) {
  46228. options = handler;
  46229. handler = handler.handler;
  46230. }
  46231. if (typeof handler === 'string') {
  46232. handler = vm[handler];
  46233. }
  46234. return vm.$watch(expOrFn, handler, options)
  46235. }
  46236. function stateMixin (Vue) {
  46237. // flow somehow has problems with directly declared definition object
  46238. // when using Object.defineProperty, so we have to procedurally build up
  46239. // the object here.
  46240. var dataDef = {};
  46241. dataDef.get = function () { return this._data };
  46242. var propsDef = {};
  46243. propsDef.get = function () { return this._props };
  46244. {
  46245. dataDef.set = function () {
  46246. warn(
  46247. 'Avoid replacing instance root $data. ' +
  46248. 'Use nested data properties instead.',
  46249. this
  46250. );
  46251. };
  46252. propsDef.set = function () {
  46253. warn("$props is readonly.", this);
  46254. };
  46255. }
  46256. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46257. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46258. Vue.prototype.$set = set;
  46259. Vue.prototype.$delete = del;
  46260. Vue.prototype.$watch = function (
  46261. expOrFn,
  46262. cb,
  46263. options
  46264. ) {
  46265. var vm = this;
  46266. if (isPlainObject(cb)) {
  46267. return createWatcher(vm, expOrFn, cb, options)
  46268. }
  46269. options = options || {};
  46270. options.user = true;
  46271. var watcher = new Watcher(vm, expOrFn, cb, options);
  46272. if (options.immediate) {
  46273. try {
  46274. cb.call(vm, watcher.value);
  46275. } catch (error) {
  46276. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46277. }
  46278. }
  46279. return function unwatchFn () {
  46280. watcher.teardown();
  46281. }
  46282. };
  46283. }
  46284. /* */
  46285. var uid$3 = 0;
  46286. function initMixin (Vue) {
  46287. Vue.prototype._init = function (options) {
  46288. var vm = this;
  46289. // a uid
  46290. vm._uid = uid$3++;
  46291. var startTag, endTag;
  46292. /* istanbul ignore if */
  46293. if (config.performance && mark) {
  46294. startTag = "vue-perf-start:" + (vm._uid);
  46295. endTag = "vue-perf-end:" + (vm._uid);
  46296. mark(startTag);
  46297. }
  46298. // a flag to avoid this being observed
  46299. vm._isVue = true;
  46300. // merge options
  46301. if (options && options._isComponent) {
  46302. // optimize internal component instantiation
  46303. // since dynamic options merging is pretty slow, and none of the
  46304. // internal component options needs special treatment.
  46305. initInternalComponent(vm, options);
  46306. } else {
  46307. vm.$options = mergeOptions(
  46308. resolveConstructorOptions(vm.constructor),
  46309. options || {},
  46310. vm
  46311. );
  46312. }
  46313. /* istanbul ignore else */
  46314. {
  46315. initProxy(vm);
  46316. }
  46317. // expose real self
  46318. vm._self = vm;
  46319. initLifecycle(vm);
  46320. initEvents(vm);
  46321. initRender(vm);
  46322. callHook(vm, 'beforeCreate');
  46323. initInjections(vm); // resolve injections before data/props
  46324. initState(vm);
  46325. initProvide(vm); // resolve provide after data/props
  46326. callHook(vm, 'created');
  46327. /* istanbul ignore if */
  46328. if (config.performance && mark) {
  46329. vm._name = formatComponentName(vm, false);
  46330. mark(endTag);
  46331. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46332. }
  46333. if (vm.$options.el) {
  46334. vm.$mount(vm.$options.el);
  46335. }
  46336. };
  46337. }
  46338. function initInternalComponent (vm, options) {
  46339. var opts = vm.$options = Object.create(vm.constructor.options);
  46340. // doing this because it's faster than dynamic enumeration.
  46341. var parentVnode = options._parentVnode;
  46342. opts.parent = options.parent;
  46343. opts._parentVnode = parentVnode;
  46344. var vnodeComponentOptions = parentVnode.componentOptions;
  46345. opts.propsData = vnodeComponentOptions.propsData;
  46346. opts._parentListeners = vnodeComponentOptions.listeners;
  46347. opts._renderChildren = vnodeComponentOptions.children;
  46348. opts._componentTag = vnodeComponentOptions.tag;
  46349. if (options.render) {
  46350. opts.render = options.render;
  46351. opts.staticRenderFns = options.staticRenderFns;
  46352. }
  46353. }
  46354. function resolveConstructorOptions (Ctor) {
  46355. var options = Ctor.options;
  46356. if (Ctor.super) {
  46357. var superOptions = resolveConstructorOptions(Ctor.super);
  46358. var cachedSuperOptions = Ctor.superOptions;
  46359. if (superOptions !== cachedSuperOptions) {
  46360. // super option changed,
  46361. // need to resolve new options.
  46362. Ctor.superOptions = superOptions;
  46363. // check if there are any late-modified/attached options (#4976)
  46364. var modifiedOptions = resolveModifiedOptions(Ctor);
  46365. // update base extend options
  46366. if (modifiedOptions) {
  46367. extend(Ctor.extendOptions, modifiedOptions);
  46368. }
  46369. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46370. if (options.name) {
  46371. options.components[options.name] = Ctor;
  46372. }
  46373. }
  46374. }
  46375. return options
  46376. }
  46377. function resolveModifiedOptions (Ctor) {
  46378. var modified;
  46379. var latest = Ctor.options;
  46380. var sealed = Ctor.sealedOptions;
  46381. for (var key in latest) {
  46382. if (latest[key] !== sealed[key]) {
  46383. if (!modified) { modified = {}; }
  46384. modified[key] = latest[key];
  46385. }
  46386. }
  46387. return modified
  46388. }
  46389. function Vue (options) {
  46390. if (!(this instanceof Vue)
  46391. ) {
  46392. warn('Vue is a constructor and should be called with the `new` keyword');
  46393. }
  46394. this._init(options);
  46395. }
  46396. initMixin(Vue);
  46397. stateMixin(Vue);
  46398. eventsMixin(Vue);
  46399. lifecycleMixin(Vue);
  46400. renderMixin(Vue);
  46401. /* */
  46402. function initUse (Vue) {
  46403. Vue.use = function (plugin) {
  46404. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46405. if (installedPlugins.indexOf(plugin) > -1) {
  46406. return this
  46407. }
  46408. // additional parameters
  46409. var args = toArray(arguments, 1);
  46410. args.unshift(this);
  46411. if (typeof plugin.install === 'function') {
  46412. plugin.install.apply(plugin, args);
  46413. } else if (typeof plugin === 'function') {
  46414. plugin.apply(null, args);
  46415. }
  46416. installedPlugins.push(plugin);
  46417. return this
  46418. };
  46419. }
  46420. /* */
  46421. function initMixin$1 (Vue) {
  46422. Vue.mixin = function (mixin) {
  46423. this.options = mergeOptions(this.options, mixin);
  46424. return this
  46425. };
  46426. }
  46427. /* */
  46428. function initExtend (Vue) {
  46429. /**
  46430. * Each instance constructor, including Vue, has a unique
  46431. * cid. This enables us to create wrapped "child
  46432. * constructors" for prototypal inheritance and cache them.
  46433. */
  46434. Vue.cid = 0;
  46435. var cid = 1;
  46436. /**
  46437. * Class inheritance
  46438. */
  46439. Vue.extend = function (extendOptions) {
  46440. extendOptions = extendOptions || {};
  46441. var Super = this;
  46442. var SuperId = Super.cid;
  46443. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46444. if (cachedCtors[SuperId]) {
  46445. return cachedCtors[SuperId]
  46446. }
  46447. var name = extendOptions.name || Super.options.name;
  46448. if (name) {
  46449. validateComponentName(name);
  46450. }
  46451. var Sub = function VueComponent (options) {
  46452. this._init(options);
  46453. };
  46454. Sub.prototype = Object.create(Super.prototype);
  46455. Sub.prototype.constructor = Sub;
  46456. Sub.cid = cid++;
  46457. Sub.options = mergeOptions(
  46458. Super.options,
  46459. extendOptions
  46460. );
  46461. Sub['super'] = Super;
  46462. // For props and computed properties, we define the proxy getters on
  46463. // the Vue instances at extension time, on the extended prototype. This
  46464. // avoids Object.defineProperty calls for each instance created.
  46465. if (Sub.options.props) {
  46466. initProps$1(Sub);
  46467. }
  46468. if (Sub.options.computed) {
  46469. initComputed$1(Sub);
  46470. }
  46471. // allow further extension/mixin/plugin usage
  46472. Sub.extend = Super.extend;
  46473. Sub.mixin = Super.mixin;
  46474. Sub.use = Super.use;
  46475. // create asset registers, so extended classes
  46476. // can have their private assets too.
  46477. ASSET_TYPES.forEach(function (type) {
  46478. Sub[type] = Super[type];
  46479. });
  46480. // enable recursive self-lookup
  46481. if (name) {
  46482. Sub.options.components[name] = Sub;
  46483. }
  46484. // keep a reference to the super options at extension time.
  46485. // later at instantiation we can check if Super's options have
  46486. // been updated.
  46487. Sub.superOptions = Super.options;
  46488. Sub.extendOptions = extendOptions;
  46489. Sub.sealedOptions = extend({}, Sub.options);
  46490. // cache constructor
  46491. cachedCtors[SuperId] = Sub;
  46492. return Sub
  46493. };
  46494. }
  46495. function initProps$1 (Comp) {
  46496. var props = Comp.options.props;
  46497. for (var key in props) {
  46498. proxy(Comp.prototype, "_props", key);
  46499. }
  46500. }
  46501. function initComputed$1 (Comp) {
  46502. var computed = Comp.options.computed;
  46503. for (var key in computed) {
  46504. defineComputed(Comp.prototype, key, computed[key]);
  46505. }
  46506. }
  46507. /* */
  46508. function initAssetRegisters (Vue) {
  46509. /**
  46510. * Create asset registration methods.
  46511. */
  46512. ASSET_TYPES.forEach(function (type) {
  46513. Vue[type] = function (
  46514. id,
  46515. definition
  46516. ) {
  46517. if (!definition) {
  46518. return this.options[type + 's'][id]
  46519. } else {
  46520. /* istanbul ignore if */
  46521. if (type === 'component') {
  46522. validateComponentName(id);
  46523. }
  46524. if (type === 'component' && isPlainObject(definition)) {
  46525. definition.name = definition.name || id;
  46526. definition = this.options._base.extend(definition);
  46527. }
  46528. if (type === 'directive' && typeof definition === 'function') {
  46529. definition = { bind: definition, update: definition };
  46530. }
  46531. this.options[type + 's'][id] = definition;
  46532. return definition
  46533. }
  46534. };
  46535. });
  46536. }
  46537. /* */
  46538. function getComponentName (opts) {
  46539. return opts && (opts.Ctor.options.name || opts.tag)
  46540. }
  46541. function matches (pattern, name) {
  46542. if (Array.isArray(pattern)) {
  46543. return pattern.indexOf(name) > -1
  46544. } else if (typeof pattern === 'string') {
  46545. return pattern.split(',').indexOf(name) > -1
  46546. } else if (isRegExp(pattern)) {
  46547. return pattern.test(name)
  46548. }
  46549. /* istanbul ignore next */
  46550. return false
  46551. }
  46552. function pruneCache (keepAliveInstance, filter) {
  46553. var cache = keepAliveInstance.cache;
  46554. var keys = keepAliveInstance.keys;
  46555. var _vnode = keepAliveInstance._vnode;
  46556. for (var key in cache) {
  46557. var cachedNode = cache[key];
  46558. if (cachedNode) {
  46559. var name = getComponentName(cachedNode.componentOptions);
  46560. if (name && !filter(name)) {
  46561. pruneCacheEntry(cache, key, keys, _vnode);
  46562. }
  46563. }
  46564. }
  46565. }
  46566. function pruneCacheEntry (
  46567. cache,
  46568. key,
  46569. keys,
  46570. current
  46571. ) {
  46572. var cached$$1 = cache[key];
  46573. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46574. cached$$1.componentInstance.$destroy();
  46575. }
  46576. cache[key] = null;
  46577. remove(keys, key);
  46578. }
  46579. var patternTypes = [String, RegExp, Array];
  46580. var KeepAlive = {
  46581. name: 'keep-alive',
  46582. abstract: true,
  46583. props: {
  46584. include: patternTypes,
  46585. exclude: patternTypes,
  46586. max: [String, Number]
  46587. },
  46588. created: function created () {
  46589. this.cache = Object.create(null);
  46590. this.keys = [];
  46591. },
  46592. destroyed: function destroyed () {
  46593. for (var key in this.cache) {
  46594. pruneCacheEntry(this.cache, key, this.keys);
  46595. }
  46596. },
  46597. mounted: function mounted () {
  46598. var this$1 = this;
  46599. this.$watch('include', function (val) {
  46600. pruneCache(this$1, function (name) { return matches(val, name); });
  46601. });
  46602. this.$watch('exclude', function (val) {
  46603. pruneCache(this$1, function (name) { return !matches(val, name); });
  46604. });
  46605. },
  46606. render: function render () {
  46607. var slot = this.$slots.default;
  46608. var vnode = getFirstComponentChild(slot);
  46609. var componentOptions = vnode && vnode.componentOptions;
  46610. if (componentOptions) {
  46611. // check pattern
  46612. var name = getComponentName(componentOptions);
  46613. var ref = this;
  46614. var include = ref.include;
  46615. var exclude = ref.exclude;
  46616. if (
  46617. // not included
  46618. (include && (!name || !matches(include, name))) ||
  46619. // excluded
  46620. (exclude && name && matches(exclude, name))
  46621. ) {
  46622. return vnode
  46623. }
  46624. var ref$1 = this;
  46625. var cache = ref$1.cache;
  46626. var keys = ref$1.keys;
  46627. var key = vnode.key == null
  46628. // same constructor may get registered as different local components
  46629. // so cid alone is not enough (#3269)
  46630. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46631. : vnode.key;
  46632. if (cache[key]) {
  46633. vnode.componentInstance = cache[key].componentInstance;
  46634. // make current key freshest
  46635. remove(keys, key);
  46636. keys.push(key);
  46637. } else {
  46638. cache[key] = vnode;
  46639. keys.push(key);
  46640. // prune oldest entry
  46641. if (this.max && keys.length > parseInt(this.max)) {
  46642. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46643. }
  46644. }
  46645. vnode.data.keepAlive = true;
  46646. }
  46647. return vnode || (slot && slot[0])
  46648. }
  46649. };
  46650. var builtInComponents = {
  46651. KeepAlive: KeepAlive
  46652. };
  46653. /* */
  46654. function initGlobalAPI (Vue) {
  46655. // config
  46656. var configDef = {};
  46657. configDef.get = function () { return config; };
  46658. {
  46659. configDef.set = function () {
  46660. warn(
  46661. 'Do not replace the Vue.config object, set individual fields instead.'
  46662. );
  46663. };
  46664. }
  46665. Object.defineProperty(Vue, 'config', configDef);
  46666. // exposed util methods.
  46667. // NOTE: these are not considered part of the public API - avoid relying on
  46668. // them unless you are aware of the risk.
  46669. Vue.util = {
  46670. warn: warn,
  46671. extend: extend,
  46672. mergeOptions: mergeOptions,
  46673. defineReactive: defineReactive$$1
  46674. };
  46675. Vue.set = set;
  46676. Vue.delete = del;
  46677. Vue.nextTick = nextTick;
  46678. // 2.6 explicit observable API
  46679. Vue.observable = function (obj) {
  46680. observe(obj);
  46681. return obj
  46682. };
  46683. Vue.options = Object.create(null);
  46684. ASSET_TYPES.forEach(function (type) {
  46685. Vue.options[type + 's'] = Object.create(null);
  46686. });
  46687. // this is used to identify the "base" constructor to extend all plain-object
  46688. // components with in Weex's multi-instance scenarios.
  46689. Vue.options._base = Vue;
  46690. extend(Vue.options.components, builtInComponents);
  46691. initUse(Vue);
  46692. initMixin$1(Vue);
  46693. initExtend(Vue);
  46694. initAssetRegisters(Vue);
  46695. }
  46696. initGlobalAPI(Vue);
  46697. Object.defineProperty(Vue.prototype, '$isServer', {
  46698. get: isServerRendering
  46699. });
  46700. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46701. get: function get () {
  46702. /* istanbul ignore next */
  46703. return this.$vnode && this.$vnode.ssrContext
  46704. }
  46705. });
  46706. // expose FunctionalRenderContext for ssr runtime helper installation
  46707. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46708. value: FunctionalRenderContext
  46709. });
  46710. Vue.version = '2.6.11';
  46711. /* */
  46712. // these are reserved for web because they are directly compiled away
  46713. // during template compilation
  46714. var isReservedAttr = makeMap('style,class');
  46715. // attributes that should be using props for binding
  46716. var acceptValue = makeMap('input,textarea,option,select,progress');
  46717. var mustUseProp = function (tag, type, attr) {
  46718. return (
  46719. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46720. (attr === 'selected' && tag === 'option') ||
  46721. (attr === 'checked' && tag === 'input') ||
  46722. (attr === 'muted' && tag === 'video')
  46723. )
  46724. };
  46725. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46726. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46727. var convertEnumeratedValue = function (key, value) {
  46728. return isFalsyAttrValue(value) || value === 'false'
  46729. ? 'false'
  46730. // allow arbitrary string value for contenteditable
  46731. : key === 'contenteditable' && isValidContentEditableValue(value)
  46732. ? value
  46733. : 'true'
  46734. };
  46735. var isBooleanAttr = makeMap(
  46736. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46737. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46738. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46739. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46740. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46741. 'truespeed,typemustmatch,visible'
  46742. );
  46743. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46744. var isXlink = function (name) {
  46745. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46746. };
  46747. var getXlinkProp = function (name) {
  46748. return isXlink(name) ? name.slice(6, name.length) : ''
  46749. };
  46750. var isFalsyAttrValue = function (val) {
  46751. return val == null || val === false
  46752. };
  46753. /* */
  46754. function genClassForVnode (vnode) {
  46755. var data = vnode.data;
  46756. var parentNode = vnode;
  46757. var childNode = vnode;
  46758. while (isDef(childNode.componentInstance)) {
  46759. childNode = childNode.componentInstance._vnode;
  46760. if (childNode && childNode.data) {
  46761. data = mergeClassData(childNode.data, data);
  46762. }
  46763. }
  46764. while (isDef(parentNode = parentNode.parent)) {
  46765. if (parentNode && parentNode.data) {
  46766. data = mergeClassData(data, parentNode.data);
  46767. }
  46768. }
  46769. return renderClass(data.staticClass, data.class)
  46770. }
  46771. function mergeClassData (child, parent) {
  46772. return {
  46773. staticClass: concat(child.staticClass, parent.staticClass),
  46774. class: isDef(child.class)
  46775. ? [child.class, parent.class]
  46776. : parent.class
  46777. }
  46778. }
  46779. function renderClass (
  46780. staticClass,
  46781. dynamicClass
  46782. ) {
  46783. if (isDef(staticClass) || isDef(dynamicClass)) {
  46784. return concat(staticClass, stringifyClass(dynamicClass))
  46785. }
  46786. /* istanbul ignore next */
  46787. return ''
  46788. }
  46789. function concat (a, b) {
  46790. return a ? b ? (a + ' ' + b) : a : (b || '')
  46791. }
  46792. function stringifyClass (value) {
  46793. if (Array.isArray(value)) {
  46794. return stringifyArray(value)
  46795. }
  46796. if (isObject(value)) {
  46797. return stringifyObject(value)
  46798. }
  46799. if (typeof value === 'string') {
  46800. return value
  46801. }
  46802. /* istanbul ignore next */
  46803. return ''
  46804. }
  46805. function stringifyArray (value) {
  46806. var res = '';
  46807. var stringified;
  46808. for (var i = 0, l = value.length; i < l; i++) {
  46809. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46810. if (res) { res += ' '; }
  46811. res += stringified;
  46812. }
  46813. }
  46814. return res
  46815. }
  46816. function stringifyObject (value) {
  46817. var res = '';
  46818. for (var key in value) {
  46819. if (value[key]) {
  46820. if (res) { res += ' '; }
  46821. res += key;
  46822. }
  46823. }
  46824. return res
  46825. }
  46826. /* */
  46827. var namespaceMap = {
  46828. svg: 'http://www.w3.org/2000/svg',
  46829. math: 'http://www.w3.org/1998/Math/MathML'
  46830. };
  46831. var isHTMLTag = makeMap(
  46832. 'html,body,base,head,link,meta,style,title,' +
  46833. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46834. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46835. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46836. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46837. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46838. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46839. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46840. 'output,progress,select,textarea,' +
  46841. 'details,dialog,menu,menuitem,summary,' +
  46842. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46843. );
  46844. // this map is intentionally selective, only covering SVG elements that may
  46845. // contain child elements.
  46846. var isSVG = makeMap(
  46847. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46848. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46849. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46850. true
  46851. );
  46852. var isPreTag = function (tag) { return tag === 'pre'; };
  46853. var isReservedTag = function (tag) {
  46854. return isHTMLTag(tag) || isSVG(tag)
  46855. };
  46856. function getTagNamespace (tag) {
  46857. if (isSVG(tag)) {
  46858. return 'svg'
  46859. }
  46860. // basic support for MathML
  46861. // note it doesn't support other MathML elements being component roots
  46862. if (tag === 'math') {
  46863. return 'math'
  46864. }
  46865. }
  46866. var unknownElementCache = Object.create(null);
  46867. function isUnknownElement (tag) {
  46868. /* istanbul ignore if */
  46869. if (!inBrowser) {
  46870. return true
  46871. }
  46872. if (isReservedTag(tag)) {
  46873. return false
  46874. }
  46875. tag = tag.toLowerCase();
  46876. /* istanbul ignore if */
  46877. if (unknownElementCache[tag] != null) {
  46878. return unknownElementCache[tag]
  46879. }
  46880. var el = document.createElement(tag);
  46881. if (tag.indexOf('-') > -1) {
  46882. // http://stackoverflow.com/a/28210364/1070244
  46883. return (unknownElementCache[tag] = (
  46884. el.constructor === window.HTMLUnknownElement ||
  46885. el.constructor === window.HTMLElement
  46886. ))
  46887. } else {
  46888. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  46889. }
  46890. }
  46891. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  46892. /* */
  46893. /**
  46894. * Query an element selector if it's not an element already.
  46895. */
  46896. function query (el) {
  46897. if (typeof el === 'string') {
  46898. var selected = document.querySelector(el);
  46899. if (!selected) {
  46900. warn(
  46901. 'Cannot find element: ' + el
  46902. );
  46903. return document.createElement('div')
  46904. }
  46905. return selected
  46906. } else {
  46907. return el
  46908. }
  46909. }
  46910. /* */
  46911. function createElement$1 (tagName, vnode) {
  46912. var elm = document.createElement(tagName);
  46913. if (tagName !== 'select') {
  46914. return elm
  46915. }
  46916. // false or null will remove the attribute but undefined will not
  46917. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  46918. elm.setAttribute('multiple', 'multiple');
  46919. }
  46920. return elm
  46921. }
  46922. function createElementNS (namespace, tagName) {
  46923. return document.createElementNS(namespaceMap[namespace], tagName)
  46924. }
  46925. function createTextNode (text) {
  46926. return document.createTextNode(text)
  46927. }
  46928. function createComment (text) {
  46929. return document.createComment(text)
  46930. }
  46931. function insertBefore (parentNode, newNode, referenceNode) {
  46932. parentNode.insertBefore(newNode, referenceNode);
  46933. }
  46934. function removeChild (node, child) {
  46935. node.removeChild(child);
  46936. }
  46937. function appendChild (node, child) {
  46938. node.appendChild(child);
  46939. }
  46940. function parentNode (node) {
  46941. return node.parentNode
  46942. }
  46943. function nextSibling (node) {
  46944. return node.nextSibling
  46945. }
  46946. function tagName (node) {
  46947. return node.tagName
  46948. }
  46949. function setTextContent (node, text) {
  46950. node.textContent = text;
  46951. }
  46952. function setStyleScope (node, scopeId) {
  46953. node.setAttribute(scopeId, '');
  46954. }
  46955. var nodeOps = /*#__PURE__*/Object.freeze({
  46956. createElement: createElement$1,
  46957. createElementNS: createElementNS,
  46958. createTextNode: createTextNode,
  46959. createComment: createComment,
  46960. insertBefore: insertBefore,
  46961. removeChild: removeChild,
  46962. appendChild: appendChild,
  46963. parentNode: parentNode,
  46964. nextSibling: nextSibling,
  46965. tagName: tagName,
  46966. setTextContent: setTextContent,
  46967. setStyleScope: setStyleScope
  46968. });
  46969. /* */
  46970. var ref = {
  46971. create: function create (_, vnode) {
  46972. registerRef(vnode);
  46973. },
  46974. update: function update (oldVnode, vnode) {
  46975. if (oldVnode.data.ref !== vnode.data.ref) {
  46976. registerRef(oldVnode, true);
  46977. registerRef(vnode);
  46978. }
  46979. },
  46980. destroy: function destroy (vnode) {
  46981. registerRef(vnode, true);
  46982. }
  46983. };
  46984. function registerRef (vnode, isRemoval) {
  46985. var key = vnode.data.ref;
  46986. if (!isDef(key)) { return }
  46987. var vm = vnode.context;
  46988. var ref = vnode.componentInstance || vnode.elm;
  46989. var refs = vm.$refs;
  46990. if (isRemoval) {
  46991. if (Array.isArray(refs[key])) {
  46992. remove(refs[key], ref);
  46993. } else if (refs[key] === ref) {
  46994. refs[key] = undefined;
  46995. }
  46996. } else {
  46997. if (vnode.data.refInFor) {
  46998. if (!Array.isArray(refs[key])) {
  46999. refs[key] = [ref];
  47000. } else if (refs[key].indexOf(ref) < 0) {
  47001. // $flow-disable-line
  47002. refs[key].push(ref);
  47003. }
  47004. } else {
  47005. refs[key] = ref;
  47006. }
  47007. }
  47008. }
  47009. /**
  47010. * Virtual DOM patching algorithm based on Snabbdom by
  47011. * Simon Friis Vindum (@paldepind)
  47012. * Licensed under the MIT License
  47013. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  47014. *
  47015. * modified by Evan You (@yyx990803)
  47016. *
  47017. * Not type-checking this because this file is perf-critical and the cost
  47018. * of making flow understand it is not worth it.
  47019. */
  47020. var emptyNode = new VNode('', {}, []);
  47021. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  47022. function sameVnode (a, b) {
  47023. return (
  47024. a.key === b.key && (
  47025. (
  47026. a.tag === b.tag &&
  47027. a.isComment === b.isComment &&
  47028. isDef(a.data) === isDef(b.data) &&
  47029. sameInputType(a, b)
  47030. ) || (
  47031. isTrue(a.isAsyncPlaceholder) &&
  47032. a.asyncFactory === b.asyncFactory &&
  47033. isUndef(b.asyncFactory.error)
  47034. )
  47035. )
  47036. )
  47037. }
  47038. function sameInputType (a, b) {
  47039. if (a.tag !== 'input') { return true }
  47040. var i;
  47041. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  47042. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  47043. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  47044. }
  47045. function createKeyToOldIdx (children, beginIdx, endIdx) {
  47046. var i, key;
  47047. var map = {};
  47048. for (i = beginIdx; i <= endIdx; ++i) {
  47049. key = children[i].key;
  47050. if (isDef(key)) { map[key] = i; }
  47051. }
  47052. return map
  47053. }
  47054. function createPatchFunction (backend) {
  47055. var i, j;
  47056. var cbs = {};
  47057. var modules = backend.modules;
  47058. var nodeOps = backend.nodeOps;
  47059. for (i = 0; i < hooks.length; ++i) {
  47060. cbs[hooks[i]] = [];
  47061. for (j = 0; j < modules.length; ++j) {
  47062. if (isDef(modules[j][hooks[i]])) {
  47063. cbs[hooks[i]].push(modules[j][hooks[i]]);
  47064. }
  47065. }
  47066. }
  47067. function emptyNodeAt (elm) {
  47068. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  47069. }
  47070. function createRmCb (childElm, listeners) {
  47071. function remove$$1 () {
  47072. if (--remove$$1.listeners === 0) {
  47073. removeNode(childElm);
  47074. }
  47075. }
  47076. remove$$1.listeners = listeners;
  47077. return remove$$1
  47078. }
  47079. function removeNode (el) {
  47080. var parent = nodeOps.parentNode(el);
  47081. // element may have already been removed due to v-html / v-text
  47082. if (isDef(parent)) {
  47083. nodeOps.removeChild(parent, el);
  47084. }
  47085. }
  47086. function isUnknownElement$$1 (vnode, inVPre) {
  47087. return (
  47088. !inVPre &&
  47089. !vnode.ns &&
  47090. !(
  47091. config.ignoredElements.length &&
  47092. config.ignoredElements.some(function (ignore) {
  47093. return isRegExp(ignore)
  47094. ? ignore.test(vnode.tag)
  47095. : ignore === vnode.tag
  47096. })
  47097. ) &&
  47098. config.isUnknownElement(vnode.tag)
  47099. )
  47100. }
  47101. var creatingElmInVPre = 0;
  47102. function createElm (
  47103. vnode,
  47104. insertedVnodeQueue,
  47105. parentElm,
  47106. refElm,
  47107. nested,
  47108. ownerArray,
  47109. index
  47110. ) {
  47111. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47112. // This vnode was used in a previous render!
  47113. // now it's used as a new node, overwriting its elm would cause
  47114. // potential patch errors down the road when it's used as an insertion
  47115. // reference node. Instead, we clone the node on-demand before creating
  47116. // associated DOM element for it.
  47117. vnode = ownerArray[index] = cloneVNode(vnode);
  47118. }
  47119. vnode.isRootInsert = !nested; // for transition enter check
  47120. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47121. return
  47122. }
  47123. var data = vnode.data;
  47124. var children = vnode.children;
  47125. var tag = vnode.tag;
  47126. if (isDef(tag)) {
  47127. {
  47128. if (data && data.pre) {
  47129. creatingElmInVPre++;
  47130. }
  47131. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47132. warn(
  47133. 'Unknown custom element: <' + tag + '> - did you ' +
  47134. 'register the component correctly? For recursive components, ' +
  47135. 'make sure to provide the "name" option.',
  47136. vnode.context
  47137. );
  47138. }
  47139. }
  47140. vnode.elm = vnode.ns
  47141. ? nodeOps.createElementNS(vnode.ns, tag)
  47142. : nodeOps.createElement(tag, vnode);
  47143. setScope(vnode);
  47144. /* istanbul ignore if */
  47145. {
  47146. createChildren(vnode, children, insertedVnodeQueue);
  47147. if (isDef(data)) {
  47148. invokeCreateHooks(vnode, insertedVnodeQueue);
  47149. }
  47150. insert(parentElm, vnode.elm, refElm);
  47151. }
  47152. if (data && data.pre) {
  47153. creatingElmInVPre--;
  47154. }
  47155. } else if (isTrue(vnode.isComment)) {
  47156. vnode.elm = nodeOps.createComment(vnode.text);
  47157. insert(parentElm, vnode.elm, refElm);
  47158. } else {
  47159. vnode.elm = nodeOps.createTextNode(vnode.text);
  47160. insert(parentElm, vnode.elm, refElm);
  47161. }
  47162. }
  47163. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47164. var i = vnode.data;
  47165. if (isDef(i)) {
  47166. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47167. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47168. i(vnode, false /* hydrating */);
  47169. }
  47170. // after calling the init hook, if the vnode is a child component
  47171. // it should've created a child instance and mounted it. the child
  47172. // component also has set the placeholder vnode's elm.
  47173. // in that case we can just return the element and be done.
  47174. if (isDef(vnode.componentInstance)) {
  47175. initComponent(vnode, insertedVnodeQueue);
  47176. insert(parentElm, vnode.elm, refElm);
  47177. if (isTrue(isReactivated)) {
  47178. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47179. }
  47180. return true
  47181. }
  47182. }
  47183. }
  47184. function initComponent (vnode, insertedVnodeQueue) {
  47185. if (isDef(vnode.data.pendingInsert)) {
  47186. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47187. vnode.data.pendingInsert = null;
  47188. }
  47189. vnode.elm = vnode.componentInstance.$el;
  47190. if (isPatchable(vnode)) {
  47191. invokeCreateHooks(vnode, insertedVnodeQueue);
  47192. setScope(vnode);
  47193. } else {
  47194. // empty component root.
  47195. // skip all element-related modules except for ref (#3455)
  47196. registerRef(vnode);
  47197. // make sure to invoke the insert hook
  47198. insertedVnodeQueue.push(vnode);
  47199. }
  47200. }
  47201. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47202. var i;
  47203. // hack for #4339: a reactivated component with inner transition
  47204. // does not trigger because the inner node's created hooks are not called
  47205. // again. It's not ideal to involve module-specific logic in here but
  47206. // there doesn't seem to be a better way to do it.
  47207. var innerNode = vnode;
  47208. while (innerNode.componentInstance) {
  47209. innerNode = innerNode.componentInstance._vnode;
  47210. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47211. for (i = 0; i < cbs.activate.length; ++i) {
  47212. cbs.activate[i](emptyNode, innerNode);
  47213. }
  47214. insertedVnodeQueue.push(innerNode);
  47215. break
  47216. }
  47217. }
  47218. // unlike a newly created component,
  47219. // a reactivated keep-alive component doesn't insert itself
  47220. insert(parentElm, vnode.elm, refElm);
  47221. }
  47222. function insert (parent, elm, ref$$1) {
  47223. if (isDef(parent)) {
  47224. if (isDef(ref$$1)) {
  47225. if (nodeOps.parentNode(ref$$1) === parent) {
  47226. nodeOps.insertBefore(parent, elm, ref$$1);
  47227. }
  47228. } else {
  47229. nodeOps.appendChild(parent, elm);
  47230. }
  47231. }
  47232. }
  47233. function createChildren (vnode, children, insertedVnodeQueue) {
  47234. if (Array.isArray(children)) {
  47235. {
  47236. checkDuplicateKeys(children);
  47237. }
  47238. for (var i = 0; i < children.length; ++i) {
  47239. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47240. }
  47241. } else if (isPrimitive(vnode.text)) {
  47242. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47243. }
  47244. }
  47245. function isPatchable (vnode) {
  47246. while (vnode.componentInstance) {
  47247. vnode = vnode.componentInstance._vnode;
  47248. }
  47249. return isDef(vnode.tag)
  47250. }
  47251. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47252. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47253. cbs.create[i$1](emptyNode, vnode);
  47254. }
  47255. i = vnode.data.hook; // Reuse variable
  47256. if (isDef(i)) {
  47257. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47258. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47259. }
  47260. }
  47261. // set scope id attribute for scoped CSS.
  47262. // this is implemented as a special case to avoid the overhead
  47263. // of going through the normal attribute patching process.
  47264. function setScope (vnode) {
  47265. var i;
  47266. if (isDef(i = vnode.fnScopeId)) {
  47267. nodeOps.setStyleScope(vnode.elm, i);
  47268. } else {
  47269. var ancestor = vnode;
  47270. while (ancestor) {
  47271. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47272. nodeOps.setStyleScope(vnode.elm, i);
  47273. }
  47274. ancestor = ancestor.parent;
  47275. }
  47276. }
  47277. // for slot content they should also get the scopeId from the host instance.
  47278. if (isDef(i = activeInstance) &&
  47279. i !== vnode.context &&
  47280. i !== vnode.fnContext &&
  47281. isDef(i = i.$options._scopeId)
  47282. ) {
  47283. nodeOps.setStyleScope(vnode.elm, i);
  47284. }
  47285. }
  47286. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47287. for (; startIdx <= endIdx; ++startIdx) {
  47288. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47289. }
  47290. }
  47291. function invokeDestroyHook (vnode) {
  47292. var i, j;
  47293. var data = vnode.data;
  47294. if (isDef(data)) {
  47295. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47296. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47297. }
  47298. if (isDef(i = vnode.children)) {
  47299. for (j = 0; j < vnode.children.length; ++j) {
  47300. invokeDestroyHook(vnode.children[j]);
  47301. }
  47302. }
  47303. }
  47304. function removeVnodes (vnodes, startIdx, endIdx) {
  47305. for (; startIdx <= endIdx; ++startIdx) {
  47306. var ch = vnodes[startIdx];
  47307. if (isDef(ch)) {
  47308. if (isDef(ch.tag)) {
  47309. removeAndInvokeRemoveHook(ch);
  47310. invokeDestroyHook(ch);
  47311. } else { // Text node
  47312. removeNode(ch.elm);
  47313. }
  47314. }
  47315. }
  47316. }
  47317. function removeAndInvokeRemoveHook (vnode, rm) {
  47318. if (isDef(rm) || isDef(vnode.data)) {
  47319. var i;
  47320. var listeners = cbs.remove.length + 1;
  47321. if (isDef(rm)) {
  47322. // we have a recursively passed down rm callback
  47323. // increase the listeners count
  47324. rm.listeners += listeners;
  47325. } else {
  47326. // directly removing
  47327. rm = createRmCb(vnode.elm, listeners);
  47328. }
  47329. // recursively invoke hooks on child component root node
  47330. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47331. removeAndInvokeRemoveHook(i, rm);
  47332. }
  47333. for (i = 0; i < cbs.remove.length; ++i) {
  47334. cbs.remove[i](vnode, rm);
  47335. }
  47336. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47337. i(vnode, rm);
  47338. } else {
  47339. rm();
  47340. }
  47341. } else {
  47342. removeNode(vnode.elm);
  47343. }
  47344. }
  47345. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47346. var oldStartIdx = 0;
  47347. var newStartIdx = 0;
  47348. var oldEndIdx = oldCh.length - 1;
  47349. var oldStartVnode = oldCh[0];
  47350. var oldEndVnode = oldCh[oldEndIdx];
  47351. var newEndIdx = newCh.length - 1;
  47352. var newStartVnode = newCh[0];
  47353. var newEndVnode = newCh[newEndIdx];
  47354. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47355. // removeOnly is a special flag used only by <transition-group>
  47356. // to ensure removed elements stay in correct relative positions
  47357. // during leaving transitions
  47358. var canMove = !removeOnly;
  47359. {
  47360. checkDuplicateKeys(newCh);
  47361. }
  47362. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47363. if (isUndef(oldStartVnode)) {
  47364. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47365. } else if (isUndef(oldEndVnode)) {
  47366. oldEndVnode = oldCh[--oldEndIdx];
  47367. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47368. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47369. oldStartVnode = oldCh[++oldStartIdx];
  47370. newStartVnode = newCh[++newStartIdx];
  47371. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47372. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47373. oldEndVnode = oldCh[--oldEndIdx];
  47374. newEndVnode = newCh[--newEndIdx];
  47375. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47376. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47377. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47378. oldStartVnode = oldCh[++oldStartIdx];
  47379. newEndVnode = newCh[--newEndIdx];
  47380. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47381. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47382. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47383. oldEndVnode = oldCh[--oldEndIdx];
  47384. newStartVnode = newCh[++newStartIdx];
  47385. } else {
  47386. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47387. idxInOld = isDef(newStartVnode.key)
  47388. ? oldKeyToIdx[newStartVnode.key]
  47389. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47390. if (isUndef(idxInOld)) { // New element
  47391. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47392. } else {
  47393. vnodeToMove = oldCh[idxInOld];
  47394. if (sameVnode(vnodeToMove, newStartVnode)) {
  47395. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47396. oldCh[idxInOld] = undefined;
  47397. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47398. } else {
  47399. // same key but different element. treat as new element
  47400. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47401. }
  47402. }
  47403. newStartVnode = newCh[++newStartIdx];
  47404. }
  47405. }
  47406. if (oldStartIdx > oldEndIdx) {
  47407. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47408. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47409. } else if (newStartIdx > newEndIdx) {
  47410. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47411. }
  47412. }
  47413. function checkDuplicateKeys (children) {
  47414. var seenKeys = {};
  47415. for (var i = 0; i < children.length; i++) {
  47416. var vnode = children[i];
  47417. var key = vnode.key;
  47418. if (isDef(key)) {
  47419. if (seenKeys[key]) {
  47420. warn(
  47421. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47422. vnode.context
  47423. );
  47424. } else {
  47425. seenKeys[key] = true;
  47426. }
  47427. }
  47428. }
  47429. }
  47430. function findIdxInOld (node, oldCh, start, end) {
  47431. for (var i = start; i < end; i++) {
  47432. var c = oldCh[i];
  47433. if (isDef(c) && sameVnode(node, c)) { return i }
  47434. }
  47435. }
  47436. function patchVnode (
  47437. oldVnode,
  47438. vnode,
  47439. insertedVnodeQueue,
  47440. ownerArray,
  47441. index,
  47442. removeOnly
  47443. ) {
  47444. if (oldVnode === vnode) {
  47445. return
  47446. }
  47447. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47448. // clone reused vnode
  47449. vnode = ownerArray[index] = cloneVNode(vnode);
  47450. }
  47451. var elm = vnode.elm = oldVnode.elm;
  47452. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47453. if (isDef(vnode.asyncFactory.resolved)) {
  47454. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47455. } else {
  47456. vnode.isAsyncPlaceholder = true;
  47457. }
  47458. return
  47459. }
  47460. // reuse element for static trees.
  47461. // note we only do this if the vnode is cloned -
  47462. // if the new node is not cloned it means the render functions have been
  47463. // reset by the hot-reload-api and we need to do a proper re-render.
  47464. if (isTrue(vnode.isStatic) &&
  47465. isTrue(oldVnode.isStatic) &&
  47466. vnode.key === oldVnode.key &&
  47467. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47468. ) {
  47469. vnode.componentInstance = oldVnode.componentInstance;
  47470. return
  47471. }
  47472. var i;
  47473. var data = vnode.data;
  47474. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47475. i(oldVnode, vnode);
  47476. }
  47477. var oldCh = oldVnode.children;
  47478. var ch = vnode.children;
  47479. if (isDef(data) && isPatchable(vnode)) {
  47480. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47481. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47482. }
  47483. if (isUndef(vnode.text)) {
  47484. if (isDef(oldCh) && isDef(ch)) {
  47485. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47486. } else if (isDef(ch)) {
  47487. {
  47488. checkDuplicateKeys(ch);
  47489. }
  47490. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47491. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47492. } else if (isDef(oldCh)) {
  47493. removeVnodes(oldCh, 0, oldCh.length - 1);
  47494. } else if (isDef(oldVnode.text)) {
  47495. nodeOps.setTextContent(elm, '');
  47496. }
  47497. } else if (oldVnode.text !== vnode.text) {
  47498. nodeOps.setTextContent(elm, vnode.text);
  47499. }
  47500. if (isDef(data)) {
  47501. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47502. }
  47503. }
  47504. function invokeInsertHook (vnode, queue, initial) {
  47505. // delay insert hooks for component root nodes, invoke them after the
  47506. // element is really inserted
  47507. if (isTrue(initial) && isDef(vnode.parent)) {
  47508. vnode.parent.data.pendingInsert = queue;
  47509. } else {
  47510. for (var i = 0; i < queue.length; ++i) {
  47511. queue[i].data.hook.insert(queue[i]);
  47512. }
  47513. }
  47514. }
  47515. var hydrationBailed = false;
  47516. // list of modules that can skip create hook during hydration because they
  47517. // are already rendered on the client or has no need for initialization
  47518. // Note: style is excluded because it relies on initial clone for future
  47519. // deep updates (#7063).
  47520. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47521. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47522. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47523. var i;
  47524. var tag = vnode.tag;
  47525. var data = vnode.data;
  47526. var children = vnode.children;
  47527. inVPre = inVPre || (data && data.pre);
  47528. vnode.elm = elm;
  47529. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47530. vnode.isAsyncPlaceholder = true;
  47531. return true
  47532. }
  47533. // assert node match
  47534. {
  47535. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47536. return false
  47537. }
  47538. }
  47539. if (isDef(data)) {
  47540. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47541. if (isDef(i = vnode.componentInstance)) {
  47542. // child component. it should have hydrated its own tree.
  47543. initComponent(vnode, insertedVnodeQueue);
  47544. return true
  47545. }
  47546. }
  47547. if (isDef(tag)) {
  47548. if (isDef(children)) {
  47549. // empty element, allow client to pick up and populate children
  47550. if (!elm.hasChildNodes()) {
  47551. createChildren(vnode, children, insertedVnodeQueue);
  47552. } else {
  47553. // v-html and domProps: innerHTML
  47554. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47555. if (i !== elm.innerHTML) {
  47556. /* istanbul ignore if */
  47557. if (typeof console !== 'undefined' &&
  47558. !hydrationBailed
  47559. ) {
  47560. hydrationBailed = true;
  47561. console.warn('Parent: ', elm);
  47562. console.warn('server innerHTML: ', i);
  47563. console.warn('client innerHTML: ', elm.innerHTML);
  47564. }
  47565. return false
  47566. }
  47567. } else {
  47568. // iterate and compare children lists
  47569. var childrenMatch = true;
  47570. var childNode = elm.firstChild;
  47571. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47572. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47573. childrenMatch = false;
  47574. break
  47575. }
  47576. childNode = childNode.nextSibling;
  47577. }
  47578. // if childNode is not null, it means the actual childNodes list is
  47579. // longer than the virtual children list.
  47580. if (!childrenMatch || childNode) {
  47581. /* istanbul ignore if */
  47582. if (typeof console !== 'undefined' &&
  47583. !hydrationBailed
  47584. ) {
  47585. hydrationBailed = true;
  47586. console.warn('Parent: ', elm);
  47587. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47588. }
  47589. return false
  47590. }
  47591. }
  47592. }
  47593. }
  47594. if (isDef(data)) {
  47595. var fullInvoke = false;
  47596. for (var key in data) {
  47597. if (!isRenderedModule(key)) {
  47598. fullInvoke = true;
  47599. invokeCreateHooks(vnode, insertedVnodeQueue);
  47600. break
  47601. }
  47602. }
  47603. if (!fullInvoke && data['class']) {
  47604. // ensure collecting deps for deep class bindings for future updates
  47605. traverse(data['class']);
  47606. }
  47607. }
  47608. } else if (elm.data !== vnode.text) {
  47609. elm.data = vnode.text;
  47610. }
  47611. return true
  47612. }
  47613. function assertNodeMatch (node, vnode, inVPre) {
  47614. if (isDef(vnode.tag)) {
  47615. return vnode.tag.indexOf('vue-component') === 0 || (
  47616. !isUnknownElement$$1(vnode, inVPre) &&
  47617. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47618. )
  47619. } else {
  47620. return node.nodeType === (vnode.isComment ? 8 : 3)
  47621. }
  47622. }
  47623. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47624. if (isUndef(vnode)) {
  47625. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47626. return
  47627. }
  47628. var isInitialPatch = false;
  47629. var insertedVnodeQueue = [];
  47630. if (isUndef(oldVnode)) {
  47631. // empty mount (likely as component), create new root element
  47632. isInitialPatch = true;
  47633. createElm(vnode, insertedVnodeQueue);
  47634. } else {
  47635. var isRealElement = isDef(oldVnode.nodeType);
  47636. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47637. // patch existing root node
  47638. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47639. } else {
  47640. if (isRealElement) {
  47641. // mounting to a real element
  47642. // check if this is server-rendered content and if we can perform
  47643. // a successful hydration.
  47644. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47645. oldVnode.removeAttribute(SSR_ATTR);
  47646. hydrating = true;
  47647. }
  47648. if (isTrue(hydrating)) {
  47649. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47650. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47651. return oldVnode
  47652. } else {
  47653. warn(
  47654. 'The client-side rendered virtual DOM tree is not matching ' +
  47655. 'server-rendered content. This is likely caused by incorrect ' +
  47656. 'HTML markup, for example nesting block-level elements inside ' +
  47657. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47658. 'full client-side render.'
  47659. );
  47660. }
  47661. }
  47662. // either not server-rendered, or hydration failed.
  47663. // create an empty node and replace it
  47664. oldVnode = emptyNodeAt(oldVnode);
  47665. }
  47666. // replacing existing element
  47667. var oldElm = oldVnode.elm;
  47668. var parentElm = nodeOps.parentNode(oldElm);
  47669. // create new node
  47670. createElm(
  47671. vnode,
  47672. insertedVnodeQueue,
  47673. // extremely rare edge case: do not insert if old element is in a
  47674. // leaving transition. Only happens when combining transition +
  47675. // keep-alive + HOCs. (#4590)
  47676. oldElm._leaveCb ? null : parentElm,
  47677. nodeOps.nextSibling(oldElm)
  47678. );
  47679. // update parent placeholder node element, recursively
  47680. if (isDef(vnode.parent)) {
  47681. var ancestor = vnode.parent;
  47682. var patchable = isPatchable(vnode);
  47683. while (ancestor) {
  47684. for (var i = 0; i < cbs.destroy.length; ++i) {
  47685. cbs.destroy[i](ancestor);
  47686. }
  47687. ancestor.elm = vnode.elm;
  47688. if (patchable) {
  47689. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47690. cbs.create[i$1](emptyNode, ancestor);
  47691. }
  47692. // #6513
  47693. // invoke insert hooks that may have been merged by create hooks.
  47694. // e.g. for directives that uses the "inserted" hook.
  47695. var insert = ancestor.data.hook.insert;
  47696. if (insert.merged) {
  47697. // start at index 1 to avoid re-invoking component mounted hook
  47698. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47699. insert.fns[i$2]();
  47700. }
  47701. }
  47702. } else {
  47703. registerRef(ancestor);
  47704. }
  47705. ancestor = ancestor.parent;
  47706. }
  47707. }
  47708. // destroy old node
  47709. if (isDef(parentElm)) {
  47710. removeVnodes([oldVnode], 0, 0);
  47711. } else if (isDef(oldVnode.tag)) {
  47712. invokeDestroyHook(oldVnode);
  47713. }
  47714. }
  47715. }
  47716. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47717. return vnode.elm
  47718. }
  47719. }
  47720. /* */
  47721. var directives = {
  47722. create: updateDirectives,
  47723. update: updateDirectives,
  47724. destroy: function unbindDirectives (vnode) {
  47725. updateDirectives(vnode, emptyNode);
  47726. }
  47727. };
  47728. function updateDirectives (oldVnode, vnode) {
  47729. if (oldVnode.data.directives || vnode.data.directives) {
  47730. _update(oldVnode, vnode);
  47731. }
  47732. }
  47733. function _update (oldVnode, vnode) {
  47734. var isCreate = oldVnode === emptyNode;
  47735. var isDestroy = vnode === emptyNode;
  47736. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47737. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47738. var dirsWithInsert = [];
  47739. var dirsWithPostpatch = [];
  47740. var key, oldDir, dir;
  47741. for (key in newDirs) {
  47742. oldDir = oldDirs[key];
  47743. dir = newDirs[key];
  47744. if (!oldDir) {
  47745. // new directive, bind
  47746. callHook$1(dir, 'bind', vnode, oldVnode);
  47747. if (dir.def && dir.def.inserted) {
  47748. dirsWithInsert.push(dir);
  47749. }
  47750. } else {
  47751. // existing directive, update
  47752. dir.oldValue = oldDir.value;
  47753. dir.oldArg = oldDir.arg;
  47754. callHook$1(dir, 'update', vnode, oldVnode);
  47755. if (dir.def && dir.def.componentUpdated) {
  47756. dirsWithPostpatch.push(dir);
  47757. }
  47758. }
  47759. }
  47760. if (dirsWithInsert.length) {
  47761. var callInsert = function () {
  47762. for (var i = 0; i < dirsWithInsert.length; i++) {
  47763. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47764. }
  47765. };
  47766. if (isCreate) {
  47767. mergeVNodeHook(vnode, 'insert', callInsert);
  47768. } else {
  47769. callInsert();
  47770. }
  47771. }
  47772. if (dirsWithPostpatch.length) {
  47773. mergeVNodeHook(vnode, 'postpatch', function () {
  47774. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47775. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47776. }
  47777. });
  47778. }
  47779. if (!isCreate) {
  47780. for (key in oldDirs) {
  47781. if (!newDirs[key]) {
  47782. // no longer present, unbind
  47783. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47784. }
  47785. }
  47786. }
  47787. }
  47788. var emptyModifiers = Object.create(null);
  47789. function normalizeDirectives$1 (
  47790. dirs,
  47791. vm
  47792. ) {
  47793. var res = Object.create(null);
  47794. if (!dirs) {
  47795. // $flow-disable-line
  47796. return res
  47797. }
  47798. var i, dir;
  47799. for (i = 0; i < dirs.length; i++) {
  47800. dir = dirs[i];
  47801. if (!dir.modifiers) {
  47802. // $flow-disable-line
  47803. dir.modifiers = emptyModifiers;
  47804. }
  47805. res[getRawDirName(dir)] = dir;
  47806. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47807. }
  47808. // $flow-disable-line
  47809. return res
  47810. }
  47811. function getRawDirName (dir) {
  47812. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47813. }
  47814. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47815. var fn = dir.def && dir.def[hook];
  47816. if (fn) {
  47817. try {
  47818. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47819. } catch (e) {
  47820. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47821. }
  47822. }
  47823. }
  47824. var baseModules = [
  47825. ref,
  47826. directives
  47827. ];
  47828. /* */
  47829. function updateAttrs (oldVnode, vnode) {
  47830. var opts = vnode.componentOptions;
  47831. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47832. return
  47833. }
  47834. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47835. return
  47836. }
  47837. var key, cur, old;
  47838. var elm = vnode.elm;
  47839. var oldAttrs = oldVnode.data.attrs || {};
  47840. var attrs = vnode.data.attrs || {};
  47841. // clone observed objects, as the user probably wants to mutate it
  47842. if (isDef(attrs.__ob__)) {
  47843. attrs = vnode.data.attrs = extend({}, attrs);
  47844. }
  47845. for (key in attrs) {
  47846. cur = attrs[key];
  47847. old = oldAttrs[key];
  47848. if (old !== cur) {
  47849. setAttr(elm, key, cur);
  47850. }
  47851. }
  47852. // #4391: in IE9, setting type can reset value for input[type=radio]
  47853. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47854. /* istanbul ignore if */
  47855. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47856. setAttr(elm, 'value', attrs.value);
  47857. }
  47858. for (key in oldAttrs) {
  47859. if (isUndef(attrs[key])) {
  47860. if (isXlink(key)) {
  47861. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47862. } else if (!isEnumeratedAttr(key)) {
  47863. elm.removeAttribute(key);
  47864. }
  47865. }
  47866. }
  47867. }
  47868. function setAttr (el, key, value) {
  47869. if (el.tagName.indexOf('-') > -1) {
  47870. baseSetAttr(el, key, value);
  47871. } else if (isBooleanAttr(key)) {
  47872. // set attribute for blank value
  47873. // e.g. <option disabled>Select one</option>
  47874. if (isFalsyAttrValue(value)) {
  47875. el.removeAttribute(key);
  47876. } else {
  47877. // technically allowfullscreen is a boolean attribute for <iframe>,
  47878. // but Flash expects a value of "true" when used on <embed> tag
  47879. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  47880. ? 'true'
  47881. : key;
  47882. el.setAttribute(key, value);
  47883. }
  47884. } else if (isEnumeratedAttr(key)) {
  47885. el.setAttribute(key, convertEnumeratedValue(key, value));
  47886. } else if (isXlink(key)) {
  47887. if (isFalsyAttrValue(value)) {
  47888. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47889. } else {
  47890. el.setAttributeNS(xlinkNS, key, value);
  47891. }
  47892. } else {
  47893. baseSetAttr(el, key, value);
  47894. }
  47895. }
  47896. function baseSetAttr (el, key, value) {
  47897. if (isFalsyAttrValue(value)) {
  47898. el.removeAttribute(key);
  47899. } else {
  47900. // #7138: IE10 & 11 fires input event when setting placeholder on
  47901. // <textarea>... block the first input event and remove the blocker
  47902. // immediately.
  47903. /* istanbul ignore if */
  47904. if (
  47905. isIE && !isIE9 &&
  47906. el.tagName === 'TEXTAREA' &&
  47907. key === 'placeholder' && value !== '' && !el.__ieph
  47908. ) {
  47909. var blocker = function (e) {
  47910. e.stopImmediatePropagation();
  47911. el.removeEventListener('input', blocker);
  47912. };
  47913. el.addEventListener('input', blocker);
  47914. // $flow-disable-line
  47915. el.__ieph = true; /* IE placeholder patched */
  47916. }
  47917. el.setAttribute(key, value);
  47918. }
  47919. }
  47920. var attrs = {
  47921. create: updateAttrs,
  47922. update: updateAttrs
  47923. };
  47924. /* */
  47925. function updateClass (oldVnode, vnode) {
  47926. var el = vnode.elm;
  47927. var data = vnode.data;
  47928. var oldData = oldVnode.data;
  47929. if (
  47930. isUndef(data.staticClass) &&
  47931. isUndef(data.class) && (
  47932. isUndef(oldData) || (
  47933. isUndef(oldData.staticClass) &&
  47934. isUndef(oldData.class)
  47935. )
  47936. )
  47937. ) {
  47938. return
  47939. }
  47940. var cls = genClassForVnode(vnode);
  47941. // handle transition classes
  47942. var transitionClass = el._transitionClasses;
  47943. if (isDef(transitionClass)) {
  47944. cls = concat(cls, stringifyClass(transitionClass));
  47945. }
  47946. // set the class
  47947. if (cls !== el._prevClass) {
  47948. el.setAttribute('class', cls);
  47949. el._prevClass = cls;
  47950. }
  47951. }
  47952. var klass = {
  47953. create: updateClass,
  47954. update: updateClass
  47955. };
  47956. /* */
  47957. var validDivisionCharRE = /[\w).+\-_$\]]/;
  47958. function parseFilters (exp) {
  47959. var inSingle = false;
  47960. var inDouble = false;
  47961. var inTemplateString = false;
  47962. var inRegex = false;
  47963. var curly = 0;
  47964. var square = 0;
  47965. var paren = 0;
  47966. var lastFilterIndex = 0;
  47967. var c, prev, i, expression, filters;
  47968. for (i = 0; i < exp.length; i++) {
  47969. prev = c;
  47970. c = exp.charCodeAt(i);
  47971. if (inSingle) {
  47972. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  47973. } else if (inDouble) {
  47974. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  47975. } else if (inTemplateString) {
  47976. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  47977. } else if (inRegex) {
  47978. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  47979. } else if (
  47980. c === 0x7C && // pipe
  47981. exp.charCodeAt(i + 1) !== 0x7C &&
  47982. exp.charCodeAt(i - 1) !== 0x7C &&
  47983. !curly && !square && !paren
  47984. ) {
  47985. if (expression === undefined) {
  47986. // first filter, end of expression
  47987. lastFilterIndex = i + 1;
  47988. expression = exp.slice(0, i).trim();
  47989. } else {
  47990. pushFilter();
  47991. }
  47992. } else {
  47993. switch (c) {
  47994. case 0x22: inDouble = true; break // "
  47995. case 0x27: inSingle = true; break // '
  47996. case 0x60: inTemplateString = true; break // `
  47997. case 0x28: paren++; break // (
  47998. case 0x29: paren--; break // )
  47999. case 0x5B: square++; break // [
  48000. case 0x5D: square--; break // ]
  48001. case 0x7B: curly++; break // {
  48002. case 0x7D: curly--; break // }
  48003. }
  48004. if (c === 0x2f) { // /
  48005. var j = i - 1;
  48006. var p = (void 0);
  48007. // find first non-whitespace prev char
  48008. for (; j >= 0; j--) {
  48009. p = exp.charAt(j);
  48010. if (p !== ' ') { break }
  48011. }
  48012. if (!p || !validDivisionCharRE.test(p)) {
  48013. inRegex = true;
  48014. }
  48015. }
  48016. }
  48017. }
  48018. if (expression === undefined) {
  48019. expression = exp.slice(0, i).trim();
  48020. } else if (lastFilterIndex !== 0) {
  48021. pushFilter();
  48022. }
  48023. function pushFilter () {
  48024. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  48025. lastFilterIndex = i + 1;
  48026. }
  48027. if (filters) {
  48028. for (i = 0; i < filters.length; i++) {
  48029. expression = wrapFilter(expression, filters[i]);
  48030. }
  48031. }
  48032. return expression
  48033. }
  48034. function wrapFilter (exp, filter) {
  48035. var i = filter.indexOf('(');
  48036. if (i < 0) {
  48037. // _f: resolveFilter
  48038. return ("_f(\"" + filter + "\")(" + exp + ")")
  48039. } else {
  48040. var name = filter.slice(0, i);
  48041. var args = filter.slice(i + 1);
  48042. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  48043. }
  48044. }
  48045. /* */
  48046. /* eslint-disable no-unused-vars */
  48047. function baseWarn (msg, range) {
  48048. console.error(("[Vue compiler]: " + msg));
  48049. }
  48050. /* eslint-enable no-unused-vars */
  48051. function pluckModuleFunction (
  48052. modules,
  48053. key
  48054. ) {
  48055. return modules
  48056. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  48057. : []
  48058. }
  48059. function addProp (el, name, value, range, dynamic) {
  48060. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48061. el.plain = false;
  48062. }
  48063. function addAttr (el, name, value, range, dynamic) {
  48064. var attrs = dynamic
  48065. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  48066. : (el.attrs || (el.attrs = []));
  48067. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48068. el.plain = false;
  48069. }
  48070. // add a raw attr (use this in preTransforms)
  48071. function addRawAttr (el, name, value, range) {
  48072. el.attrsMap[name] = value;
  48073. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  48074. }
  48075. function addDirective (
  48076. el,
  48077. name,
  48078. rawName,
  48079. value,
  48080. arg,
  48081. isDynamicArg,
  48082. modifiers,
  48083. range
  48084. ) {
  48085. (el.directives || (el.directives = [])).push(rangeSetItem({
  48086. name: name,
  48087. rawName: rawName,
  48088. value: value,
  48089. arg: arg,
  48090. isDynamicArg: isDynamicArg,
  48091. modifiers: modifiers
  48092. }, range));
  48093. el.plain = false;
  48094. }
  48095. function prependModifierMarker (symbol, name, dynamic) {
  48096. return dynamic
  48097. ? ("_p(" + name + ",\"" + symbol + "\")")
  48098. : symbol + name // mark the event as captured
  48099. }
  48100. function addHandler (
  48101. el,
  48102. name,
  48103. value,
  48104. modifiers,
  48105. important,
  48106. warn,
  48107. range,
  48108. dynamic
  48109. ) {
  48110. modifiers = modifiers || emptyObject;
  48111. // warn prevent and passive modifier
  48112. /* istanbul ignore if */
  48113. if (
  48114. warn &&
  48115. modifiers.prevent && modifiers.passive
  48116. ) {
  48117. warn(
  48118. 'passive and prevent can\'t be used together. ' +
  48119. 'Passive handler can\'t prevent default event.',
  48120. range
  48121. );
  48122. }
  48123. // normalize click.right and click.middle since they don't actually fire
  48124. // this is technically browser-specific, but at least for now browsers are
  48125. // the only target envs that have right/middle clicks.
  48126. if (modifiers.right) {
  48127. if (dynamic) {
  48128. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48129. } else if (name === 'click') {
  48130. name = 'contextmenu';
  48131. delete modifiers.right;
  48132. }
  48133. } else if (modifiers.middle) {
  48134. if (dynamic) {
  48135. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48136. } else if (name === 'click') {
  48137. name = 'mouseup';
  48138. }
  48139. }
  48140. // check capture modifier
  48141. if (modifiers.capture) {
  48142. delete modifiers.capture;
  48143. name = prependModifierMarker('!', name, dynamic);
  48144. }
  48145. if (modifiers.once) {
  48146. delete modifiers.once;
  48147. name = prependModifierMarker('~', name, dynamic);
  48148. }
  48149. /* istanbul ignore if */
  48150. if (modifiers.passive) {
  48151. delete modifiers.passive;
  48152. name = prependModifierMarker('&', name, dynamic);
  48153. }
  48154. var events;
  48155. if (modifiers.native) {
  48156. delete modifiers.native;
  48157. events = el.nativeEvents || (el.nativeEvents = {});
  48158. } else {
  48159. events = el.events || (el.events = {});
  48160. }
  48161. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48162. if (modifiers !== emptyObject) {
  48163. newHandler.modifiers = modifiers;
  48164. }
  48165. var handlers = events[name];
  48166. /* istanbul ignore if */
  48167. if (Array.isArray(handlers)) {
  48168. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48169. } else if (handlers) {
  48170. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48171. } else {
  48172. events[name] = newHandler;
  48173. }
  48174. el.plain = false;
  48175. }
  48176. function getRawBindingAttr (
  48177. el,
  48178. name
  48179. ) {
  48180. return el.rawAttrsMap[':' + name] ||
  48181. el.rawAttrsMap['v-bind:' + name] ||
  48182. el.rawAttrsMap[name]
  48183. }
  48184. function getBindingAttr (
  48185. el,
  48186. name,
  48187. getStatic
  48188. ) {
  48189. var dynamicValue =
  48190. getAndRemoveAttr(el, ':' + name) ||
  48191. getAndRemoveAttr(el, 'v-bind:' + name);
  48192. if (dynamicValue != null) {
  48193. return parseFilters(dynamicValue)
  48194. } else if (getStatic !== false) {
  48195. var staticValue = getAndRemoveAttr(el, name);
  48196. if (staticValue != null) {
  48197. return JSON.stringify(staticValue)
  48198. }
  48199. }
  48200. }
  48201. // note: this only removes the attr from the Array (attrsList) so that it
  48202. // doesn't get processed by processAttrs.
  48203. // By default it does NOT remove it from the map (attrsMap) because the map is
  48204. // needed during codegen.
  48205. function getAndRemoveAttr (
  48206. el,
  48207. name,
  48208. removeFromMap
  48209. ) {
  48210. var val;
  48211. if ((val = el.attrsMap[name]) != null) {
  48212. var list = el.attrsList;
  48213. for (var i = 0, l = list.length; i < l; i++) {
  48214. if (list[i].name === name) {
  48215. list.splice(i, 1);
  48216. break
  48217. }
  48218. }
  48219. }
  48220. if (removeFromMap) {
  48221. delete el.attrsMap[name];
  48222. }
  48223. return val
  48224. }
  48225. function getAndRemoveAttrByRegex (
  48226. el,
  48227. name
  48228. ) {
  48229. var list = el.attrsList;
  48230. for (var i = 0, l = list.length; i < l; i++) {
  48231. var attr = list[i];
  48232. if (name.test(attr.name)) {
  48233. list.splice(i, 1);
  48234. return attr
  48235. }
  48236. }
  48237. }
  48238. function rangeSetItem (
  48239. item,
  48240. range
  48241. ) {
  48242. if (range) {
  48243. if (range.start != null) {
  48244. item.start = range.start;
  48245. }
  48246. if (range.end != null) {
  48247. item.end = range.end;
  48248. }
  48249. }
  48250. return item
  48251. }
  48252. /* */
  48253. /**
  48254. * Cross-platform code generation for component v-model
  48255. */
  48256. function genComponentModel (
  48257. el,
  48258. value,
  48259. modifiers
  48260. ) {
  48261. var ref = modifiers || {};
  48262. var number = ref.number;
  48263. var trim = ref.trim;
  48264. var baseValueExpression = '$$v';
  48265. var valueExpression = baseValueExpression;
  48266. if (trim) {
  48267. valueExpression =
  48268. "(typeof " + baseValueExpression + " === 'string'" +
  48269. "? " + baseValueExpression + ".trim()" +
  48270. ": " + baseValueExpression + ")";
  48271. }
  48272. if (number) {
  48273. valueExpression = "_n(" + valueExpression + ")";
  48274. }
  48275. var assignment = genAssignmentCode(value, valueExpression);
  48276. el.model = {
  48277. value: ("(" + value + ")"),
  48278. expression: JSON.stringify(value),
  48279. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48280. };
  48281. }
  48282. /**
  48283. * Cross-platform codegen helper for generating v-model value assignment code.
  48284. */
  48285. function genAssignmentCode (
  48286. value,
  48287. assignment
  48288. ) {
  48289. var res = parseModel(value);
  48290. if (res.key === null) {
  48291. return (value + "=" + assignment)
  48292. } else {
  48293. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48294. }
  48295. }
  48296. /**
  48297. * Parse a v-model expression into a base path and a final key segment.
  48298. * Handles both dot-path and possible square brackets.
  48299. *
  48300. * Possible cases:
  48301. *
  48302. * - test
  48303. * - test[key]
  48304. * - test[test1[key]]
  48305. * - test["a"][key]
  48306. * - xxx.test[a[a].test1[key]]
  48307. * - test.xxx.a["asa"][test1[key]]
  48308. *
  48309. */
  48310. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48311. function parseModel (val) {
  48312. // Fix https://github.com/vuejs/vue/pull/7730
  48313. // allow v-model="obj.val " (trailing whitespace)
  48314. val = val.trim();
  48315. len = val.length;
  48316. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48317. index$1 = val.lastIndexOf('.');
  48318. if (index$1 > -1) {
  48319. return {
  48320. exp: val.slice(0, index$1),
  48321. key: '"' + val.slice(index$1 + 1) + '"'
  48322. }
  48323. } else {
  48324. return {
  48325. exp: val,
  48326. key: null
  48327. }
  48328. }
  48329. }
  48330. str = val;
  48331. index$1 = expressionPos = expressionEndPos = 0;
  48332. while (!eof()) {
  48333. chr = next();
  48334. /* istanbul ignore if */
  48335. if (isStringStart(chr)) {
  48336. parseString(chr);
  48337. } else if (chr === 0x5B) {
  48338. parseBracket(chr);
  48339. }
  48340. }
  48341. return {
  48342. exp: val.slice(0, expressionPos),
  48343. key: val.slice(expressionPos + 1, expressionEndPos)
  48344. }
  48345. }
  48346. function next () {
  48347. return str.charCodeAt(++index$1)
  48348. }
  48349. function eof () {
  48350. return index$1 >= len
  48351. }
  48352. function isStringStart (chr) {
  48353. return chr === 0x22 || chr === 0x27
  48354. }
  48355. function parseBracket (chr) {
  48356. var inBracket = 1;
  48357. expressionPos = index$1;
  48358. while (!eof()) {
  48359. chr = next();
  48360. if (isStringStart(chr)) {
  48361. parseString(chr);
  48362. continue
  48363. }
  48364. if (chr === 0x5B) { inBracket++; }
  48365. if (chr === 0x5D) { inBracket--; }
  48366. if (inBracket === 0) {
  48367. expressionEndPos = index$1;
  48368. break
  48369. }
  48370. }
  48371. }
  48372. function parseString (chr) {
  48373. var stringQuote = chr;
  48374. while (!eof()) {
  48375. chr = next();
  48376. if (chr === stringQuote) {
  48377. break
  48378. }
  48379. }
  48380. }
  48381. /* */
  48382. var warn$1;
  48383. // in some cases, the event used has to be determined at runtime
  48384. // so we used some reserved tokens during compile.
  48385. var RANGE_TOKEN = '__r';
  48386. var CHECKBOX_RADIO_TOKEN = '__c';
  48387. function model (
  48388. el,
  48389. dir,
  48390. _warn
  48391. ) {
  48392. warn$1 = _warn;
  48393. var value = dir.value;
  48394. var modifiers = dir.modifiers;
  48395. var tag = el.tag;
  48396. var type = el.attrsMap.type;
  48397. {
  48398. // inputs with type="file" are read only and setting the input's
  48399. // value will throw an error.
  48400. if (tag === 'input' && type === 'file') {
  48401. warn$1(
  48402. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48403. "File inputs are read only. Use a v-on:change listener instead.",
  48404. el.rawAttrsMap['v-model']
  48405. );
  48406. }
  48407. }
  48408. if (el.component) {
  48409. genComponentModel(el, value, modifiers);
  48410. // component v-model doesn't need extra runtime
  48411. return false
  48412. } else if (tag === 'select') {
  48413. genSelect(el, value, modifiers);
  48414. } else if (tag === 'input' && type === 'checkbox') {
  48415. genCheckboxModel(el, value, modifiers);
  48416. } else if (tag === 'input' && type === 'radio') {
  48417. genRadioModel(el, value, modifiers);
  48418. } else if (tag === 'input' || tag === 'textarea') {
  48419. genDefaultModel(el, value, modifiers);
  48420. } else if (!config.isReservedTag(tag)) {
  48421. genComponentModel(el, value, modifiers);
  48422. // component v-model doesn't need extra runtime
  48423. return false
  48424. } else {
  48425. warn$1(
  48426. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48427. "v-model is not supported on this element type. " +
  48428. 'If you are working with contenteditable, it\'s recommended to ' +
  48429. 'wrap a library dedicated for that purpose inside a custom component.',
  48430. el.rawAttrsMap['v-model']
  48431. );
  48432. }
  48433. // ensure runtime directive metadata
  48434. return true
  48435. }
  48436. function genCheckboxModel (
  48437. el,
  48438. value,
  48439. modifiers
  48440. ) {
  48441. var number = modifiers && modifiers.number;
  48442. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48443. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48444. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48445. addProp(el, 'checked',
  48446. "Array.isArray(" + value + ")" +
  48447. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48448. trueValueBinding === 'true'
  48449. ? (":(" + value + ")")
  48450. : (":_q(" + value + "," + trueValueBinding + ")")
  48451. )
  48452. );
  48453. addHandler(el, 'change',
  48454. "var $$a=" + value + "," +
  48455. '$$el=$event.target,' +
  48456. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48457. 'if(Array.isArray($$a)){' +
  48458. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48459. '$$i=_i($$a,$$v);' +
  48460. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48461. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48462. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48463. null, true
  48464. );
  48465. }
  48466. function genRadioModel (
  48467. el,
  48468. value,
  48469. modifiers
  48470. ) {
  48471. var number = modifiers && modifiers.number;
  48472. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48473. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48474. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48475. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48476. }
  48477. function genSelect (
  48478. el,
  48479. value,
  48480. modifiers
  48481. ) {
  48482. var number = modifiers && modifiers.number;
  48483. var selectedVal = "Array.prototype.filter" +
  48484. ".call($event.target.options,function(o){return o.selected})" +
  48485. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48486. "return " + (number ? '_n(val)' : 'val') + "})";
  48487. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48488. var code = "var $$selectedVal = " + selectedVal + ";";
  48489. code = code + " " + (genAssignmentCode(value, assignment));
  48490. addHandler(el, 'change', code, null, true);
  48491. }
  48492. function genDefaultModel (
  48493. el,
  48494. value,
  48495. modifiers
  48496. ) {
  48497. var type = el.attrsMap.type;
  48498. // warn if v-bind:value conflicts with v-model
  48499. // except for inputs with v-bind:type
  48500. {
  48501. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48502. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48503. if (value$1 && !typeBinding) {
  48504. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48505. warn$1(
  48506. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48507. 'because the latter already expands to a value binding internally',
  48508. el.rawAttrsMap[binding]
  48509. );
  48510. }
  48511. }
  48512. var ref = modifiers || {};
  48513. var lazy = ref.lazy;
  48514. var number = ref.number;
  48515. var trim = ref.trim;
  48516. var needCompositionGuard = !lazy && type !== 'range';
  48517. var event = lazy
  48518. ? 'change'
  48519. : type === 'range'
  48520. ? RANGE_TOKEN
  48521. : 'input';
  48522. var valueExpression = '$event.target.value';
  48523. if (trim) {
  48524. valueExpression = "$event.target.value.trim()";
  48525. }
  48526. if (number) {
  48527. valueExpression = "_n(" + valueExpression + ")";
  48528. }
  48529. var code = genAssignmentCode(value, valueExpression);
  48530. if (needCompositionGuard) {
  48531. code = "if($event.target.composing)return;" + code;
  48532. }
  48533. addProp(el, 'value', ("(" + value + ")"));
  48534. addHandler(el, event, code, null, true);
  48535. if (trim || number) {
  48536. addHandler(el, 'blur', '$forceUpdate()');
  48537. }
  48538. }
  48539. /* */
  48540. // normalize v-model event tokens that can only be determined at runtime.
  48541. // it's important to place the event as the first in the array because
  48542. // the whole point is ensuring the v-model callback gets called before
  48543. // user-attached handlers.
  48544. function normalizeEvents (on) {
  48545. /* istanbul ignore if */
  48546. if (isDef(on[RANGE_TOKEN])) {
  48547. // IE input[type=range] only supports `change` event
  48548. var event = isIE ? 'change' : 'input';
  48549. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48550. delete on[RANGE_TOKEN];
  48551. }
  48552. // This was originally intended to fix #4521 but no longer necessary
  48553. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48554. /* istanbul ignore if */
  48555. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48556. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48557. delete on[CHECKBOX_RADIO_TOKEN];
  48558. }
  48559. }
  48560. var target$1;
  48561. function createOnceHandler$1 (event, handler, capture) {
  48562. var _target = target$1; // save current target element in closure
  48563. return function onceHandler () {
  48564. var res = handler.apply(null, arguments);
  48565. if (res !== null) {
  48566. remove$2(event, onceHandler, capture, _target);
  48567. }
  48568. }
  48569. }
  48570. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48571. // implementation and does not fire microtasks in between event propagation, so
  48572. // safe to exclude.
  48573. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48574. function add$1 (
  48575. name,
  48576. handler,
  48577. capture,
  48578. passive
  48579. ) {
  48580. // async edge case #6566: inner click event triggers patch, event handler
  48581. // attached to outer element during patch, and triggered again. This
  48582. // happens because browsers fire microtask ticks between event propagation.
  48583. // the solution is simple: we save the timestamp when a handler is attached,
  48584. // and the handler would only fire if the event passed to it was fired
  48585. // AFTER it was attached.
  48586. if (useMicrotaskFix) {
  48587. var attachedTimestamp = currentFlushTimestamp;
  48588. var original = handler;
  48589. handler = original._wrapper = function (e) {
  48590. if (
  48591. // no bubbling, should always fire.
  48592. // this is just a safety net in case event.timeStamp is unreliable in
  48593. // certain weird environments...
  48594. e.target === e.currentTarget ||
  48595. // event is fired after handler attachment
  48596. e.timeStamp >= attachedTimestamp ||
  48597. // bail for environments that have buggy event.timeStamp implementations
  48598. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48599. // #9681 QtWebEngine event.timeStamp is negative value
  48600. e.timeStamp <= 0 ||
  48601. // #9448 bail if event is fired in another document in a multi-page
  48602. // electron/nw.js app, since event.timeStamp will be using a different
  48603. // starting reference
  48604. e.target.ownerDocument !== document
  48605. ) {
  48606. return original.apply(this, arguments)
  48607. }
  48608. };
  48609. }
  48610. target$1.addEventListener(
  48611. name,
  48612. handler,
  48613. supportsPassive
  48614. ? { capture: capture, passive: passive }
  48615. : capture
  48616. );
  48617. }
  48618. function remove$2 (
  48619. name,
  48620. handler,
  48621. capture,
  48622. _target
  48623. ) {
  48624. (_target || target$1).removeEventListener(
  48625. name,
  48626. handler._wrapper || handler,
  48627. capture
  48628. );
  48629. }
  48630. function updateDOMListeners (oldVnode, vnode) {
  48631. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48632. return
  48633. }
  48634. var on = vnode.data.on || {};
  48635. var oldOn = oldVnode.data.on || {};
  48636. target$1 = vnode.elm;
  48637. normalizeEvents(on);
  48638. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48639. target$1 = undefined;
  48640. }
  48641. var events = {
  48642. create: updateDOMListeners,
  48643. update: updateDOMListeners
  48644. };
  48645. /* */
  48646. var svgContainer;
  48647. function updateDOMProps (oldVnode, vnode) {
  48648. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48649. return
  48650. }
  48651. var key, cur;
  48652. var elm = vnode.elm;
  48653. var oldProps = oldVnode.data.domProps || {};
  48654. var props = vnode.data.domProps || {};
  48655. // clone observed objects, as the user probably wants to mutate it
  48656. if (isDef(props.__ob__)) {
  48657. props = vnode.data.domProps = extend({}, props);
  48658. }
  48659. for (key in oldProps) {
  48660. if (!(key in props)) {
  48661. elm[key] = '';
  48662. }
  48663. }
  48664. for (key in props) {
  48665. cur = props[key];
  48666. // ignore children if the node has textContent or innerHTML,
  48667. // as these will throw away existing DOM nodes and cause removal errors
  48668. // on subsequent patches (#3360)
  48669. if (key === 'textContent' || key === 'innerHTML') {
  48670. if (vnode.children) { vnode.children.length = 0; }
  48671. if (cur === oldProps[key]) { continue }
  48672. // #6601 work around Chrome version <= 55 bug where single textNode
  48673. // replaced by innerHTML/textContent retains its parentNode property
  48674. if (elm.childNodes.length === 1) {
  48675. elm.removeChild(elm.childNodes[0]);
  48676. }
  48677. }
  48678. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48679. // store value as _value as well since
  48680. // non-string values will be stringified
  48681. elm._value = cur;
  48682. // avoid resetting cursor position when value is the same
  48683. var strCur = isUndef(cur) ? '' : String(cur);
  48684. if (shouldUpdateValue(elm, strCur)) {
  48685. elm.value = strCur;
  48686. }
  48687. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48688. // IE doesn't support innerHTML for SVG elements
  48689. svgContainer = svgContainer || document.createElement('div');
  48690. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48691. var svg = svgContainer.firstChild;
  48692. while (elm.firstChild) {
  48693. elm.removeChild(elm.firstChild);
  48694. }
  48695. while (svg.firstChild) {
  48696. elm.appendChild(svg.firstChild);
  48697. }
  48698. } else if (
  48699. // skip the update if old and new VDOM state is the same.
  48700. // `value` is handled separately because the DOM value may be temporarily
  48701. // out of sync with VDOM state due to focus, composition and modifiers.
  48702. // This #4521 by skipping the unnecesarry `checked` update.
  48703. cur !== oldProps[key]
  48704. ) {
  48705. // some property updates can throw
  48706. // e.g. `value` on <progress> w/ non-finite value
  48707. try {
  48708. elm[key] = cur;
  48709. } catch (e) {}
  48710. }
  48711. }
  48712. }
  48713. // check platforms/web/util/attrs.js acceptValue
  48714. function shouldUpdateValue (elm, checkVal) {
  48715. return (!elm.composing && (
  48716. elm.tagName === 'OPTION' ||
  48717. isNotInFocusAndDirty(elm, checkVal) ||
  48718. isDirtyWithModifiers(elm, checkVal)
  48719. ))
  48720. }
  48721. function isNotInFocusAndDirty (elm, checkVal) {
  48722. // return true when textbox (.number and .trim) loses focus and its value is
  48723. // not equal to the updated value
  48724. var notInFocus = true;
  48725. // #6157
  48726. // work around IE bug when accessing document.activeElement in an iframe
  48727. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48728. return notInFocus && elm.value !== checkVal
  48729. }
  48730. function isDirtyWithModifiers (elm, newVal) {
  48731. var value = elm.value;
  48732. var modifiers = elm._vModifiers; // injected by v-model runtime
  48733. if (isDef(modifiers)) {
  48734. if (modifiers.number) {
  48735. return toNumber(value) !== toNumber(newVal)
  48736. }
  48737. if (modifiers.trim) {
  48738. return value.trim() !== newVal.trim()
  48739. }
  48740. }
  48741. return value !== newVal
  48742. }
  48743. var domProps = {
  48744. create: updateDOMProps,
  48745. update: updateDOMProps
  48746. };
  48747. /* */
  48748. var parseStyleText = cached(function (cssText) {
  48749. var res = {};
  48750. var listDelimiter = /;(?![^(]*\))/g;
  48751. var propertyDelimiter = /:(.+)/;
  48752. cssText.split(listDelimiter).forEach(function (item) {
  48753. if (item) {
  48754. var tmp = item.split(propertyDelimiter);
  48755. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48756. }
  48757. });
  48758. return res
  48759. });
  48760. // merge static and dynamic style data on the same vnode
  48761. function normalizeStyleData (data) {
  48762. var style = normalizeStyleBinding(data.style);
  48763. // static style is pre-processed into an object during compilation
  48764. // and is always a fresh object, so it's safe to merge into it
  48765. return data.staticStyle
  48766. ? extend(data.staticStyle, style)
  48767. : style
  48768. }
  48769. // normalize possible array / string values into Object
  48770. function normalizeStyleBinding (bindingStyle) {
  48771. if (Array.isArray(bindingStyle)) {
  48772. return toObject(bindingStyle)
  48773. }
  48774. if (typeof bindingStyle === 'string') {
  48775. return parseStyleText(bindingStyle)
  48776. }
  48777. return bindingStyle
  48778. }
  48779. /**
  48780. * parent component style should be after child's
  48781. * so that parent component's style could override it
  48782. */
  48783. function getStyle (vnode, checkChild) {
  48784. var res = {};
  48785. var styleData;
  48786. if (checkChild) {
  48787. var childNode = vnode;
  48788. while (childNode.componentInstance) {
  48789. childNode = childNode.componentInstance._vnode;
  48790. if (
  48791. childNode && childNode.data &&
  48792. (styleData = normalizeStyleData(childNode.data))
  48793. ) {
  48794. extend(res, styleData);
  48795. }
  48796. }
  48797. }
  48798. if ((styleData = normalizeStyleData(vnode.data))) {
  48799. extend(res, styleData);
  48800. }
  48801. var parentNode = vnode;
  48802. while ((parentNode = parentNode.parent)) {
  48803. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48804. extend(res, styleData);
  48805. }
  48806. }
  48807. return res
  48808. }
  48809. /* */
  48810. var cssVarRE = /^--/;
  48811. var importantRE = /\s*!important$/;
  48812. var setProp = function (el, name, val) {
  48813. /* istanbul ignore if */
  48814. if (cssVarRE.test(name)) {
  48815. el.style.setProperty(name, val);
  48816. } else if (importantRE.test(val)) {
  48817. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48818. } else {
  48819. var normalizedName = normalize(name);
  48820. if (Array.isArray(val)) {
  48821. // Support values array created by autoprefixer, e.g.
  48822. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48823. // Set them one by one, and the browser will only set those it can recognize
  48824. for (var i = 0, len = val.length; i < len; i++) {
  48825. el.style[normalizedName] = val[i];
  48826. }
  48827. } else {
  48828. el.style[normalizedName] = val;
  48829. }
  48830. }
  48831. };
  48832. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48833. var emptyStyle;
  48834. var normalize = cached(function (prop) {
  48835. emptyStyle = emptyStyle || document.createElement('div').style;
  48836. prop = camelize(prop);
  48837. if (prop !== 'filter' && (prop in emptyStyle)) {
  48838. return prop
  48839. }
  48840. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48841. for (var i = 0; i < vendorNames.length; i++) {
  48842. var name = vendorNames[i] + capName;
  48843. if (name in emptyStyle) {
  48844. return name
  48845. }
  48846. }
  48847. });
  48848. function updateStyle (oldVnode, vnode) {
  48849. var data = vnode.data;
  48850. var oldData = oldVnode.data;
  48851. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48852. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48853. ) {
  48854. return
  48855. }
  48856. var cur, name;
  48857. var el = vnode.elm;
  48858. var oldStaticStyle = oldData.staticStyle;
  48859. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  48860. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  48861. var oldStyle = oldStaticStyle || oldStyleBinding;
  48862. var style = normalizeStyleBinding(vnode.data.style) || {};
  48863. // store normalized style under a different key for next diff
  48864. // make sure to clone it if it's reactive, since the user likely wants
  48865. // to mutate it.
  48866. vnode.data.normalizedStyle = isDef(style.__ob__)
  48867. ? extend({}, style)
  48868. : style;
  48869. var newStyle = getStyle(vnode, true);
  48870. for (name in oldStyle) {
  48871. if (isUndef(newStyle[name])) {
  48872. setProp(el, name, '');
  48873. }
  48874. }
  48875. for (name in newStyle) {
  48876. cur = newStyle[name];
  48877. if (cur !== oldStyle[name]) {
  48878. // ie9 setting to null has no effect, must use empty string
  48879. setProp(el, name, cur == null ? '' : cur);
  48880. }
  48881. }
  48882. }
  48883. var style = {
  48884. create: updateStyle,
  48885. update: updateStyle
  48886. };
  48887. /* */
  48888. var whitespaceRE = /\s+/;
  48889. /**
  48890. * Add class with compatibility for SVG since classList is not supported on
  48891. * SVG elements in IE
  48892. */
  48893. function addClass (el, cls) {
  48894. /* istanbul ignore if */
  48895. if (!cls || !(cls = cls.trim())) {
  48896. return
  48897. }
  48898. /* istanbul ignore else */
  48899. if (el.classList) {
  48900. if (cls.indexOf(' ') > -1) {
  48901. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  48902. } else {
  48903. el.classList.add(cls);
  48904. }
  48905. } else {
  48906. var cur = " " + (el.getAttribute('class') || '') + " ";
  48907. if (cur.indexOf(' ' + cls + ' ') < 0) {
  48908. el.setAttribute('class', (cur + cls).trim());
  48909. }
  48910. }
  48911. }
  48912. /**
  48913. * Remove class with compatibility for SVG since classList is not supported on
  48914. * SVG elements in IE
  48915. */
  48916. function removeClass (el, cls) {
  48917. /* istanbul ignore if */
  48918. if (!cls || !(cls = cls.trim())) {
  48919. return
  48920. }
  48921. /* istanbul ignore else */
  48922. if (el.classList) {
  48923. if (cls.indexOf(' ') > -1) {
  48924. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  48925. } else {
  48926. el.classList.remove(cls);
  48927. }
  48928. if (!el.classList.length) {
  48929. el.removeAttribute('class');
  48930. }
  48931. } else {
  48932. var cur = " " + (el.getAttribute('class') || '') + " ";
  48933. var tar = ' ' + cls + ' ';
  48934. while (cur.indexOf(tar) >= 0) {
  48935. cur = cur.replace(tar, ' ');
  48936. }
  48937. cur = cur.trim();
  48938. if (cur) {
  48939. el.setAttribute('class', cur);
  48940. } else {
  48941. el.removeAttribute('class');
  48942. }
  48943. }
  48944. }
  48945. /* */
  48946. function resolveTransition (def$$1) {
  48947. if (!def$$1) {
  48948. return
  48949. }
  48950. /* istanbul ignore else */
  48951. if (typeof def$$1 === 'object') {
  48952. var res = {};
  48953. if (def$$1.css !== false) {
  48954. extend(res, autoCssTransition(def$$1.name || 'v'));
  48955. }
  48956. extend(res, def$$1);
  48957. return res
  48958. } else if (typeof def$$1 === 'string') {
  48959. return autoCssTransition(def$$1)
  48960. }
  48961. }
  48962. var autoCssTransition = cached(function (name) {
  48963. return {
  48964. enterClass: (name + "-enter"),
  48965. enterToClass: (name + "-enter-to"),
  48966. enterActiveClass: (name + "-enter-active"),
  48967. leaveClass: (name + "-leave"),
  48968. leaveToClass: (name + "-leave-to"),
  48969. leaveActiveClass: (name + "-leave-active")
  48970. }
  48971. });
  48972. var hasTransition = inBrowser && !isIE9;
  48973. var TRANSITION = 'transition';
  48974. var ANIMATION = 'animation';
  48975. // Transition property/event sniffing
  48976. var transitionProp = 'transition';
  48977. var transitionEndEvent = 'transitionend';
  48978. var animationProp = 'animation';
  48979. var animationEndEvent = 'animationend';
  48980. if (hasTransition) {
  48981. /* istanbul ignore if */
  48982. if (window.ontransitionend === undefined &&
  48983. window.onwebkittransitionend !== undefined
  48984. ) {
  48985. transitionProp = 'WebkitTransition';
  48986. transitionEndEvent = 'webkitTransitionEnd';
  48987. }
  48988. if (window.onanimationend === undefined &&
  48989. window.onwebkitanimationend !== undefined
  48990. ) {
  48991. animationProp = 'WebkitAnimation';
  48992. animationEndEvent = 'webkitAnimationEnd';
  48993. }
  48994. }
  48995. // binding to window is necessary to make hot reload work in IE in strict mode
  48996. var raf = inBrowser
  48997. ? window.requestAnimationFrame
  48998. ? window.requestAnimationFrame.bind(window)
  48999. : setTimeout
  49000. : /* istanbul ignore next */ function (fn) { return fn(); };
  49001. function nextFrame (fn) {
  49002. raf(function () {
  49003. raf(fn);
  49004. });
  49005. }
  49006. function addTransitionClass (el, cls) {
  49007. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  49008. if (transitionClasses.indexOf(cls) < 0) {
  49009. transitionClasses.push(cls);
  49010. addClass(el, cls);
  49011. }
  49012. }
  49013. function removeTransitionClass (el, cls) {
  49014. if (el._transitionClasses) {
  49015. remove(el._transitionClasses, cls);
  49016. }
  49017. removeClass(el, cls);
  49018. }
  49019. function whenTransitionEnds (
  49020. el,
  49021. expectedType,
  49022. cb
  49023. ) {
  49024. var ref = getTransitionInfo(el, expectedType);
  49025. var type = ref.type;
  49026. var timeout = ref.timeout;
  49027. var propCount = ref.propCount;
  49028. if (!type) { return cb() }
  49029. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  49030. var ended = 0;
  49031. var end = function () {
  49032. el.removeEventListener(event, onEnd);
  49033. cb();
  49034. };
  49035. var onEnd = function (e) {
  49036. if (e.target === el) {
  49037. if (++ended >= propCount) {
  49038. end();
  49039. }
  49040. }
  49041. };
  49042. setTimeout(function () {
  49043. if (ended < propCount) {
  49044. end();
  49045. }
  49046. }, timeout + 1);
  49047. el.addEventListener(event, onEnd);
  49048. }
  49049. var transformRE = /\b(transform|all)(,|$)/;
  49050. function getTransitionInfo (el, expectedType) {
  49051. var styles = window.getComputedStyle(el);
  49052. // JSDOM may return undefined for transition properties
  49053. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  49054. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  49055. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  49056. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  49057. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  49058. var animationTimeout = getTimeout(animationDelays, animationDurations);
  49059. var type;
  49060. var timeout = 0;
  49061. var propCount = 0;
  49062. /* istanbul ignore if */
  49063. if (expectedType === TRANSITION) {
  49064. if (transitionTimeout > 0) {
  49065. type = TRANSITION;
  49066. timeout = transitionTimeout;
  49067. propCount = transitionDurations.length;
  49068. }
  49069. } else if (expectedType === ANIMATION) {
  49070. if (animationTimeout > 0) {
  49071. type = ANIMATION;
  49072. timeout = animationTimeout;
  49073. propCount = animationDurations.length;
  49074. }
  49075. } else {
  49076. timeout = Math.max(transitionTimeout, animationTimeout);
  49077. type = timeout > 0
  49078. ? transitionTimeout > animationTimeout
  49079. ? TRANSITION
  49080. : ANIMATION
  49081. : null;
  49082. propCount = type
  49083. ? type === TRANSITION
  49084. ? transitionDurations.length
  49085. : animationDurations.length
  49086. : 0;
  49087. }
  49088. var hasTransform =
  49089. type === TRANSITION &&
  49090. transformRE.test(styles[transitionProp + 'Property']);
  49091. return {
  49092. type: type,
  49093. timeout: timeout,
  49094. propCount: propCount,
  49095. hasTransform: hasTransform
  49096. }
  49097. }
  49098. function getTimeout (delays, durations) {
  49099. /* istanbul ignore next */
  49100. while (delays.length < durations.length) {
  49101. delays = delays.concat(delays);
  49102. }
  49103. return Math.max.apply(null, durations.map(function (d, i) {
  49104. return toMs(d) + toMs(delays[i])
  49105. }))
  49106. }
  49107. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49108. // in a locale-dependent way, using a comma instead of a dot.
  49109. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49110. // as a floor function) causing unexpected behaviors
  49111. function toMs (s) {
  49112. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49113. }
  49114. /* */
  49115. function enter (vnode, toggleDisplay) {
  49116. var el = vnode.elm;
  49117. // call leave callback now
  49118. if (isDef(el._leaveCb)) {
  49119. el._leaveCb.cancelled = true;
  49120. el._leaveCb();
  49121. }
  49122. var data = resolveTransition(vnode.data.transition);
  49123. if (isUndef(data)) {
  49124. return
  49125. }
  49126. /* istanbul ignore if */
  49127. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49128. return
  49129. }
  49130. var css = data.css;
  49131. var type = data.type;
  49132. var enterClass = data.enterClass;
  49133. var enterToClass = data.enterToClass;
  49134. var enterActiveClass = data.enterActiveClass;
  49135. var appearClass = data.appearClass;
  49136. var appearToClass = data.appearToClass;
  49137. var appearActiveClass = data.appearActiveClass;
  49138. var beforeEnter = data.beforeEnter;
  49139. var enter = data.enter;
  49140. var afterEnter = data.afterEnter;
  49141. var enterCancelled = data.enterCancelled;
  49142. var beforeAppear = data.beforeAppear;
  49143. var appear = data.appear;
  49144. var afterAppear = data.afterAppear;
  49145. var appearCancelled = data.appearCancelled;
  49146. var duration = data.duration;
  49147. // activeInstance will always be the <transition> component managing this
  49148. // transition. One edge case to check is when the <transition> is placed
  49149. // as the root node of a child component. In that case we need to check
  49150. // <transition>'s parent for appear check.
  49151. var context = activeInstance;
  49152. var transitionNode = activeInstance.$vnode;
  49153. while (transitionNode && transitionNode.parent) {
  49154. context = transitionNode.context;
  49155. transitionNode = transitionNode.parent;
  49156. }
  49157. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49158. if (isAppear && !appear && appear !== '') {
  49159. return
  49160. }
  49161. var startClass = isAppear && appearClass
  49162. ? appearClass
  49163. : enterClass;
  49164. var activeClass = isAppear && appearActiveClass
  49165. ? appearActiveClass
  49166. : enterActiveClass;
  49167. var toClass = isAppear && appearToClass
  49168. ? appearToClass
  49169. : enterToClass;
  49170. var beforeEnterHook = isAppear
  49171. ? (beforeAppear || beforeEnter)
  49172. : beforeEnter;
  49173. var enterHook = isAppear
  49174. ? (typeof appear === 'function' ? appear : enter)
  49175. : enter;
  49176. var afterEnterHook = isAppear
  49177. ? (afterAppear || afterEnter)
  49178. : afterEnter;
  49179. var enterCancelledHook = isAppear
  49180. ? (appearCancelled || enterCancelled)
  49181. : enterCancelled;
  49182. var explicitEnterDuration = toNumber(
  49183. isObject(duration)
  49184. ? duration.enter
  49185. : duration
  49186. );
  49187. if (explicitEnterDuration != null) {
  49188. checkDuration(explicitEnterDuration, 'enter', vnode);
  49189. }
  49190. var expectsCSS = css !== false && !isIE9;
  49191. var userWantsControl = getHookArgumentsLength(enterHook);
  49192. var cb = el._enterCb = once(function () {
  49193. if (expectsCSS) {
  49194. removeTransitionClass(el, toClass);
  49195. removeTransitionClass(el, activeClass);
  49196. }
  49197. if (cb.cancelled) {
  49198. if (expectsCSS) {
  49199. removeTransitionClass(el, startClass);
  49200. }
  49201. enterCancelledHook && enterCancelledHook(el);
  49202. } else {
  49203. afterEnterHook && afterEnterHook(el);
  49204. }
  49205. el._enterCb = null;
  49206. });
  49207. if (!vnode.data.show) {
  49208. // remove pending leave element on enter by injecting an insert hook
  49209. mergeVNodeHook(vnode, 'insert', function () {
  49210. var parent = el.parentNode;
  49211. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49212. if (pendingNode &&
  49213. pendingNode.tag === vnode.tag &&
  49214. pendingNode.elm._leaveCb
  49215. ) {
  49216. pendingNode.elm._leaveCb();
  49217. }
  49218. enterHook && enterHook(el, cb);
  49219. });
  49220. }
  49221. // start enter transition
  49222. beforeEnterHook && beforeEnterHook(el);
  49223. if (expectsCSS) {
  49224. addTransitionClass(el, startClass);
  49225. addTransitionClass(el, activeClass);
  49226. nextFrame(function () {
  49227. removeTransitionClass(el, startClass);
  49228. if (!cb.cancelled) {
  49229. addTransitionClass(el, toClass);
  49230. if (!userWantsControl) {
  49231. if (isValidDuration(explicitEnterDuration)) {
  49232. setTimeout(cb, explicitEnterDuration);
  49233. } else {
  49234. whenTransitionEnds(el, type, cb);
  49235. }
  49236. }
  49237. }
  49238. });
  49239. }
  49240. if (vnode.data.show) {
  49241. toggleDisplay && toggleDisplay();
  49242. enterHook && enterHook(el, cb);
  49243. }
  49244. if (!expectsCSS && !userWantsControl) {
  49245. cb();
  49246. }
  49247. }
  49248. function leave (vnode, rm) {
  49249. var el = vnode.elm;
  49250. // call enter callback now
  49251. if (isDef(el._enterCb)) {
  49252. el._enterCb.cancelled = true;
  49253. el._enterCb();
  49254. }
  49255. var data = resolveTransition(vnode.data.transition);
  49256. if (isUndef(data) || el.nodeType !== 1) {
  49257. return rm()
  49258. }
  49259. /* istanbul ignore if */
  49260. if (isDef(el._leaveCb)) {
  49261. return
  49262. }
  49263. var css = data.css;
  49264. var type = data.type;
  49265. var leaveClass = data.leaveClass;
  49266. var leaveToClass = data.leaveToClass;
  49267. var leaveActiveClass = data.leaveActiveClass;
  49268. var beforeLeave = data.beforeLeave;
  49269. var leave = data.leave;
  49270. var afterLeave = data.afterLeave;
  49271. var leaveCancelled = data.leaveCancelled;
  49272. var delayLeave = data.delayLeave;
  49273. var duration = data.duration;
  49274. var expectsCSS = css !== false && !isIE9;
  49275. var userWantsControl = getHookArgumentsLength(leave);
  49276. var explicitLeaveDuration = toNumber(
  49277. isObject(duration)
  49278. ? duration.leave
  49279. : duration
  49280. );
  49281. if (isDef(explicitLeaveDuration)) {
  49282. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49283. }
  49284. var cb = el._leaveCb = once(function () {
  49285. if (el.parentNode && el.parentNode._pending) {
  49286. el.parentNode._pending[vnode.key] = null;
  49287. }
  49288. if (expectsCSS) {
  49289. removeTransitionClass(el, leaveToClass);
  49290. removeTransitionClass(el, leaveActiveClass);
  49291. }
  49292. if (cb.cancelled) {
  49293. if (expectsCSS) {
  49294. removeTransitionClass(el, leaveClass);
  49295. }
  49296. leaveCancelled && leaveCancelled(el);
  49297. } else {
  49298. rm();
  49299. afterLeave && afterLeave(el);
  49300. }
  49301. el._leaveCb = null;
  49302. });
  49303. if (delayLeave) {
  49304. delayLeave(performLeave);
  49305. } else {
  49306. performLeave();
  49307. }
  49308. function performLeave () {
  49309. // the delayed leave may have already been cancelled
  49310. if (cb.cancelled) {
  49311. return
  49312. }
  49313. // record leaving element
  49314. if (!vnode.data.show && el.parentNode) {
  49315. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49316. }
  49317. beforeLeave && beforeLeave(el);
  49318. if (expectsCSS) {
  49319. addTransitionClass(el, leaveClass);
  49320. addTransitionClass(el, leaveActiveClass);
  49321. nextFrame(function () {
  49322. removeTransitionClass(el, leaveClass);
  49323. if (!cb.cancelled) {
  49324. addTransitionClass(el, leaveToClass);
  49325. if (!userWantsControl) {
  49326. if (isValidDuration(explicitLeaveDuration)) {
  49327. setTimeout(cb, explicitLeaveDuration);
  49328. } else {
  49329. whenTransitionEnds(el, type, cb);
  49330. }
  49331. }
  49332. }
  49333. });
  49334. }
  49335. leave && leave(el, cb);
  49336. if (!expectsCSS && !userWantsControl) {
  49337. cb();
  49338. }
  49339. }
  49340. }
  49341. // only used in dev mode
  49342. function checkDuration (val, name, vnode) {
  49343. if (typeof val !== 'number') {
  49344. warn(
  49345. "<transition> explicit " + name + " duration is not a valid number - " +
  49346. "got " + (JSON.stringify(val)) + ".",
  49347. vnode.context
  49348. );
  49349. } else if (isNaN(val)) {
  49350. warn(
  49351. "<transition> explicit " + name + " duration is NaN - " +
  49352. 'the duration expression might be incorrect.',
  49353. vnode.context
  49354. );
  49355. }
  49356. }
  49357. function isValidDuration (val) {
  49358. return typeof val === 'number' && !isNaN(val)
  49359. }
  49360. /**
  49361. * Normalize a transition hook's argument length. The hook may be:
  49362. * - a merged hook (invoker) with the original in .fns
  49363. * - a wrapped component method (check ._length)
  49364. * - a plain function (.length)
  49365. */
  49366. function getHookArgumentsLength (fn) {
  49367. if (isUndef(fn)) {
  49368. return false
  49369. }
  49370. var invokerFns = fn.fns;
  49371. if (isDef(invokerFns)) {
  49372. // invoker
  49373. return getHookArgumentsLength(
  49374. Array.isArray(invokerFns)
  49375. ? invokerFns[0]
  49376. : invokerFns
  49377. )
  49378. } else {
  49379. return (fn._length || fn.length) > 1
  49380. }
  49381. }
  49382. function _enter (_, vnode) {
  49383. if (vnode.data.show !== true) {
  49384. enter(vnode);
  49385. }
  49386. }
  49387. var transition = inBrowser ? {
  49388. create: _enter,
  49389. activate: _enter,
  49390. remove: function remove$$1 (vnode, rm) {
  49391. /* istanbul ignore else */
  49392. if (vnode.data.show !== true) {
  49393. leave(vnode, rm);
  49394. } else {
  49395. rm();
  49396. }
  49397. }
  49398. } : {};
  49399. var platformModules = [
  49400. attrs,
  49401. klass,
  49402. events,
  49403. domProps,
  49404. style,
  49405. transition
  49406. ];
  49407. /* */
  49408. // the directive module should be applied last, after all
  49409. // built-in modules have been applied.
  49410. var modules = platformModules.concat(baseModules);
  49411. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49412. /**
  49413. * Not type checking this file because flow doesn't like attaching
  49414. * properties to Elements.
  49415. */
  49416. /* istanbul ignore if */
  49417. if (isIE9) {
  49418. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49419. document.addEventListener('selectionchange', function () {
  49420. var el = document.activeElement;
  49421. if (el && el.vmodel) {
  49422. trigger(el, 'input');
  49423. }
  49424. });
  49425. }
  49426. var directive = {
  49427. inserted: function inserted (el, binding, vnode, oldVnode) {
  49428. if (vnode.tag === 'select') {
  49429. // #6903
  49430. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49431. mergeVNodeHook(vnode, 'postpatch', function () {
  49432. directive.componentUpdated(el, binding, vnode);
  49433. });
  49434. } else {
  49435. setSelected(el, binding, vnode.context);
  49436. }
  49437. el._vOptions = [].map.call(el.options, getValue);
  49438. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49439. el._vModifiers = binding.modifiers;
  49440. if (!binding.modifiers.lazy) {
  49441. el.addEventListener('compositionstart', onCompositionStart);
  49442. el.addEventListener('compositionend', onCompositionEnd);
  49443. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49444. // switching focus before confirming composition choice
  49445. // this also fixes the issue where some browsers e.g. iOS Chrome
  49446. // fires "change" instead of "input" on autocomplete.
  49447. el.addEventListener('change', onCompositionEnd);
  49448. /* istanbul ignore if */
  49449. if (isIE9) {
  49450. el.vmodel = true;
  49451. }
  49452. }
  49453. }
  49454. },
  49455. componentUpdated: function componentUpdated (el, binding, vnode) {
  49456. if (vnode.tag === 'select') {
  49457. setSelected(el, binding, vnode.context);
  49458. // in case the options rendered by v-for have changed,
  49459. // it's possible that the value is out-of-sync with the rendered options.
  49460. // detect such cases and filter out values that no longer has a matching
  49461. // option in the DOM.
  49462. var prevOptions = el._vOptions;
  49463. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49464. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49465. // trigger change event if
  49466. // no matching option found for at least one value
  49467. var needReset = el.multiple
  49468. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49469. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49470. if (needReset) {
  49471. trigger(el, 'change');
  49472. }
  49473. }
  49474. }
  49475. }
  49476. };
  49477. function setSelected (el, binding, vm) {
  49478. actuallySetSelected(el, binding, vm);
  49479. /* istanbul ignore if */
  49480. if (isIE || isEdge) {
  49481. setTimeout(function () {
  49482. actuallySetSelected(el, binding, vm);
  49483. }, 0);
  49484. }
  49485. }
  49486. function actuallySetSelected (el, binding, vm) {
  49487. var value = binding.value;
  49488. var isMultiple = el.multiple;
  49489. if (isMultiple && !Array.isArray(value)) {
  49490. warn(
  49491. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49492. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49493. vm
  49494. );
  49495. return
  49496. }
  49497. var selected, option;
  49498. for (var i = 0, l = el.options.length; i < l; i++) {
  49499. option = el.options[i];
  49500. if (isMultiple) {
  49501. selected = looseIndexOf(value, getValue(option)) > -1;
  49502. if (option.selected !== selected) {
  49503. option.selected = selected;
  49504. }
  49505. } else {
  49506. if (looseEqual(getValue(option), value)) {
  49507. if (el.selectedIndex !== i) {
  49508. el.selectedIndex = i;
  49509. }
  49510. return
  49511. }
  49512. }
  49513. }
  49514. if (!isMultiple) {
  49515. el.selectedIndex = -1;
  49516. }
  49517. }
  49518. function hasNoMatchingOption (value, options) {
  49519. return options.every(function (o) { return !looseEqual(o, value); })
  49520. }
  49521. function getValue (option) {
  49522. return '_value' in option
  49523. ? option._value
  49524. : option.value
  49525. }
  49526. function onCompositionStart (e) {
  49527. e.target.composing = true;
  49528. }
  49529. function onCompositionEnd (e) {
  49530. // prevent triggering an input event for no reason
  49531. if (!e.target.composing) { return }
  49532. e.target.composing = false;
  49533. trigger(e.target, 'input');
  49534. }
  49535. function trigger (el, type) {
  49536. var e = document.createEvent('HTMLEvents');
  49537. e.initEvent(type, true, true);
  49538. el.dispatchEvent(e);
  49539. }
  49540. /* */
  49541. // recursively search for possible transition defined inside the component root
  49542. function locateNode (vnode) {
  49543. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49544. ? locateNode(vnode.componentInstance._vnode)
  49545. : vnode
  49546. }
  49547. var show = {
  49548. bind: function bind (el, ref, vnode) {
  49549. var value = ref.value;
  49550. vnode = locateNode(vnode);
  49551. var transition$$1 = vnode.data && vnode.data.transition;
  49552. var originalDisplay = el.__vOriginalDisplay =
  49553. el.style.display === 'none' ? '' : el.style.display;
  49554. if (value && transition$$1) {
  49555. vnode.data.show = true;
  49556. enter(vnode, function () {
  49557. el.style.display = originalDisplay;
  49558. });
  49559. } else {
  49560. el.style.display = value ? originalDisplay : 'none';
  49561. }
  49562. },
  49563. update: function update (el, ref, vnode) {
  49564. var value = ref.value;
  49565. var oldValue = ref.oldValue;
  49566. /* istanbul ignore if */
  49567. if (!value === !oldValue) { return }
  49568. vnode = locateNode(vnode);
  49569. var transition$$1 = vnode.data && vnode.data.transition;
  49570. if (transition$$1) {
  49571. vnode.data.show = true;
  49572. if (value) {
  49573. enter(vnode, function () {
  49574. el.style.display = el.__vOriginalDisplay;
  49575. });
  49576. } else {
  49577. leave(vnode, function () {
  49578. el.style.display = 'none';
  49579. });
  49580. }
  49581. } else {
  49582. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49583. }
  49584. },
  49585. unbind: function unbind (
  49586. el,
  49587. binding,
  49588. vnode,
  49589. oldVnode,
  49590. isDestroy
  49591. ) {
  49592. if (!isDestroy) {
  49593. el.style.display = el.__vOriginalDisplay;
  49594. }
  49595. }
  49596. };
  49597. var platformDirectives = {
  49598. model: directive,
  49599. show: show
  49600. };
  49601. /* */
  49602. var transitionProps = {
  49603. name: String,
  49604. appear: Boolean,
  49605. css: Boolean,
  49606. mode: String,
  49607. type: String,
  49608. enterClass: String,
  49609. leaveClass: String,
  49610. enterToClass: String,
  49611. leaveToClass: String,
  49612. enterActiveClass: String,
  49613. leaveActiveClass: String,
  49614. appearClass: String,
  49615. appearActiveClass: String,
  49616. appearToClass: String,
  49617. duration: [Number, String, Object]
  49618. };
  49619. // in case the child is also an abstract component, e.g. <keep-alive>
  49620. // we want to recursively retrieve the real component to be rendered
  49621. function getRealChild (vnode) {
  49622. var compOptions = vnode && vnode.componentOptions;
  49623. if (compOptions && compOptions.Ctor.options.abstract) {
  49624. return getRealChild(getFirstComponentChild(compOptions.children))
  49625. } else {
  49626. return vnode
  49627. }
  49628. }
  49629. function extractTransitionData (comp) {
  49630. var data = {};
  49631. var options = comp.$options;
  49632. // props
  49633. for (var key in options.propsData) {
  49634. data[key] = comp[key];
  49635. }
  49636. // events.
  49637. // extract listeners and pass them directly to the transition methods
  49638. var listeners = options._parentListeners;
  49639. for (var key$1 in listeners) {
  49640. data[camelize(key$1)] = listeners[key$1];
  49641. }
  49642. return data
  49643. }
  49644. function placeholder (h, rawChild) {
  49645. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49646. return h('keep-alive', {
  49647. props: rawChild.componentOptions.propsData
  49648. })
  49649. }
  49650. }
  49651. function hasParentTransition (vnode) {
  49652. while ((vnode = vnode.parent)) {
  49653. if (vnode.data.transition) {
  49654. return true
  49655. }
  49656. }
  49657. }
  49658. function isSameChild (child, oldChild) {
  49659. return oldChild.key === child.key && oldChild.tag === child.tag
  49660. }
  49661. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49662. var isVShowDirective = function (d) { return d.name === 'show'; };
  49663. var Transition = {
  49664. name: 'transition',
  49665. props: transitionProps,
  49666. abstract: true,
  49667. render: function render (h) {
  49668. var this$1 = this;
  49669. var children = this.$slots.default;
  49670. if (!children) {
  49671. return
  49672. }
  49673. // filter out text nodes (possible whitespaces)
  49674. children = children.filter(isNotTextNode);
  49675. /* istanbul ignore if */
  49676. if (!children.length) {
  49677. return
  49678. }
  49679. // warn multiple elements
  49680. if (children.length > 1) {
  49681. warn(
  49682. '<transition> can only be used on a single element. Use ' +
  49683. '<transition-group> for lists.',
  49684. this.$parent
  49685. );
  49686. }
  49687. var mode = this.mode;
  49688. // warn invalid mode
  49689. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49690. ) {
  49691. warn(
  49692. 'invalid <transition> mode: ' + mode,
  49693. this.$parent
  49694. );
  49695. }
  49696. var rawChild = children[0];
  49697. // if this is a component root node and the component's
  49698. // parent container node also has transition, skip.
  49699. if (hasParentTransition(this.$vnode)) {
  49700. return rawChild
  49701. }
  49702. // apply transition data to child
  49703. // use getRealChild() to ignore abstract components e.g. keep-alive
  49704. var child = getRealChild(rawChild);
  49705. /* istanbul ignore if */
  49706. if (!child) {
  49707. return rawChild
  49708. }
  49709. if (this._leaving) {
  49710. return placeholder(h, rawChild)
  49711. }
  49712. // ensure a key that is unique to the vnode type and to this transition
  49713. // component instance. This key will be used to remove pending leaving nodes
  49714. // during entering.
  49715. var id = "__transition-" + (this._uid) + "-";
  49716. child.key = child.key == null
  49717. ? child.isComment
  49718. ? id + 'comment'
  49719. : id + child.tag
  49720. : isPrimitive(child.key)
  49721. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49722. : child.key;
  49723. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49724. var oldRawChild = this._vnode;
  49725. var oldChild = getRealChild(oldRawChild);
  49726. // mark v-show
  49727. // so that the transition module can hand over the control to the directive
  49728. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49729. child.data.show = true;
  49730. }
  49731. if (
  49732. oldChild &&
  49733. oldChild.data &&
  49734. !isSameChild(child, oldChild) &&
  49735. !isAsyncPlaceholder(oldChild) &&
  49736. // #6687 component root is a comment node
  49737. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49738. ) {
  49739. // replace old child transition data with fresh one
  49740. // important for dynamic transitions!
  49741. var oldData = oldChild.data.transition = extend({}, data);
  49742. // handle transition mode
  49743. if (mode === 'out-in') {
  49744. // return placeholder node and queue update when leave finishes
  49745. this._leaving = true;
  49746. mergeVNodeHook(oldData, 'afterLeave', function () {
  49747. this$1._leaving = false;
  49748. this$1.$forceUpdate();
  49749. });
  49750. return placeholder(h, rawChild)
  49751. } else if (mode === 'in-out') {
  49752. if (isAsyncPlaceholder(child)) {
  49753. return oldRawChild
  49754. }
  49755. var delayedLeave;
  49756. var performLeave = function () { delayedLeave(); };
  49757. mergeVNodeHook(data, 'afterEnter', performLeave);
  49758. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49759. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49760. }
  49761. }
  49762. return rawChild
  49763. }
  49764. };
  49765. /* */
  49766. var props = extend({
  49767. tag: String,
  49768. moveClass: String
  49769. }, transitionProps);
  49770. delete props.mode;
  49771. var TransitionGroup = {
  49772. props: props,
  49773. beforeMount: function beforeMount () {
  49774. var this$1 = this;
  49775. var update = this._update;
  49776. this._update = function (vnode, hydrating) {
  49777. var restoreActiveInstance = setActiveInstance(this$1);
  49778. // force removing pass
  49779. this$1.__patch__(
  49780. this$1._vnode,
  49781. this$1.kept,
  49782. false, // hydrating
  49783. true // removeOnly (!important, avoids unnecessary moves)
  49784. );
  49785. this$1._vnode = this$1.kept;
  49786. restoreActiveInstance();
  49787. update.call(this$1, vnode, hydrating);
  49788. };
  49789. },
  49790. render: function render (h) {
  49791. var tag = this.tag || this.$vnode.data.tag || 'span';
  49792. var map = Object.create(null);
  49793. var prevChildren = this.prevChildren = this.children;
  49794. var rawChildren = this.$slots.default || [];
  49795. var children = this.children = [];
  49796. var transitionData = extractTransitionData(this);
  49797. for (var i = 0; i < rawChildren.length; i++) {
  49798. var c = rawChildren[i];
  49799. if (c.tag) {
  49800. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49801. children.push(c);
  49802. map[c.key] = c
  49803. ;(c.data || (c.data = {})).transition = transitionData;
  49804. } else {
  49805. var opts = c.componentOptions;
  49806. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49807. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49808. }
  49809. }
  49810. }
  49811. if (prevChildren) {
  49812. var kept = [];
  49813. var removed = [];
  49814. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49815. var c$1 = prevChildren[i$1];
  49816. c$1.data.transition = transitionData;
  49817. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49818. if (map[c$1.key]) {
  49819. kept.push(c$1);
  49820. } else {
  49821. removed.push(c$1);
  49822. }
  49823. }
  49824. this.kept = h(tag, null, kept);
  49825. this.removed = removed;
  49826. }
  49827. return h(tag, null, children)
  49828. },
  49829. updated: function updated () {
  49830. var children = this.prevChildren;
  49831. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49832. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49833. return
  49834. }
  49835. // we divide the work into three loops to avoid mixing DOM reads and writes
  49836. // in each iteration - which helps prevent layout thrashing.
  49837. children.forEach(callPendingCbs);
  49838. children.forEach(recordPosition);
  49839. children.forEach(applyTranslation);
  49840. // force reflow to put everything in position
  49841. // assign to this to avoid being removed in tree-shaking
  49842. // $flow-disable-line
  49843. this._reflow = document.body.offsetHeight;
  49844. children.forEach(function (c) {
  49845. if (c.data.moved) {
  49846. var el = c.elm;
  49847. var s = el.style;
  49848. addTransitionClass(el, moveClass);
  49849. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49850. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49851. if (e && e.target !== el) {
  49852. return
  49853. }
  49854. if (!e || /transform$/.test(e.propertyName)) {
  49855. el.removeEventListener(transitionEndEvent, cb);
  49856. el._moveCb = null;
  49857. removeTransitionClass(el, moveClass);
  49858. }
  49859. });
  49860. }
  49861. });
  49862. },
  49863. methods: {
  49864. hasMove: function hasMove (el, moveClass) {
  49865. /* istanbul ignore if */
  49866. if (!hasTransition) {
  49867. return false
  49868. }
  49869. /* istanbul ignore if */
  49870. if (this._hasMove) {
  49871. return this._hasMove
  49872. }
  49873. // Detect whether an element with the move class applied has
  49874. // CSS transitions. Since the element may be inside an entering
  49875. // transition at this very moment, we make a clone of it and remove
  49876. // all other transition classes applied to ensure only the move class
  49877. // is applied.
  49878. var clone = el.cloneNode();
  49879. if (el._transitionClasses) {
  49880. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  49881. }
  49882. addClass(clone, moveClass);
  49883. clone.style.display = 'none';
  49884. this.$el.appendChild(clone);
  49885. var info = getTransitionInfo(clone);
  49886. this.$el.removeChild(clone);
  49887. return (this._hasMove = info.hasTransform)
  49888. }
  49889. }
  49890. };
  49891. function callPendingCbs (c) {
  49892. /* istanbul ignore if */
  49893. if (c.elm._moveCb) {
  49894. c.elm._moveCb();
  49895. }
  49896. /* istanbul ignore if */
  49897. if (c.elm._enterCb) {
  49898. c.elm._enterCb();
  49899. }
  49900. }
  49901. function recordPosition (c) {
  49902. c.data.newPos = c.elm.getBoundingClientRect();
  49903. }
  49904. function applyTranslation (c) {
  49905. var oldPos = c.data.pos;
  49906. var newPos = c.data.newPos;
  49907. var dx = oldPos.left - newPos.left;
  49908. var dy = oldPos.top - newPos.top;
  49909. if (dx || dy) {
  49910. c.data.moved = true;
  49911. var s = c.elm.style;
  49912. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  49913. s.transitionDuration = '0s';
  49914. }
  49915. }
  49916. var platformComponents = {
  49917. Transition: Transition,
  49918. TransitionGroup: TransitionGroup
  49919. };
  49920. /* */
  49921. // install platform specific utils
  49922. Vue.config.mustUseProp = mustUseProp;
  49923. Vue.config.isReservedTag = isReservedTag;
  49924. Vue.config.isReservedAttr = isReservedAttr;
  49925. Vue.config.getTagNamespace = getTagNamespace;
  49926. Vue.config.isUnknownElement = isUnknownElement;
  49927. // install platform runtime directives & components
  49928. extend(Vue.options.directives, platformDirectives);
  49929. extend(Vue.options.components, platformComponents);
  49930. // install platform patch function
  49931. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  49932. // public mount method
  49933. Vue.prototype.$mount = function (
  49934. el,
  49935. hydrating
  49936. ) {
  49937. el = el && inBrowser ? query(el) : undefined;
  49938. return mountComponent(this, el, hydrating)
  49939. };
  49940. // devtools global hook
  49941. /* istanbul ignore next */
  49942. if (inBrowser) {
  49943. setTimeout(function () {
  49944. if (config.devtools) {
  49945. if (devtools) {
  49946. devtools.emit('init', Vue);
  49947. } else {
  49948. console[console.info ? 'info' : 'log'](
  49949. 'Download the Vue Devtools extension for a better development experience:\n' +
  49950. 'https://github.com/vuejs/vue-devtools'
  49951. );
  49952. }
  49953. }
  49954. if (config.productionTip !== false &&
  49955. typeof console !== 'undefined'
  49956. ) {
  49957. console[console.info ? 'info' : 'log'](
  49958. "You are running Vue in development mode.\n" +
  49959. "Make sure to turn on production mode when deploying for production.\n" +
  49960. "See more tips at https://vuejs.org/guide/deployment.html"
  49961. );
  49962. }
  49963. }, 0);
  49964. }
  49965. /* */
  49966. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  49967. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  49968. var buildRegex = cached(function (delimiters) {
  49969. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  49970. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  49971. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  49972. });
  49973. function parseText (
  49974. text,
  49975. delimiters
  49976. ) {
  49977. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  49978. if (!tagRE.test(text)) {
  49979. return
  49980. }
  49981. var tokens = [];
  49982. var rawTokens = [];
  49983. var lastIndex = tagRE.lastIndex = 0;
  49984. var match, index, tokenValue;
  49985. while ((match = tagRE.exec(text))) {
  49986. index = match.index;
  49987. // push text token
  49988. if (index > lastIndex) {
  49989. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  49990. tokens.push(JSON.stringify(tokenValue));
  49991. }
  49992. // tag token
  49993. var exp = parseFilters(match[1].trim());
  49994. tokens.push(("_s(" + exp + ")"));
  49995. rawTokens.push({ '@binding': exp });
  49996. lastIndex = index + match[0].length;
  49997. }
  49998. if (lastIndex < text.length) {
  49999. rawTokens.push(tokenValue = text.slice(lastIndex));
  50000. tokens.push(JSON.stringify(tokenValue));
  50001. }
  50002. return {
  50003. expression: tokens.join('+'),
  50004. tokens: rawTokens
  50005. }
  50006. }
  50007. /* */
  50008. function transformNode (el, options) {
  50009. var warn = options.warn || baseWarn;
  50010. var staticClass = getAndRemoveAttr(el, 'class');
  50011. if (staticClass) {
  50012. var res = parseText(staticClass, options.delimiters);
  50013. if (res) {
  50014. warn(
  50015. "class=\"" + staticClass + "\": " +
  50016. 'Interpolation inside attributes has been removed. ' +
  50017. 'Use v-bind or the colon shorthand instead. For example, ' +
  50018. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  50019. el.rawAttrsMap['class']
  50020. );
  50021. }
  50022. }
  50023. if (staticClass) {
  50024. el.staticClass = JSON.stringify(staticClass);
  50025. }
  50026. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  50027. if (classBinding) {
  50028. el.classBinding = classBinding;
  50029. }
  50030. }
  50031. function genData (el) {
  50032. var data = '';
  50033. if (el.staticClass) {
  50034. data += "staticClass:" + (el.staticClass) + ",";
  50035. }
  50036. if (el.classBinding) {
  50037. data += "class:" + (el.classBinding) + ",";
  50038. }
  50039. return data
  50040. }
  50041. var klass$1 = {
  50042. staticKeys: ['staticClass'],
  50043. transformNode: transformNode,
  50044. genData: genData
  50045. };
  50046. /* */
  50047. function transformNode$1 (el, options) {
  50048. var warn = options.warn || baseWarn;
  50049. var staticStyle = getAndRemoveAttr(el, 'style');
  50050. if (staticStyle) {
  50051. /* istanbul ignore if */
  50052. {
  50053. var res = parseText(staticStyle, options.delimiters);
  50054. if (res) {
  50055. warn(
  50056. "style=\"" + staticStyle + "\": " +
  50057. 'Interpolation inside attributes has been removed. ' +
  50058. 'Use v-bind or the colon shorthand instead. For example, ' +
  50059. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  50060. el.rawAttrsMap['style']
  50061. );
  50062. }
  50063. }
  50064. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  50065. }
  50066. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  50067. if (styleBinding) {
  50068. el.styleBinding = styleBinding;
  50069. }
  50070. }
  50071. function genData$1 (el) {
  50072. var data = '';
  50073. if (el.staticStyle) {
  50074. data += "staticStyle:" + (el.staticStyle) + ",";
  50075. }
  50076. if (el.styleBinding) {
  50077. data += "style:(" + (el.styleBinding) + "),";
  50078. }
  50079. return data
  50080. }
  50081. var style$1 = {
  50082. staticKeys: ['staticStyle'],
  50083. transformNode: transformNode$1,
  50084. genData: genData$1
  50085. };
  50086. /* */
  50087. var decoder;
  50088. var he = {
  50089. decode: function decode (html) {
  50090. decoder = decoder || document.createElement('div');
  50091. decoder.innerHTML = html;
  50092. return decoder.textContent
  50093. }
  50094. };
  50095. /* */
  50096. var isUnaryTag = makeMap(
  50097. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50098. 'link,meta,param,source,track,wbr'
  50099. );
  50100. // Elements that you can, intentionally, leave open
  50101. // (and which close themselves)
  50102. var canBeLeftOpenTag = makeMap(
  50103. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50104. );
  50105. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50106. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50107. var isNonPhrasingTag = makeMap(
  50108. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50109. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50110. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50111. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50112. 'title,tr,track'
  50113. );
  50114. /**
  50115. * Not type-checking this file because it's mostly vendor code.
  50116. */
  50117. // Regular Expressions for parsing tags and attributes
  50118. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50119. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50120. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50121. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50122. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50123. var startTagClose = /^\s*(\/?)>/;
  50124. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50125. var doctype = /^<!DOCTYPE [^>]+>/i;
  50126. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50127. var comment = /^<!\--/;
  50128. var conditionalComment = /^<!\[/;
  50129. // Special Elements (can contain anything)
  50130. var isPlainTextElement = makeMap('script,style,textarea', true);
  50131. var reCache = {};
  50132. var decodingMap = {
  50133. '&lt;': '<',
  50134. '&gt;': '>',
  50135. '&quot;': '"',
  50136. '&amp;': '&',
  50137. '&#10;': '\n',
  50138. '&#9;': '\t',
  50139. '&#39;': "'"
  50140. };
  50141. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50142. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50143. // #5992
  50144. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50145. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50146. function decodeAttr (value, shouldDecodeNewlines) {
  50147. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50148. return value.replace(re, function (match) { return decodingMap[match]; })
  50149. }
  50150. function parseHTML (html, options) {
  50151. var stack = [];
  50152. var expectHTML = options.expectHTML;
  50153. var isUnaryTag$$1 = options.isUnaryTag || no;
  50154. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50155. var index = 0;
  50156. var last, lastTag;
  50157. while (html) {
  50158. last = html;
  50159. // Make sure we're not in a plaintext content element like script/style
  50160. if (!lastTag || !isPlainTextElement(lastTag)) {
  50161. var textEnd = html.indexOf('<');
  50162. if (textEnd === 0) {
  50163. // Comment:
  50164. if (comment.test(html)) {
  50165. var commentEnd = html.indexOf('-->');
  50166. if (commentEnd >= 0) {
  50167. if (options.shouldKeepComment) {
  50168. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50169. }
  50170. advance(commentEnd + 3);
  50171. continue
  50172. }
  50173. }
  50174. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50175. if (conditionalComment.test(html)) {
  50176. var conditionalEnd = html.indexOf(']>');
  50177. if (conditionalEnd >= 0) {
  50178. advance(conditionalEnd + 2);
  50179. continue
  50180. }
  50181. }
  50182. // Doctype:
  50183. var doctypeMatch = html.match(doctype);
  50184. if (doctypeMatch) {
  50185. advance(doctypeMatch[0].length);
  50186. continue
  50187. }
  50188. // End tag:
  50189. var endTagMatch = html.match(endTag);
  50190. if (endTagMatch) {
  50191. var curIndex = index;
  50192. advance(endTagMatch[0].length);
  50193. parseEndTag(endTagMatch[1], curIndex, index);
  50194. continue
  50195. }
  50196. // Start tag:
  50197. var startTagMatch = parseStartTag();
  50198. if (startTagMatch) {
  50199. handleStartTag(startTagMatch);
  50200. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50201. advance(1);
  50202. }
  50203. continue
  50204. }
  50205. }
  50206. var text = (void 0), rest = (void 0), next = (void 0);
  50207. if (textEnd >= 0) {
  50208. rest = html.slice(textEnd);
  50209. while (
  50210. !endTag.test(rest) &&
  50211. !startTagOpen.test(rest) &&
  50212. !comment.test(rest) &&
  50213. !conditionalComment.test(rest)
  50214. ) {
  50215. // < in plain text, be forgiving and treat it as text
  50216. next = rest.indexOf('<', 1);
  50217. if (next < 0) { break }
  50218. textEnd += next;
  50219. rest = html.slice(textEnd);
  50220. }
  50221. text = html.substring(0, textEnd);
  50222. }
  50223. if (textEnd < 0) {
  50224. text = html;
  50225. }
  50226. if (text) {
  50227. advance(text.length);
  50228. }
  50229. if (options.chars && text) {
  50230. options.chars(text, index - text.length, index);
  50231. }
  50232. } else {
  50233. var endTagLength = 0;
  50234. var stackedTag = lastTag.toLowerCase();
  50235. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50236. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50237. endTagLength = endTag.length;
  50238. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50239. text = text
  50240. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50241. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50242. }
  50243. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50244. text = text.slice(1);
  50245. }
  50246. if (options.chars) {
  50247. options.chars(text);
  50248. }
  50249. return ''
  50250. });
  50251. index += html.length - rest$1.length;
  50252. html = rest$1;
  50253. parseEndTag(stackedTag, index - endTagLength, index);
  50254. }
  50255. if (html === last) {
  50256. options.chars && options.chars(html);
  50257. if (!stack.length && options.warn) {
  50258. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50259. }
  50260. break
  50261. }
  50262. }
  50263. // Clean up any remaining tags
  50264. parseEndTag();
  50265. function advance (n) {
  50266. index += n;
  50267. html = html.substring(n);
  50268. }
  50269. function parseStartTag () {
  50270. var start = html.match(startTagOpen);
  50271. if (start) {
  50272. var match = {
  50273. tagName: start[1],
  50274. attrs: [],
  50275. start: index
  50276. };
  50277. advance(start[0].length);
  50278. var end, attr;
  50279. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50280. attr.start = index;
  50281. advance(attr[0].length);
  50282. attr.end = index;
  50283. match.attrs.push(attr);
  50284. }
  50285. if (end) {
  50286. match.unarySlash = end[1];
  50287. advance(end[0].length);
  50288. match.end = index;
  50289. return match
  50290. }
  50291. }
  50292. }
  50293. function handleStartTag (match) {
  50294. var tagName = match.tagName;
  50295. var unarySlash = match.unarySlash;
  50296. if (expectHTML) {
  50297. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50298. parseEndTag(lastTag);
  50299. }
  50300. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50301. parseEndTag(tagName);
  50302. }
  50303. }
  50304. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50305. var l = match.attrs.length;
  50306. var attrs = new Array(l);
  50307. for (var i = 0; i < l; i++) {
  50308. var args = match.attrs[i];
  50309. var value = args[3] || args[4] || args[5] || '';
  50310. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50311. ? options.shouldDecodeNewlinesForHref
  50312. : options.shouldDecodeNewlines;
  50313. attrs[i] = {
  50314. name: args[1],
  50315. value: decodeAttr(value, shouldDecodeNewlines)
  50316. };
  50317. if (options.outputSourceRange) {
  50318. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50319. attrs[i].end = args.end;
  50320. }
  50321. }
  50322. if (!unary) {
  50323. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50324. lastTag = tagName;
  50325. }
  50326. if (options.start) {
  50327. options.start(tagName, attrs, unary, match.start, match.end);
  50328. }
  50329. }
  50330. function parseEndTag (tagName, start, end) {
  50331. var pos, lowerCasedTagName;
  50332. if (start == null) { start = index; }
  50333. if (end == null) { end = index; }
  50334. // Find the closest opened tag of the same type
  50335. if (tagName) {
  50336. lowerCasedTagName = tagName.toLowerCase();
  50337. for (pos = stack.length - 1; pos >= 0; pos--) {
  50338. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50339. break
  50340. }
  50341. }
  50342. } else {
  50343. // If no tag name is provided, clean shop
  50344. pos = 0;
  50345. }
  50346. if (pos >= 0) {
  50347. // Close all the open elements, up the stack
  50348. for (var i = stack.length - 1; i >= pos; i--) {
  50349. if (i > pos || !tagName &&
  50350. options.warn
  50351. ) {
  50352. options.warn(
  50353. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50354. { start: stack[i].start, end: stack[i].end }
  50355. );
  50356. }
  50357. if (options.end) {
  50358. options.end(stack[i].tag, start, end);
  50359. }
  50360. }
  50361. // Remove the open elements from the stack
  50362. stack.length = pos;
  50363. lastTag = pos && stack[pos - 1].tag;
  50364. } else if (lowerCasedTagName === 'br') {
  50365. if (options.start) {
  50366. options.start(tagName, [], true, start, end);
  50367. }
  50368. } else if (lowerCasedTagName === 'p') {
  50369. if (options.start) {
  50370. options.start(tagName, [], false, start, end);
  50371. }
  50372. if (options.end) {
  50373. options.end(tagName, start, end);
  50374. }
  50375. }
  50376. }
  50377. }
  50378. /* */
  50379. var onRE = /^@|^v-on:/;
  50380. var dirRE = /^v-|^@|^:|^#/;
  50381. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50382. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50383. var stripParensRE = /^\(|\)$/g;
  50384. var dynamicArgRE = /^\[.*\]$/;
  50385. var argRE = /:(.*)$/;
  50386. var bindRE = /^:|^\.|^v-bind:/;
  50387. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50388. var slotRE = /^v-slot(:|$)|^#/;
  50389. var lineBreakRE = /[\r\n]/;
  50390. var whitespaceRE$1 = /\s+/g;
  50391. var invalidAttributeRE = /[\s"'<>\/=]/;
  50392. var decodeHTMLCached = cached(he.decode);
  50393. var emptySlotScopeToken = "_empty_";
  50394. // configurable state
  50395. var warn$2;
  50396. var delimiters;
  50397. var transforms;
  50398. var preTransforms;
  50399. var postTransforms;
  50400. var platformIsPreTag;
  50401. var platformMustUseProp;
  50402. var platformGetTagNamespace;
  50403. var maybeComponent;
  50404. function createASTElement (
  50405. tag,
  50406. attrs,
  50407. parent
  50408. ) {
  50409. return {
  50410. type: 1,
  50411. tag: tag,
  50412. attrsList: attrs,
  50413. attrsMap: makeAttrsMap(attrs),
  50414. rawAttrsMap: {},
  50415. parent: parent,
  50416. children: []
  50417. }
  50418. }
  50419. /**
  50420. * Convert HTML string to AST.
  50421. */
  50422. function parse (
  50423. template,
  50424. options
  50425. ) {
  50426. warn$2 = options.warn || baseWarn;
  50427. platformIsPreTag = options.isPreTag || no;
  50428. platformMustUseProp = options.mustUseProp || no;
  50429. platformGetTagNamespace = options.getTagNamespace || no;
  50430. var isReservedTag = options.isReservedTag || no;
  50431. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50432. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50433. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50434. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50435. delimiters = options.delimiters;
  50436. var stack = [];
  50437. var preserveWhitespace = options.preserveWhitespace !== false;
  50438. var whitespaceOption = options.whitespace;
  50439. var root;
  50440. var currentParent;
  50441. var inVPre = false;
  50442. var inPre = false;
  50443. var warned = false;
  50444. function warnOnce (msg, range) {
  50445. if (!warned) {
  50446. warned = true;
  50447. warn$2(msg, range);
  50448. }
  50449. }
  50450. function closeElement (element) {
  50451. trimEndingWhitespace(element);
  50452. if (!inVPre && !element.processed) {
  50453. element = processElement(element, options);
  50454. }
  50455. // tree management
  50456. if (!stack.length && element !== root) {
  50457. // allow root elements with v-if, v-else-if and v-else
  50458. if (root.if && (element.elseif || element.else)) {
  50459. {
  50460. checkRootConstraints(element);
  50461. }
  50462. addIfCondition(root, {
  50463. exp: element.elseif,
  50464. block: element
  50465. });
  50466. } else {
  50467. warnOnce(
  50468. "Component template should contain exactly one root element. " +
  50469. "If you are using v-if on multiple elements, " +
  50470. "use v-else-if to chain them instead.",
  50471. { start: element.start }
  50472. );
  50473. }
  50474. }
  50475. if (currentParent && !element.forbidden) {
  50476. if (element.elseif || element.else) {
  50477. processIfConditions(element, currentParent);
  50478. } else {
  50479. if (element.slotScope) {
  50480. // scoped slot
  50481. // keep it in the children list so that v-else(-if) conditions can
  50482. // find it as the prev node.
  50483. var name = element.slotTarget || '"default"'
  50484. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50485. }
  50486. currentParent.children.push(element);
  50487. element.parent = currentParent;
  50488. }
  50489. }
  50490. // final children cleanup
  50491. // filter out scoped slots
  50492. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50493. // remove trailing whitespace node again
  50494. trimEndingWhitespace(element);
  50495. // check pre state
  50496. if (element.pre) {
  50497. inVPre = false;
  50498. }
  50499. if (platformIsPreTag(element.tag)) {
  50500. inPre = false;
  50501. }
  50502. // apply post-transforms
  50503. for (var i = 0; i < postTransforms.length; i++) {
  50504. postTransforms[i](element, options);
  50505. }
  50506. }
  50507. function trimEndingWhitespace (el) {
  50508. // remove trailing whitespace node
  50509. if (!inPre) {
  50510. var lastNode;
  50511. while (
  50512. (lastNode = el.children[el.children.length - 1]) &&
  50513. lastNode.type === 3 &&
  50514. lastNode.text === ' '
  50515. ) {
  50516. el.children.pop();
  50517. }
  50518. }
  50519. }
  50520. function checkRootConstraints (el) {
  50521. if (el.tag === 'slot' || el.tag === 'template') {
  50522. warnOnce(
  50523. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50524. 'contain multiple nodes.',
  50525. { start: el.start }
  50526. );
  50527. }
  50528. if (el.attrsMap.hasOwnProperty('v-for')) {
  50529. warnOnce(
  50530. 'Cannot use v-for on stateful component root element because ' +
  50531. 'it renders multiple elements.',
  50532. el.rawAttrsMap['v-for']
  50533. );
  50534. }
  50535. }
  50536. parseHTML(template, {
  50537. warn: warn$2,
  50538. expectHTML: options.expectHTML,
  50539. isUnaryTag: options.isUnaryTag,
  50540. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50541. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50542. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50543. shouldKeepComment: options.comments,
  50544. outputSourceRange: options.outputSourceRange,
  50545. start: function start (tag, attrs, unary, start$1, end) {
  50546. // check namespace.
  50547. // inherit parent ns if there is one
  50548. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50549. // handle IE svg bug
  50550. /* istanbul ignore if */
  50551. if (isIE && ns === 'svg') {
  50552. attrs = guardIESVGBug(attrs);
  50553. }
  50554. var element = createASTElement(tag, attrs, currentParent);
  50555. if (ns) {
  50556. element.ns = ns;
  50557. }
  50558. {
  50559. if (options.outputSourceRange) {
  50560. element.start = start$1;
  50561. element.end = end;
  50562. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50563. cumulated[attr.name] = attr;
  50564. return cumulated
  50565. }, {});
  50566. }
  50567. attrs.forEach(function (attr) {
  50568. if (invalidAttributeRE.test(attr.name)) {
  50569. warn$2(
  50570. "Invalid dynamic argument expression: attribute names cannot contain " +
  50571. "spaces, quotes, <, >, / or =.",
  50572. {
  50573. start: attr.start + attr.name.indexOf("["),
  50574. end: attr.start + attr.name.length
  50575. }
  50576. );
  50577. }
  50578. });
  50579. }
  50580. if (isForbiddenTag(element) && !isServerRendering()) {
  50581. element.forbidden = true;
  50582. warn$2(
  50583. 'Templates should only be responsible for mapping the state to the ' +
  50584. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50585. "<" + tag + ">" + ', as they will not be parsed.',
  50586. { start: element.start }
  50587. );
  50588. }
  50589. // apply pre-transforms
  50590. for (var i = 0; i < preTransforms.length; i++) {
  50591. element = preTransforms[i](element, options) || element;
  50592. }
  50593. if (!inVPre) {
  50594. processPre(element);
  50595. if (element.pre) {
  50596. inVPre = true;
  50597. }
  50598. }
  50599. if (platformIsPreTag(element.tag)) {
  50600. inPre = true;
  50601. }
  50602. if (inVPre) {
  50603. processRawAttrs(element);
  50604. } else if (!element.processed) {
  50605. // structural directives
  50606. processFor(element);
  50607. processIf(element);
  50608. processOnce(element);
  50609. }
  50610. if (!root) {
  50611. root = element;
  50612. {
  50613. checkRootConstraints(root);
  50614. }
  50615. }
  50616. if (!unary) {
  50617. currentParent = element;
  50618. stack.push(element);
  50619. } else {
  50620. closeElement(element);
  50621. }
  50622. },
  50623. end: function end (tag, start, end$1) {
  50624. var element = stack[stack.length - 1];
  50625. // pop stack
  50626. stack.length -= 1;
  50627. currentParent = stack[stack.length - 1];
  50628. if (options.outputSourceRange) {
  50629. element.end = end$1;
  50630. }
  50631. closeElement(element);
  50632. },
  50633. chars: function chars (text, start, end) {
  50634. if (!currentParent) {
  50635. {
  50636. if (text === template) {
  50637. warnOnce(
  50638. 'Component template requires a root element, rather than just text.',
  50639. { start: start }
  50640. );
  50641. } else if ((text = text.trim())) {
  50642. warnOnce(
  50643. ("text \"" + text + "\" outside root element will be ignored."),
  50644. { start: start }
  50645. );
  50646. }
  50647. }
  50648. return
  50649. }
  50650. // IE textarea placeholder bug
  50651. /* istanbul ignore if */
  50652. if (isIE &&
  50653. currentParent.tag === 'textarea' &&
  50654. currentParent.attrsMap.placeholder === text
  50655. ) {
  50656. return
  50657. }
  50658. var children = currentParent.children;
  50659. if (inPre || text.trim()) {
  50660. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50661. } else if (!children.length) {
  50662. // remove the whitespace-only node right after an opening tag
  50663. text = '';
  50664. } else if (whitespaceOption) {
  50665. if (whitespaceOption === 'condense') {
  50666. // in condense mode, remove the whitespace node if it contains
  50667. // line break, otherwise condense to a single space
  50668. text = lineBreakRE.test(text) ? '' : ' ';
  50669. } else {
  50670. text = ' ';
  50671. }
  50672. } else {
  50673. text = preserveWhitespace ? ' ' : '';
  50674. }
  50675. if (text) {
  50676. if (!inPre && whitespaceOption === 'condense') {
  50677. // condense consecutive whitespaces into single space
  50678. text = text.replace(whitespaceRE$1, ' ');
  50679. }
  50680. var res;
  50681. var child;
  50682. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50683. child = {
  50684. type: 2,
  50685. expression: res.expression,
  50686. tokens: res.tokens,
  50687. text: text
  50688. };
  50689. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50690. child = {
  50691. type: 3,
  50692. text: text
  50693. };
  50694. }
  50695. if (child) {
  50696. if (options.outputSourceRange) {
  50697. child.start = start;
  50698. child.end = end;
  50699. }
  50700. children.push(child);
  50701. }
  50702. }
  50703. },
  50704. comment: function comment (text, start, end) {
  50705. // adding anyting as a sibling to the root node is forbidden
  50706. // comments should still be allowed, but ignored
  50707. if (currentParent) {
  50708. var child = {
  50709. type: 3,
  50710. text: text,
  50711. isComment: true
  50712. };
  50713. if (options.outputSourceRange) {
  50714. child.start = start;
  50715. child.end = end;
  50716. }
  50717. currentParent.children.push(child);
  50718. }
  50719. }
  50720. });
  50721. return root
  50722. }
  50723. function processPre (el) {
  50724. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50725. el.pre = true;
  50726. }
  50727. }
  50728. function processRawAttrs (el) {
  50729. var list = el.attrsList;
  50730. var len = list.length;
  50731. if (len) {
  50732. var attrs = el.attrs = new Array(len);
  50733. for (var i = 0; i < len; i++) {
  50734. attrs[i] = {
  50735. name: list[i].name,
  50736. value: JSON.stringify(list[i].value)
  50737. };
  50738. if (list[i].start != null) {
  50739. attrs[i].start = list[i].start;
  50740. attrs[i].end = list[i].end;
  50741. }
  50742. }
  50743. } else if (!el.pre) {
  50744. // non root node in pre blocks with no attributes
  50745. el.plain = true;
  50746. }
  50747. }
  50748. function processElement (
  50749. element,
  50750. options
  50751. ) {
  50752. processKey(element);
  50753. // determine whether this is a plain element after
  50754. // removing structural attributes
  50755. element.plain = (
  50756. !element.key &&
  50757. !element.scopedSlots &&
  50758. !element.attrsList.length
  50759. );
  50760. processRef(element);
  50761. processSlotContent(element);
  50762. processSlotOutlet(element);
  50763. processComponent(element);
  50764. for (var i = 0; i < transforms.length; i++) {
  50765. element = transforms[i](element, options) || element;
  50766. }
  50767. processAttrs(element);
  50768. return element
  50769. }
  50770. function processKey (el) {
  50771. var exp = getBindingAttr(el, 'key');
  50772. if (exp) {
  50773. {
  50774. if (el.tag === 'template') {
  50775. warn$2(
  50776. "<template> cannot be keyed. Place the key on real elements instead.",
  50777. getRawBindingAttr(el, 'key')
  50778. );
  50779. }
  50780. if (el.for) {
  50781. var iterator = el.iterator2 || el.iterator1;
  50782. var parent = el.parent;
  50783. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50784. warn$2(
  50785. "Do not use v-for index as key on <transition-group> children, " +
  50786. "this is the same as not using keys.",
  50787. getRawBindingAttr(el, 'key'),
  50788. true /* tip */
  50789. );
  50790. }
  50791. }
  50792. }
  50793. el.key = exp;
  50794. }
  50795. }
  50796. function processRef (el) {
  50797. var ref = getBindingAttr(el, 'ref');
  50798. if (ref) {
  50799. el.ref = ref;
  50800. el.refInFor = checkInFor(el);
  50801. }
  50802. }
  50803. function processFor (el) {
  50804. var exp;
  50805. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50806. var res = parseFor(exp);
  50807. if (res) {
  50808. extend(el, res);
  50809. } else {
  50810. warn$2(
  50811. ("Invalid v-for expression: " + exp),
  50812. el.rawAttrsMap['v-for']
  50813. );
  50814. }
  50815. }
  50816. }
  50817. function parseFor (exp) {
  50818. var inMatch = exp.match(forAliasRE);
  50819. if (!inMatch) { return }
  50820. var res = {};
  50821. res.for = inMatch[2].trim();
  50822. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50823. var iteratorMatch = alias.match(forIteratorRE);
  50824. if (iteratorMatch) {
  50825. res.alias = alias.replace(forIteratorRE, '').trim();
  50826. res.iterator1 = iteratorMatch[1].trim();
  50827. if (iteratorMatch[2]) {
  50828. res.iterator2 = iteratorMatch[2].trim();
  50829. }
  50830. } else {
  50831. res.alias = alias;
  50832. }
  50833. return res
  50834. }
  50835. function processIf (el) {
  50836. var exp = getAndRemoveAttr(el, 'v-if');
  50837. if (exp) {
  50838. el.if = exp;
  50839. addIfCondition(el, {
  50840. exp: exp,
  50841. block: el
  50842. });
  50843. } else {
  50844. if (getAndRemoveAttr(el, 'v-else') != null) {
  50845. el.else = true;
  50846. }
  50847. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50848. if (elseif) {
  50849. el.elseif = elseif;
  50850. }
  50851. }
  50852. }
  50853. function processIfConditions (el, parent) {
  50854. var prev = findPrevElement(parent.children);
  50855. if (prev && prev.if) {
  50856. addIfCondition(prev, {
  50857. exp: el.elseif,
  50858. block: el
  50859. });
  50860. } else {
  50861. warn$2(
  50862. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  50863. "used on element <" + (el.tag) + "> without corresponding v-if.",
  50864. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  50865. );
  50866. }
  50867. }
  50868. function findPrevElement (children) {
  50869. var i = children.length;
  50870. while (i--) {
  50871. if (children[i].type === 1) {
  50872. return children[i]
  50873. } else {
  50874. if (children[i].text !== ' ') {
  50875. warn$2(
  50876. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  50877. "will be ignored.",
  50878. children[i]
  50879. );
  50880. }
  50881. children.pop();
  50882. }
  50883. }
  50884. }
  50885. function addIfCondition (el, condition) {
  50886. if (!el.ifConditions) {
  50887. el.ifConditions = [];
  50888. }
  50889. el.ifConditions.push(condition);
  50890. }
  50891. function processOnce (el) {
  50892. var once$$1 = getAndRemoveAttr(el, 'v-once');
  50893. if (once$$1 != null) {
  50894. el.once = true;
  50895. }
  50896. }
  50897. // handle content being passed to a component as slot,
  50898. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  50899. function processSlotContent (el) {
  50900. var slotScope;
  50901. if (el.tag === 'template') {
  50902. slotScope = getAndRemoveAttr(el, 'scope');
  50903. /* istanbul ignore if */
  50904. if (slotScope) {
  50905. warn$2(
  50906. "the \"scope\" attribute for scoped slots have been deprecated and " +
  50907. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  50908. "can also be used on plain elements in addition to <template> to " +
  50909. "denote scoped slots.",
  50910. el.rawAttrsMap['scope'],
  50911. true
  50912. );
  50913. }
  50914. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  50915. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  50916. /* istanbul ignore if */
  50917. if (el.attrsMap['v-for']) {
  50918. warn$2(
  50919. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  50920. "(v-for takes higher priority). Use a wrapper <template> for the " +
  50921. "scoped slot to make it clearer.",
  50922. el.rawAttrsMap['slot-scope'],
  50923. true
  50924. );
  50925. }
  50926. el.slotScope = slotScope;
  50927. }
  50928. // slot="xxx"
  50929. var slotTarget = getBindingAttr(el, 'slot');
  50930. if (slotTarget) {
  50931. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  50932. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  50933. // preserve slot as an attribute for native shadow DOM compat
  50934. // only for non-scoped slots.
  50935. if (el.tag !== 'template' && !el.slotScope) {
  50936. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  50937. }
  50938. }
  50939. // 2.6 v-slot syntax
  50940. {
  50941. if (el.tag === 'template') {
  50942. // v-slot on <template>
  50943. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  50944. if (slotBinding) {
  50945. {
  50946. if (el.slotTarget || el.slotScope) {
  50947. warn$2(
  50948. "Unexpected mixed usage of different slot syntaxes.",
  50949. el
  50950. );
  50951. }
  50952. if (el.parent && !maybeComponent(el.parent)) {
  50953. warn$2(
  50954. "<template v-slot> can only appear at the root level inside " +
  50955. "the receiving component",
  50956. el
  50957. );
  50958. }
  50959. }
  50960. var ref = getSlotName(slotBinding);
  50961. var name = ref.name;
  50962. var dynamic = ref.dynamic;
  50963. el.slotTarget = name;
  50964. el.slotTargetDynamic = dynamic;
  50965. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  50966. }
  50967. } else {
  50968. // v-slot on component, denotes default slot
  50969. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  50970. if (slotBinding$1) {
  50971. {
  50972. if (!maybeComponent(el)) {
  50973. warn$2(
  50974. "v-slot can only be used on components or <template>.",
  50975. slotBinding$1
  50976. );
  50977. }
  50978. if (el.slotScope || el.slotTarget) {
  50979. warn$2(
  50980. "Unexpected mixed usage of different slot syntaxes.",
  50981. el
  50982. );
  50983. }
  50984. if (el.scopedSlots) {
  50985. warn$2(
  50986. "To avoid scope ambiguity, the default slot should also use " +
  50987. "<template> syntax when there are other named slots.",
  50988. slotBinding$1
  50989. );
  50990. }
  50991. }
  50992. // add the component's children to its default slot
  50993. var slots = el.scopedSlots || (el.scopedSlots = {});
  50994. var ref$1 = getSlotName(slotBinding$1);
  50995. var name$1 = ref$1.name;
  50996. var dynamic$1 = ref$1.dynamic;
  50997. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  50998. slotContainer.slotTarget = name$1;
  50999. slotContainer.slotTargetDynamic = dynamic$1;
  51000. slotContainer.children = el.children.filter(function (c) {
  51001. if (!c.slotScope) {
  51002. c.parent = slotContainer;
  51003. return true
  51004. }
  51005. });
  51006. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  51007. // remove children as they are returned from scopedSlots now
  51008. el.children = [];
  51009. // mark el non-plain so data gets generated
  51010. el.plain = false;
  51011. }
  51012. }
  51013. }
  51014. }
  51015. function getSlotName (binding) {
  51016. var name = binding.name.replace(slotRE, '');
  51017. if (!name) {
  51018. if (binding.name[0] !== '#') {
  51019. name = 'default';
  51020. } else {
  51021. warn$2(
  51022. "v-slot shorthand syntax requires a slot name.",
  51023. binding
  51024. );
  51025. }
  51026. }
  51027. return dynamicArgRE.test(name)
  51028. // dynamic [name]
  51029. ? { name: name.slice(1, -1), dynamic: true }
  51030. // static name
  51031. : { name: ("\"" + name + "\""), dynamic: false }
  51032. }
  51033. // handle <slot/> outlets
  51034. function processSlotOutlet (el) {
  51035. if (el.tag === 'slot') {
  51036. el.slotName = getBindingAttr(el, 'name');
  51037. if (el.key) {
  51038. warn$2(
  51039. "`key` does not work on <slot> because slots are abstract outlets " +
  51040. "and can possibly expand into multiple elements. " +
  51041. "Use the key on a wrapping element instead.",
  51042. getRawBindingAttr(el, 'key')
  51043. );
  51044. }
  51045. }
  51046. }
  51047. function processComponent (el) {
  51048. var binding;
  51049. if ((binding = getBindingAttr(el, 'is'))) {
  51050. el.component = binding;
  51051. }
  51052. if (getAndRemoveAttr(el, 'inline-template') != null) {
  51053. el.inlineTemplate = true;
  51054. }
  51055. }
  51056. function processAttrs (el) {
  51057. var list = el.attrsList;
  51058. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  51059. for (i = 0, l = list.length; i < l; i++) {
  51060. name = rawName = list[i].name;
  51061. value = list[i].value;
  51062. if (dirRE.test(name)) {
  51063. // mark element as dynamic
  51064. el.hasBindings = true;
  51065. // modifiers
  51066. modifiers = parseModifiers(name.replace(dirRE, ''));
  51067. // support .foo shorthand syntax for the .prop modifier
  51068. if (modifiers) {
  51069. name = name.replace(modifierRE, '');
  51070. }
  51071. if (bindRE.test(name)) { // v-bind
  51072. name = name.replace(bindRE, '');
  51073. value = parseFilters(value);
  51074. isDynamic = dynamicArgRE.test(name);
  51075. if (isDynamic) {
  51076. name = name.slice(1, -1);
  51077. }
  51078. if (
  51079. value.trim().length === 0
  51080. ) {
  51081. warn$2(
  51082. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  51083. );
  51084. }
  51085. if (modifiers) {
  51086. if (modifiers.prop && !isDynamic) {
  51087. name = camelize(name);
  51088. if (name === 'innerHtml') { name = 'innerHTML'; }
  51089. }
  51090. if (modifiers.camel && !isDynamic) {
  51091. name = camelize(name);
  51092. }
  51093. if (modifiers.sync) {
  51094. syncGen = genAssignmentCode(value, "$event");
  51095. if (!isDynamic) {
  51096. addHandler(
  51097. el,
  51098. ("update:" + (camelize(name))),
  51099. syncGen,
  51100. null,
  51101. false,
  51102. warn$2,
  51103. list[i]
  51104. );
  51105. if (hyphenate(name) !== camelize(name)) {
  51106. addHandler(
  51107. el,
  51108. ("update:" + (hyphenate(name))),
  51109. syncGen,
  51110. null,
  51111. false,
  51112. warn$2,
  51113. list[i]
  51114. );
  51115. }
  51116. } else {
  51117. // handler w/ dynamic event name
  51118. addHandler(
  51119. el,
  51120. ("\"update:\"+(" + name + ")"),
  51121. syncGen,
  51122. null,
  51123. false,
  51124. warn$2,
  51125. list[i],
  51126. true // dynamic
  51127. );
  51128. }
  51129. }
  51130. }
  51131. if ((modifiers && modifiers.prop) || (
  51132. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51133. )) {
  51134. addProp(el, name, value, list[i], isDynamic);
  51135. } else {
  51136. addAttr(el, name, value, list[i], isDynamic);
  51137. }
  51138. } else if (onRE.test(name)) { // v-on
  51139. name = name.replace(onRE, '');
  51140. isDynamic = dynamicArgRE.test(name);
  51141. if (isDynamic) {
  51142. name = name.slice(1, -1);
  51143. }
  51144. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51145. } else { // normal directives
  51146. name = name.replace(dirRE, '');
  51147. // parse arg
  51148. var argMatch = name.match(argRE);
  51149. var arg = argMatch && argMatch[1];
  51150. isDynamic = false;
  51151. if (arg) {
  51152. name = name.slice(0, -(arg.length + 1));
  51153. if (dynamicArgRE.test(arg)) {
  51154. arg = arg.slice(1, -1);
  51155. isDynamic = true;
  51156. }
  51157. }
  51158. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51159. if (name === 'model') {
  51160. checkForAliasModel(el, value);
  51161. }
  51162. }
  51163. } else {
  51164. // literal attribute
  51165. {
  51166. var res = parseText(value, delimiters);
  51167. if (res) {
  51168. warn$2(
  51169. name + "=\"" + value + "\": " +
  51170. 'Interpolation inside attributes has been removed. ' +
  51171. 'Use v-bind or the colon shorthand instead. For example, ' +
  51172. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51173. list[i]
  51174. );
  51175. }
  51176. }
  51177. addAttr(el, name, JSON.stringify(value), list[i]);
  51178. // #6887 firefox doesn't update muted state if set via attribute
  51179. // even immediately after element creation
  51180. if (!el.component &&
  51181. name === 'muted' &&
  51182. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51183. addProp(el, name, 'true', list[i]);
  51184. }
  51185. }
  51186. }
  51187. }
  51188. function checkInFor (el) {
  51189. var parent = el;
  51190. while (parent) {
  51191. if (parent.for !== undefined) {
  51192. return true
  51193. }
  51194. parent = parent.parent;
  51195. }
  51196. return false
  51197. }
  51198. function parseModifiers (name) {
  51199. var match = name.match(modifierRE);
  51200. if (match) {
  51201. var ret = {};
  51202. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51203. return ret
  51204. }
  51205. }
  51206. function makeAttrsMap (attrs) {
  51207. var map = {};
  51208. for (var i = 0, l = attrs.length; i < l; i++) {
  51209. if (
  51210. map[attrs[i].name] && !isIE && !isEdge
  51211. ) {
  51212. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51213. }
  51214. map[attrs[i].name] = attrs[i].value;
  51215. }
  51216. return map
  51217. }
  51218. // for script (e.g. type="x/template") or style, do not decode content
  51219. function isTextTag (el) {
  51220. return el.tag === 'script' || el.tag === 'style'
  51221. }
  51222. function isForbiddenTag (el) {
  51223. return (
  51224. el.tag === 'style' ||
  51225. (el.tag === 'script' && (
  51226. !el.attrsMap.type ||
  51227. el.attrsMap.type === 'text/javascript'
  51228. ))
  51229. )
  51230. }
  51231. var ieNSBug = /^xmlns:NS\d+/;
  51232. var ieNSPrefix = /^NS\d+:/;
  51233. /* istanbul ignore next */
  51234. function guardIESVGBug (attrs) {
  51235. var res = [];
  51236. for (var i = 0; i < attrs.length; i++) {
  51237. var attr = attrs[i];
  51238. if (!ieNSBug.test(attr.name)) {
  51239. attr.name = attr.name.replace(ieNSPrefix, '');
  51240. res.push(attr);
  51241. }
  51242. }
  51243. return res
  51244. }
  51245. function checkForAliasModel (el, value) {
  51246. var _el = el;
  51247. while (_el) {
  51248. if (_el.for && _el.alias === value) {
  51249. warn$2(
  51250. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51251. "You are binding v-model directly to a v-for iteration alias. " +
  51252. "This will not be able to modify the v-for source array because " +
  51253. "writing to the alias is like modifying a function local variable. " +
  51254. "Consider using an array of objects and use v-model on an object property instead.",
  51255. el.rawAttrsMap['v-model']
  51256. );
  51257. }
  51258. _el = _el.parent;
  51259. }
  51260. }
  51261. /* */
  51262. function preTransformNode (el, options) {
  51263. if (el.tag === 'input') {
  51264. var map = el.attrsMap;
  51265. if (!map['v-model']) {
  51266. return
  51267. }
  51268. var typeBinding;
  51269. if (map[':type'] || map['v-bind:type']) {
  51270. typeBinding = getBindingAttr(el, 'type');
  51271. }
  51272. if (!map.type && !typeBinding && map['v-bind']) {
  51273. typeBinding = "(" + (map['v-bind']) + ").type";
  51274. }
  51275. if (typeBinding) {
  51276. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51277. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51278. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51279. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51280. // 1. checkbox
  51281. var branch0 = cloneASTElement(el);
  51282. // process for on the main node
  51283. processFor(branch0);
  51284. addRawAttr(branch0, 'type', 'checkbox');
  51285. processElement(branch0, options);
  51286. branch0.processed = true; // prevent it from double-processed
  51287. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51288. addIfCondition(branch0, {
  51289. exp: branch0.if,
  51290. block: branch0
  51291. });
  51292. // 2. add radio else-if condition
  51293. var branch1 = cloneASTElement(el);
  51294. getAndRemoveAttr(branch1, 'v-for', true);
  51295. addRawAttr(branch1, 'type', 'radio');
  51296. processElement(branch1, options);
  51297. addIfCondition(branch0, {
  51298. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51299. block: branch1
  51300. });
  51301. // 3. other
  51302. var branch2 = cloneASTElement(el);
  51303. getAndRemoveAttr(branch2, 'v-for', true);
  51304. addRawAttr(branch2, ':type', typeBinding);
  51305. processElement(branch2, options);
  51306. addIfCondition(branch0, {
  51307. exp: ifCondition,
  51308. block: branch2
  51309. });
  51310. if (hasElse) {
  51311. branch0.else = true;
  51312. } else if (elseIfCondition) {
  51313. branch0.elseif = elseIfCondition;
  51314. }
  51315. return branch0
  51316. }
  51317. }
  51318. }
  51319. function cloneASTElement (el) {
  51320. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51321. }
  51322. var model$1 = {
  51323. preTransformNode: preTransformNode
  51324. };
  51325. var modules$1 = [
  51326. klass$1,
  51327. style$1,
  51328. model$1
  51329. ];
  51330. /* */
  51331. function text (el, dir) {
  51332. if (dir.value) {
  51333. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51334. }
  51335. }
  51336. /* */
  51337. function html (el, dir) {
  51338. if (dir.value) {
  51339. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51340. }
  51341. }
  51342. var directives$1 = {
  51343. model: model,
  51344. text: text,
  51345. html: html
  51346. };
  51347. /* */
  51348. var baseOptions = {
  51349. expectHTML: true,
  51350. modules: modules$1,
  51351. directives: directives$1,
  51352. isPreTag: isPreTag,
  51353. isUnaryTag: isUnaryTag,
  51354. mustUseProp: mustUseProp,
  51355. canBeLeftOpenTag: canBeLeftOpenTag,
  51356. isReservedTag: isReservedTag,
  51357. getTagNamespace: getTagNamespace,
  51358. staticKeys: genStaticKeys(modules$1)
  51359. };
  51360. /* */
  51361. var isStaticKey;
  51362. var isPlatformReservedTag;
  51363. var genStaticKeysCached = cached(genStaticKeys$1);
  51364. /**
  51365. * Goal of the optimizer: walk the generated template AST tree
  51366. * and detect sub-trees that are purely static, i.e. parts of
  51367. * the DOM that never needs to change.
  51368. *
  51369. * Once we detect these sub-trees, we can:
  51370. *
  51371. * 1. Hoist them into constants, so that we no longer need to
  51372. * create fresh nodes for them on each re-render;
  51373. * 2. Completely skip them in the patching process.
  51374. */
  51375. function optimize (root, options) {
  51376. if (!root) { return }
  51377. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51378. isPlatformReservedTag = options.isReservedTag || no;
  51379. // first pass: mark all non-static nodes.
  51380. markStatic$1(root);
  51381. // second pass: mark static roots.
  51382. markStaticRoots(root, false);
  51383. }
  51384. function genStaticKeys$1 (keys) {
  51385. return makeMap(
  51386. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51387. (keys ? ',' + keys : '')
  51388. )
  51389. }
  51390. function markStatic$1 (node) {
  51391. node.static = isStatic(node);
  51392. if (node.type === 1) {
  51393. // do not make component slot content static. this avoids
  51394. // 1. components not able to mutate slot nodes
  51395. // 2. static slot content fails for hot-reloading
  51396. if (
  51397. !isPlatformReservedTag(node.tag) &&
  51398. node.tag !== 'slot' &&
  51399. node.attrsMap['inline-template'] == null
  51400. ) {
  51401. return
  51402. }
  51403. for (var i = 0, l = node.children.length; i < l; i++) {
  51404. var child = node.children[i];
  51405. markStatic$1(child);
  51406. if (!child.static) {
  51407. node.static = false;
  51408. }
  51409. }
  51410. if (node.ifConditions) {
  51411. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51412. var block = node.ifConditions[i$1].block;
  51413. markStatic$1(block);
  51414. if (!block.static) {
  51415. node.static = false;
  51416. }
  51417. }
  51418. }
  51419. }
  51420. }
  51421. function markStaticRoots (node, isInFor) {
  51422. if (node.type === 1) {
  51423. if (node.static || node.once) {
  51424. node.staticInFor = isInFor;
  51425. }
  51426. // For a node to qualify as a static root, it should have children that
  51427. // are not just static text. Otherwise the cost of hoisting out will
  51428. // outweigh the benefits and it's better off to just always render it fresh.
  51429. if (node.static && node.children.length && !(
  51430. node.children.length === 1 &&
  51431. node.children[0].type === 3
  51432. )) {
  51433. node.staticRoot = true;
  51434. return
  51435. } else {
  51436. node.staticRoot = false;
  51437. }
  51438. if (node.children) {
  51439. for (var i = 0, l = node.children.length; i < l; i++) {
  51440. markStaticRoots(node.children[i], isInFor || !!node.for);
  51441. }
  51442. }
  51443. if (node.ifConditions) {
  51444. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51445. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51446. }
  51447. }
  51448. }
  51449. }
  51450. function isStatic (node) {
  51451. if (node.type === 2) { // expression
  51452. return false
  51453. }
  51454. if (node.type === 3) { // text
  51455. return true
  51456. }
  51457. return !!(node.pre || (
  51458. !node.hasBindings && // no dynamic bindings
  51459. !node.if && !node.for && // not v-if or v-for or v-else
  51460. !isBuiltInTag(node.tag) && // not a built-in
  51461. isPlatformReservedTag(node.tag) && // not a component
  51462. !isDirectChildOfTemplateFor(node) &&
  51463. Object.keys(node).every(isStaticKey)
  51464. ))
  51465. }
  51466. function isDirectChildOfTemplateFor (node) {
  51467. while (node.parent) {
  51468. node = node.parent;
  51469. if (node.tag !== 'template') {
  51470. return false
  51471. }
  51472. if (node.for) {
  51473. return true
  51474. }
  51475. }
  51476. return false
  51477. }
  51478. /* */
  51479. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51480. var fnInvokeRE = /\([^)]*?\);*$/;
  51481. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51482. // KeyboardEvent.keyCode aliases
  51483. var keyCodes = {
  51484. esc: 27,
  51485. tab: 9,
  51486. enter: 13,
  51487. space: 32,
  51488. up: 38,
  51489. left: 37,
  51490. right: 39,
  51491. down: 40,
  51492. 'delete': [8, 46]
  51493. };
  51494. // KeyboardEvent.key aliases
  51495. var keyNames = {
  51496. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51497. esc: ['Esc', 'Escape'],
  51498. tab: 'Tab',
  51499. enter: 'Enter',
  51500. // #9112: IE11 uses `Spacebar` for Space key name.
  51501. space: [' ', 'Spacebar'],
  51502. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51503. up: ['Up', 'ArrowUp'],
  51504. left: ['Left', 'ArrowLeft'],
  51505. right: ['Right', 'ArrowRight'],
  51506. down: ['Down', 'ArrowDown'],
  51507. // #9112: IE11 uses `Del` for Delete key name.
  51508. 'delete': ['Backspace', 'Delete', 'Del']
  51509. };
  51510. // #4868: modifiers that prevent the execution of the listener
  51511. // need to explicitly return null so that we can determine whether to remove
  51512. // the listener for .once
  51513. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51514. var modifierCode = {
  51515. stop: '$event.stopPropagation();',
  51516. prevent: '$event.preventDefault();',
  51517. self: genGuard("$event.target !== $event.currentTarget"),
  51518. ctrl: genGuard("!$event.ctrlKey"),
  51519. shift: genGuard("!$event.shiftKey"),
  51520. alt: genGuard("!$event.altKey"),
  51521. meta: genGuard("!$event.metaKey"),
  51522. left: genGuard("'button' in $event && $event.button !== 0"),
  51523. middle: genGuard("'button' in $event && $event.button !== 1"),
  51524. right: genGuard("'button' in $event && $event.button !== 2")
  51525. };
  51526. function genHandlers (
  51527. events,
  51528. isNative
  51529. ) {
  51530. var prefix = isNative ? 'nativeOn:' : 'on:';
  51531. var staticHandlers = "";
  51532. var dynamicHandlers = "";
  51533. for (var name in events) {
  51534. var handlerCode = genHandler(events[name]);
  51535. if (events[name] && events[name].dynamic) {
  51536. dynamicHandlers += name + "," + handlerCode + ",";
  51537. } else {
  51538. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51539. }
  51540. }
  51541. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51542. if (dynamicHandlers) {
  51543. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51544. } else {
  51545. return prefix + staticHandlers
  51546. }
  51547. }
  51548. function genHandler (handler) {
  51549. if (!handler) {
  51550. return 'function(){}'
  51551. }
  51552. if (Array.isArray(handler)) {
  51553. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51554. }
  51555. var isMethodPath = simplePathRE.test(handler.value);
  51556. var isFunctionExpression = fnExpRE.test(handler.value);
  51557. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51558. if (!handler.modifiers) {
  51559. if (isMethodPath || isFunctionExpression) {
  51560. return handler.value
  51561. }
  51562. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51563. } else {
  51564. var code = '';
  51565. var genModifierCode = '';
  51566. var keys = [];
  51567. for (var key in handler.modifiers) {
  51568. if (modifierCode[key]) {
  51569. genModifierCode += modifierCode[key];
  51570. // left/right
  51571. if (keyCodes[key]) {
  51572. keys.push(key);
  51573. }
  51574. } else if (key === 'exact') {
  51575. var modifiers = (handler.modifiers);
  51576. genModifierCode += genGuard(
  51577. ['ctrl', 'shift', 'alt', 'meta']
  51578. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51579. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51580. .join('||')
  51581. );
  51582. } else {
  51583. keys.push(key);
  51584. }
  51585. }
  51586. if (keys.length) {
  51587. code += genKeyFilter(keys);
  51588. }
  51589. // Make sure modifiers like prevent and stop get executed after key filtering
  51590. if (genModifierCode) {
  51591. code += genModifierCode;
  51592. }
  51593. var handlerCode = isMethodPath
  51594. ? ("return " + (handler.value) + "($event)")
  51595. : isFunctionExpression
  51596. ? ("return (" + (handler.value) + ")($event)")
  51597. : isFunctionInvocation
  51598. ? ("return " + (handler.value))
  51599. : handler.value;
  51600. return ("function($event){" + code + handlerCode + "}")
  51601. }
  51602. }
  51603. function genKeyFilter (keys) {
  51604. return (
  51605. // make sure the key filters only apply to KeyboardEvents
  51606. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51607. // key events that do not have keyCode property...
  51608. "if(!$event.type.indexOf('key')&&" +
  51609. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51610. )
  51611. }
  51612. function genFilterCode (key) {
  51613. var keyVal = parseInt(key, 10);
  51614. if (keyVal) {
  51615. return ("$event.keyCode!==" + keyVal)
  51616. }
  51617. var keyCode = keyCodes[key];
  51618. var keyName = keyNames[key];
  51619. return (
  51620. "_k($event.keyCode," +
  51621. (JSON.stringify(key)) + "," +
  51622. (JSON.stringify(keyCode)) + "," +
  51623. "$event.key," +
  51624. "" + (JSON.stringify(keyName)) +
  51625. ")"
  51626. )
  51627. }
  51628. /* */
  51629. function on (el, dir) {
  51630. if (dir.modifiers) {
  51631. warn("v-on without argument does not support modifiers.");
  51632. }
  51633. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51634. }
  51635. /* */
  51636. function bind$1 (el, dir) {
  51637. el.wrapData = function (code) {
  51638. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51639. };
  51640. }
  51641. /* */
  51642. var baseDirectives = {
  51643. on: on,
  51644. bind: bind$1,
  51645. cloak: noop
  51646. };
  51647. /* */
  51648. var CodegenState = function CodegenState (options) {
  51649. this.options = options;
  51650. this.warn = options.warn || baseWarn;
  51651. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51652. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51653. this.directives = extend(extend({}, baseDirectives), options.directives);
  51654. var isReservedTag = options.isReservedTag || no;
  51655. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51656. this.onceId = 0;
  51657. this.staticRenderFns = [];
  51658. this.pre = false;
  51659. };
  51660. function generate (
  51661. ast,
  51662. options
  51663. ) {
  51664. var state = new CodegenState(options);
  51665. var code = ast ? genElement(ast, state) : '_c("div")';
  51666. return {
  51667. render: ("with(this){return " + code + "}"),
  51668. staticRenderFns: state.staticRenderFns
  51669. }
  51670. }
  51671. function genElement (el, state) {
  51672. if (el.parent) {
  51673. el.pre = el.pre || el.parent.pre;
  51674. }
  51675. if (el.staticRoot && !el.staticProcessed) {
  51676. return genStatic(el, state)
  51677. } else if (el.once && !el.onceProcessed) {
  51678. return genOnce(el, state)
  51679. } else if (el.for && !el.forProcessed) {
  51680. return genFor(el, state)
  51681. } else if (el.if && !el.ifProcessed) {
  51682. return genIf(el, state)
  51683. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51684. return genChildren(el, state) || 'void 0'
  51685. } else if (el.tag === 'slot') {
  51686. return genSlot(el, state)
  51687. } else {
  51688. // component or element
  51689. var code;
  51690. if (el.component) {
  51691. code = genComponent(el.component, el, state);
  51692. } else {
  51693. var data;
  51694. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51695. data = genData$2(el, state);
  51696. }
  51697. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51698. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51699. }
  51700. // module transforms
  51701. for (var i = 0; i < state.transforms.length; i++) {
  51702. code = state.transforms[i](el, code);
  51703. }
  51704. return code
  51705. }
  51706. }
  51707. // hoist static sub-trees out
  51708. function genStatic (el, state) {
  51709. el.staticProcessed = true;
  51710. // Some elements (templates) need to behave differently inside of a v-pre
  51711. // node. All pre nodes are static roots, so we can use this as a location to
  51712. // wrap a state change and reset it upon exiting the pre node.
  51713. var originalPreState = state.pre;
  51714. if (el.pre) {
  51715. state.pre = el.pre;
  51716. }
  51717. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51718. state.pre = originalPreState;
  51719. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51720. }
  51721. // v-once
  51722. function genOnce (el, state) {
  51723. el.onceProcessed = true;
  51724. if (el.if && !el.ifProcessed) {
  51725. return genIf(el, state)
  51726. } else if (el.staticInFor) {
  51727. var key = '';
  51728. var parent = el.parent;
  51729. while (parent) {
  51730. if (parent.for) {
  51731. key = parent.key;
  51732. break
  51733. }
  51734. parent = parent.parent;
  51735. }
  51736. if (!key) {
  51737. state.warn(
  51738. "v-once can only be used inside v-for that is keyed. ",
  51739. el.rawAttrsMap['v-once']
  51740. );
  51741. return genElement(el, state)
  51742. }
  51743. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51744. } else {
  51745. return genStatic(el, state)
  51746. }
  51747. }
  51748. function genIf (
  51749. el,
  51750. state,
  51751. altGen,
  51752. altEmpty
  51753. ) {
  51754. el.ifProcessed = true; // avoid recursion
  51755. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51756. }
  51757. function genIfConditions (
  51758. conditions,
  51759. state,
  51760. altGen,
  51761. altEmpty
  51762. ) {
  51763. if (!conditions.length) {
  51764. return altEmpty || '_e()'
  51765. }
  51766. var condition = conditions.shift();
  51767. if (condition.exp) {
  51768. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51769. } else {
  51770. return ("" + (genTernaryExp(condition.block)))
  51771. }
  51772. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51773. function genTernaryExp (el) {
  51774. return altGen
  51775. ? altGen(el, state)
  51776. : el.once
  51777. ? genOnce(el, state)
  51778. : genElement(el, state)
  51779. }
  51780. }
  51781. function genFor (
  51782. el,
  51783. state,
  51784. altGen,
  51785. altHelper
  51786. ) {
  51787. var exp = el.for;
  51788. var alias = el.alias;
  51789. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51790. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51791. if (state.maybeComponent(el) &&
  51792. el.tag !== 'slot' &&
  51793. el.tag !== 'template' &&
  51794. !el.key
  51795. ) {
  51796. state.warn(
  51797. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51798. "v-for should have explicit keys. " +
  51799. "See https://vuejs.org/guide/list.html#key for more info.",
  51800. el.rawAttrsMap['v-for'],
  51801. true /* tip */
  51802. );
  51803. }
  51804. el.forProcessed = true; // avoid recursion
  51805. return (altHelper || '_l') + "((" + exp + ")," +
  51806. "function(" + alias + iterator1 + iterator2 + "){" +
  51807. "return " + ((altGen || genElement)(el, state)) +
  51808. '})'
  51809. }
  51810. function genData$2 (el, state) {
  51811. var data = '{';
  51812. // directives first.
  51813. // directives may mutate the el's other properties before they are generated.
  51814. var dirs = genDirectives(el, state);
  51815. if (dirs) { data += dirs + ','; }
  51816. // key
  51817. if (el.key) {
  51818. data += "key:" + (el.key) + ",";
  51819. }
  51820. // ref
  51821. if (el.ref) {
  51822. data += "ref:" + (el.ref) + ",";
  51823. }
  51824. if (el.refInFor) {
  51825. data += "refInFor:true,";
  51826. }
  51827. // pre
  51828. if (el.pre) {
  51829. data += "pre:true,";
  51830. }
  51831. // record original tag name for components using "is" attribute
  51832. if (el.component) {
  51833. data += "tag:\"" + (el.tag) + "\",";
  51834. }
  51835. // module data generation functions
  51836. for (var i = 0; i < state.dataGenFns.length; i++) {
  51837. data += state.dataGenFns[i](el);
  51838. }
  51839. // attributes
  51840. if (el.attrs) {
  51841. data += "attrs:" + (genProps(el.attrs)) + ",";
  51842. }
  51843. // DOM props
  51844. if (el.props) {
  51845. data += "domProps:" + (genProps(el.props)) + ",";
  51846. }
  51847. // event handlers
  51848. if (el.events) {
  51849. data += (genHandlers(el.events, false)) + ",";
  51850. }
  51851. if (el.nativeEvents) {
  51852. data += (genHandlers(el.nativeEvents, true)) + ",";
  51853. }
  51854. // slot target
  51855. // only for non-scoped slots
  51856. if (el.slotTarget && !el.slotScope) {
  51857. data += "slot:" + (el.slotTarget) + ",";
  51858. }
  51859. // scoped slots
  51860. if (el.scopedSlots) {
  51861. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  51862. }
  51863. // component v-model
  51864. if (el.model) {
  51865. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  51866. }
  51867. // inline-template
  51868. if (el.inlineTemplate) {
  51869. var inlineTemplate = genInlineTemplate(el, state);
  51870. if (inlineTemplate) {
  51871. data += inlineTemplate + ",";
  51872. }
  51873. }
  51874. data = data.replace(/,$/, '') + '}';
  51875. // v-bind dynamic argument wrap
  51876. // v-bind with dynamic arguments must be applied using the same v-bind object
  51877. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  51878. if (el.dynamicAttrs) {
  51879. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  51880. }
  51881. // v-bind data wrap
  51882. if (el.wrapData) {
  51883. data = el.wrapData(data);
  51884. }
  51885. // v-on data wrap
  51886. if (el.wrapListeners) {
  51887. data = el.wrapListeners(data);
  51888. }
  51889. return data
  51890. }
  51891. function genDirectives (el, state) {
  51892. var dirs = el.directives;
  51893. if (!dirs) { return }
  51894. var res = 'directives:[';
  51895. var hasRuntime = false;
  51896. var i, l, dir, needRuntime;
  51897. for (i = 0, l = dirs.length; i < l; i++) {
  51898. dir = dirs[i];
  51899. needRuntime = true;
  51900. var gen = state.directives[dir.name];
  51901. if (gen) {
  51902. // compile-time directive that manipulates AST.
  51903. // returns true if it also needs a runtime counterpart.
  51904. needRuntime = !!gen(el, dir, state.warn);
  51905. }
  51906. if (needRuntime) {
  51907. hasRuntime = true;
  51908. 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))) : '') + "},";
  51909. }
  51910. }
  51911. if (hasRuntime) {
  51912. return res.slice(0, -1) + ']'
  51913. }
  51914. }
  51915. function genInlineTemplate (el, state) {
  51916. var ast = el.children[0];
  51917. if (el.children.length !== 1 || ast.type !== 1) {
  51918. state.warn(
  51919. 'Inline-template components must have exactly one child element.',
  51920. { start: el.start }
  51921. );
  51922. }
  51923. if (ast && ast.type === 1) {
  51924. var inlineRenderFns = generate(ast, state.options);
  51925. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  51926. }
  51927. }
  51928. function genScopedSlots (
  51929. el,
  51930. slots,
  51931. state
  51932. ) {
  51933. // by default scoped slots are considered "stable", this allows child
  51934. // components with only scoped slots to skip forced updates from parent.
  51935. // but in some cases we have to bail-out of this optimization
  51936. // for example if the slot contains dynamic names, has v-if or v-for on them...
  51937. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  51938. var slot = slots[key];
  51939. return (
  51940. slot.slotTargetDynamic ||
  51941. slot.if ||
  51942. slot.for ||
  51943. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  51944. )
  51945. });
  51946. // #9534: if a component with scoped slots is inside a conditional branch,
  51947. // it's possible for the same component to be reused but with different
  51948. // compiled slot content. To avoid that, we generate a unique key based on
  51949. // the generated code of all the slot contents.
  51950. var needsKey = !!el.if;
  51951. // OR when it is inside another scoped slot or v-for (the reactivity may be
  51952. // disconnected due to the intermediate scope variable)
  51953. // #9438, #9506
  51954. // TODO: this can be further optimized by properly analyzing in-scope bindings
  51955. // and skip force updating ones that do not actually use scope variables.
  51956. if (!needsForceUpdate) {
  51957. var parent = el.parent;
  51958. while (parent) {
  51959. if (
  51960. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  51961. parent.for
  51962. ) {
  51963. needsForceUpdate = true;
  51964. break
  51965. }
  51966. if (parent.if) {
  51967. needsKey = true;
  51968. }
  51969. parent = parent.parent;
  51970. }
  51971. }
  51972. var generatedSlots = Object.keys(slots)
  51973. .map(function (key) { return genScopedSlot(slots[key], state); })
  51974. .join(',');
  51975. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  51976. }
  51977. function hash(str) {
  51978. var hash = 5381;
  51979. var i = str.length;
  51980. while(i) {
  51981. hash = (hash * 33) ^ str.charCodeAt(--i);
  51982. }
  51983. return hash >>> 0
  51984. }
  51985. function containsSlotChild (el) {
  51986. if (el.type === 1) {
  51987. if (el.tag === 'slot') {
  51988. return true
  51989. }
  51990. return el.children.some(containsSlotChild)
  51991. }
  51992. return false
  51993. }
  51994. function genScopedSlot (
  51995. el,
  51996. state
  51997. ) {
  51998. var isLegacySyntax = el.attrsMap['slot-scope'];
  51999. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  52000. return genIf(el, state, genScopedSlot, "null")
  52001. }
  52002. if (el.for && !el.forProcessed) {
  52003. return genFor(el, state, genScopedSlot)
  52004. }
  52005. var slotScope = el.slotScope === emptySlotScopeToken
  52006. ? ""
  52007. : String(el.slotScope);
  52008. var fn = "function(" + slotScope + "){" +
  52009. "return " + (el.tag === 'template'
  52010. ? el.if && isLegacySyntax
  52011. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  52012. : genChildren(el, state) || 'undefined'
  52013. : genElement(el, state)) + "}";
  52014. // reverse proxy v-slot without scope on this.$slots
  52015. var reverseProxy = slotScope ? "" : ",proxy:true";
  52016. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  52017. }
  52018. function genChildren (
  52019. el,
  52020. state,
  52021. checkSkip,
  52022. altGenElement,
  52023. altGenNode
  52024. ) {
  52025. var children = el.children;
  52026. if (children.length) {
  52027. var el$1 = children[0];
  52028. // optimize single v-for
  52029. if (children.length === 1 &&
  52030. el$1.for &&
  52031. el$1.tag !== 'template' &&
  52032. el$1.tag !== 'slot'
  52033. ) {
  52034. var normalizationType = checkSkip
  52035. ? state.maybeComponent(el$1) ? ",1" : ",0"
  52036. : "";
  52037. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  52038. }
  52039. var normalizationType$1 = checkSkip
  52040. ? getNormalizationType(children, state.maybeComponent)
  52041. : 0;
  52042. var gen = altGenNode || genNode;
  52043. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  52044. }
  52045. }
  52046. // determine the normalization needed for the children array.
  52047. // 0: no normalization needed
  52048. // 1: simple normalization needed (possible 1-level deep nested array)
  52049. // 2: full normalization needed
  52050. function getNormalizationType (
  52051. children,
  52052. maybeComponent
  52053. ) {
  52054. var res = 0;
  52055. for (var i = 0; i < children.length; i++) {
  52056. var el = children[i];
  52057. if (el.type !== 1) {
  52058. continue
  52059. }
  52060. if (needsNormalization(el) ||
  52061. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  52062. res = 2;
  52063. break
  52064. }
  52065. if (maybeComponent(el) ||
  52066. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  52067. res = 1;
  52068. }
  52069. }
  52070. return res
  52071. }
  52072. function needsNormalization (el) {
  52073. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  52074. }
  52075. function genNode (node, state) {
  52076. if (node.type === 1) {
  52077. return genElement(node, state)
  52078. } else if (node.type === 3 && node.isComment) {
  52079. return genComment(node)
  52080. } else {
  52081. return genText(node)
  52082. }
  52083. }
  52084. function genText (text) {
  52085. return ("_v(" + (text.type === 2
  52086. ? text.expression // no need for () because already wrapped in _s()
  52087. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  52088. }
  52089. function genComment (comment) {
  52090. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52091. }
  52092. function genSlot (el, state) {
  52093. var slotName = el.slotName || '"default"';
  52094. var children = genChildren(el, state);
  52095. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52096. var attrs = el.attrs || el.dynamicAttrs
  52097. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52098. // slot props are camelized
  52099. name: camelize(attr.name),
  52100. value: attr.value,
  52101. dynamic: attr.dynamic
  52102. }); }))
  52103. : null;
  52104. var bind$$1 = el.attrsMap['v-bind'];
  52105. if ((attrs || bind$$1) && !children) {
  52106. res += ",null";
  52107. }
  52108. if (attrs) {
  52109. res += "," + attrs;
  52110. }
  52111. if (bind$$1) {
  52112. res += (attrs ? '' : ',null') + "," + bind$$1;
  52113. }
  52114. return res + ')'
  52115. }
  52116. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52117. function genComponent (
  52118. componentName,
  52119. el,
  52120. state
  52121. ) {
  52122. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52123. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52124. }
  52125. function genProps (props) {
  52126. var staticProps = "";
  52127. var dynamicProps = "";
  52128. for (var i = 0; i < props.length; i++) {
  52129. var prop = props[i];
  52130. var value = transformSpecialNewlines(prop.value);
  52131. if (prop.dynamic) {
  52132. dynamicProps += (prop.name) + "," + value + ",";
  52133. } else {
  52134. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52135. }
  52136. }
  52137. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52138. if (dynamicProps) {
  52139. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52140. } else {
  52141. return staticProps
  52142. }
  52143. }
  52144. // #3895, #4268
  52145. function transformSpecialNewlines (text) {
  52146. return text
  52147. .replace(/\u2028/g, '\\u2028')
  52148. .replace(/\u2029/g, '\\u2029')
  52149. }
  52150. /* */
  52151. // these keywords should not appear inside expressions, but operators like
  52152. // typeof, instanceof and in are allowed
  52153. var prohibitedKeywordRE = new RegExp('\\b' + (
  52154. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52155. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52156. 'extends,finally,continue,debugger,function,arguments'
  52157. ).split(',').join('\\b|\\b') + '\\b');
  52158. // these unary operators should not be used as property/method names
  52159. var unaryOperatorsRE = new RegExp('\\b' + (
  52160. 'delete,typeof,void'
  52161. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52162. // strip strings in expressions
  52163. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52164. // detect problematic expressions in a template
  52165. function detectErrors (ast, warn) {
  52166. if (ast) {
  52167. checkNode(ast, warn);
  52168. }
  52169. }
  52170. function checkNode (node, warn) {
  52171. if (node.type === 1) {
  52172. for (var name in node.attrsMap) {
  52173. if (dirRE.test(name)) {
  52174. var value = node.attrsMap[name];
  52175. if (value) {
  52176. var range = node.rawAttrsMap[name];
  52177. if (name === 'v-for') {
  52178. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52179. } else if (name === 'v-slot' || name[0] === '#') {
  52180. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52181. } else if (onRE.test(name)) {
  52182. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52183. } else {
  52184. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52185. }
  52186. }
  52187. }
  52188. }
  52189. if (node.children) {
  52190. for (var i = 0; i < node.children.length; i++) {
  52191. checkNode(node.children[i], warn);
  52192. }
  52193. }
  52194. } else if (node.type === 2) {
  52195. checkExpression(node.expression, node.text, warn, node);
  52196. }
  52197. }
  52198. function checkEvent (exp, text, warn, range) {
  52199. var stripped = exp.replace(stripStringRE, '');
  52200. var keywordMatch = stripped.match(unaryOperatorsRE);
  52201. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52202. warn(
  52203. "avoid using JavaScript unary operator as property name: " +
  52204. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52205. range
  52206. );
  52207. }
  52208. checkExpression(exp, text, warn, range);
  52209. }
  52210. function checkFor (node, text, warn, range) {
  52211. checkExpression(node.for || '', text, warn, range);
  52212. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52213. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52214. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52215. }
  52216. function checkIdentifier (
  52217. ident,
  52218. type,
  52219. text,
  52220. warn,
  52221. range
  52222. ) {
  52223. if (typeof ident === 'string') {
  52224. try {
  52225. new Function(("var " + ident + "=_"));
  52226. } catch (e) {
  52227. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52228. }
  52229. }
  52230. }
  52231. function checkExpression (exp, text, warn, range) {
  52232. try {
  52233. new Function(("return " + exp));
  52234. } catch (e) {
  52235. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52236. if (keywordMatch) {
  52237. warn(
  52238. "avoid using JavaScript keyword as property name: " +
  52239. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52240. range
  52241. );
  52242. } else {
  52243. warn(
  52244. "invalid expression: " + (e.message) + " in\n\n" +
  52245. " " + exp + "\n\n" +
  52246. " Raw expression: " + (text.trim()) + "\n",
  52247. range
  52248. );
  52249. }
  52250. }
  52251. }
  52252. function checkFunctionParameterExpression (exp, text, warn, range) {
  52253. try {
  52254. new Function(exp, '');
  52255. } catch (e) {
  52256. warn(
  52257. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52258. " " + exp + "\n\n" +
  52259. " Raw expression: " + (text.trim()) + "\n",
  52260. range
  52261. );
  52262. }
  52263. }
  52264. /* */
  52265. var range = 2;
  52266. function generateCodeFrame (
  52267. source,
  52268. start,
  52269. end
  52270. ) {
  52271. if ( start === void 0 ) start = 0;
  52272. if ( end === void 0 ) end = source.length;
  52273. var lines = source.split(/\r?\n/);
  52274. var count = 0;
  52275. var res = [];
  52276. for (var i = 0; i < lines.length; i++) {
  52277. count += lines[i].length + 1;
  52278. if (count >= start) {
  52279. for (var j = i - range; j <= i + range || end > count; j++) {
  52280. if (j < 0 || j >= lines.length) { continue }
  52281. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52282. var lineLength = lines[j].length;
  52283. if (j === i) {
  52284. // push underline
  52285. var pad = start - (count - lineLength) + 1;
  52286. var length = end > count ? lineLength - pad : end - start;
  52287. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52288. } else if (j > i) {
  52289. if (end > count) {
  52290. var length$1 = Math.min(end - count, lineLength);
  52291. res.push(" | " + repeat$1("^", length$1));
  52292. }
  52293. count += lineLength + 1;
  52294. }
  52295. }
  52296. break
  52297. }
  52298. }
  52299. return res.join('\n')
  52300. }
  52301. function repeat$1 (str, n) {
  52302. var result = '';
  52303. if (n > 0) {
  52304. while (true) { // eslint-disable-line
  52305. if (n & 1) { result += str; }
  52306. n >>>= 1;
  52307. if (n <= 0) { break }
  52308. str += str;
  52309. }
  52310. }
  52311. return result
  52312. }
  52313. /* */
  52314. function createFunction (code, errors) {
  52315. try {
  52316. return new Function(code)
  52317. } catch (err) {
  52318. errors.push({ err: err, code: code });
  52319. return noop
  52320. }
  52321. }
  52322. function createCompileToFunctionFn (compile) {
  52323. var cache = Object.create(null);
  52324. return function compileToFunctions (
  52325. template,
  52326. options,
  52327. vm
  52328. ) {
  52329. options = extend({}, options);
  52330. var warn$$1 = options.warn || warn;
  52331. delete options.warn;
  52332. /* istanbul ignore if */
  52333. {
  52334. // detect possible CSP restriction
  52335. try {
  52336. new Function('return 1');
  52337. } catch (e) {
  52338. if (e.toString().match(/unsafe-eval|CSP/)) {
  52339. warn$$1(
  52340. 'It seems you are using the standalone build of Vue.js in an ' +
  52341. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52342. 'The template compiler cannot work in this environment. Consider ' +
  52343. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52344. 'templates into render functions.'
  52345. );
  52346. }
  52347. }
  52348. }
  52349. // check cache
  52350. var key = options.delimiters
  52351. ? String(options.delimiters) + template
  52352. : template;
  52353. if (cache[key]) {
  52354. return cache[key]
  52355. }
  52356. // compile
  52357. var compiled = compile(template, options);
  52358. // check compilation errors/tips
  52359. {
  52360. if (compiled.errors && compiled.errors.length) {
  52361. if (options.outputSourceRange) {
  52362. compiled.errors.forEach(function (e) {
  52363. warn$$1(
  52364. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52365. generateCodeFrame(template, e.start, e.end),
  52366. vm
  52367. );
  52368. });
  52369. } else {
  52370. warn$$1(
  52371. "Error compiling template:\n\n" + template + "\n\n" +
  52372. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52373. vm
  52374. );
  52375. }
  52376. }
  52377. if (compiled.tips && compiled.tips.length) {
  52378. if (options.outputSourceRange) {
  52379. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52380. } else {
  52381. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52382. }
  52383. }
  52384. }
  52385. // turn code into functions
  52386. var res = {};
  52387. var fnGenErrors = [];
  52388. res.render = createFunction(compiled.render, fnGenErrors);
  52389. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52390. return createFunction(code, fnGenErrors)
  52391. });
  52392. // check function generation errors.
  52393. // this should only happen if there is a bug in the compiler itself.
  52394. // mostly for codegen development use
  52395. /* istanbul ignore if */
  52396. {
  52397. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52398. warn$$1(
  52399. "Failed to generate render function:\n\n" +
  52400. fnGenErrors.map(function (ref) {
  52401. var err = ref.err;
  52402. var code = ref.code;
  52403. return ((err.toString()) + " in\n\n" + code + "\n");
  52404. }).join('\n'),
  52405. vm
  52406. );
  52407. }
  52408. }
  52409. return (cache[key] = res)
  52410. }
  52411. }
  52412. /* */
  52413. function createCompilerCreator (baseCompile) {
  52414. return function createCompiler (baseOptions) {
  52415. function compile (
  52416. template,
  52417. options
  52418. ) {
  52419. var finalOptions = Object.create(baseOptions);
  52420. var errors = [];
  52421. var tips = [];
  52422. var warn = function (msg, range, tip) {
  52423. (tip ? tips : errors).push(msg);
  52424. };
  52425. if (options) {
  52426. if (options.outputSourceRange) {
  52427. // $flow-disable-line
  52428. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52429. warn = function (msg, range, tip) {
  52430. var data = { msg: msg };
  52431. if (range) {
  52432. if (range.start != null) {
  52433. data.start = range.start + leadingSpaceLength;
  52434. }
  52435. if (range.end != null) {
  52436. data.end = range.end + leadingSpaceLength;
  52437. }
  52438. }
  52439. (tip ? tips : errors).push(data);
  52440. };
  52441. }
  52442. // merge custom modules
  52443. if (options.modules) {
  52444. finalOptions.modules =
  52445. (baseOptions.modules || []).concat(options.modules);
  52446. }
  52447. // merge custom directives
  52448. if (options.directives) {
  52449. finalOptions.directives = extend(
  52450. Object.create(baseOptions.directives || null),
  52451. options.directives
  52452. );
  52453. }
  52454. // copy other options
  52455. for (var key in options) {
  52456. if (key !== 'modules' && key !== 'directives') {
  52457. finalOptions[key] = options[key];
  52458. }
  52459. }
  52460. }
  52461. finalOptions.warn = warn;
  52462. var compiled = baseCompile(template.trim(), finalOptions);
  52463. {
  52464. detectErrors(compiled.ast, warn);
  52465. }
  52466. compiled.errors = errors;
  52467. compiled.tips = tips;
  52468. return compiled
  52469. }
  52470. return {
  52471. compile: compile,
  52472. compileToFunctions: createCompileToFunctionFn(compile)
  52473. }
  52474. }
  52475. }
  52476. /* */
  52477. // `createCompilerCreator` allows creating compilers that use alternative
  52478. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52479. // Here we just export a default compiler using the default parts.
  52480. var createCompiler = createCompilerCreator(function baseCompile (
  52481. template,
  52482. options
  52483. ) {
  52484. var ast = parse(template.trim(), options);
  52485. if (options.optimize !== false) {
  52486. optimize(ast, options);
  52487. }
  52488. var code = generate(ast, options);
  52489. return {
  52490. ast: ast,
  52491. render: code.render,
  52492. staticRenderFns: code.staticRenderFns
  52493. }
  52494. });
  52495. /* */
  52496. var ref$1 = createCompiler(baseOptions);
  52497. var compile = ref$1.compile;
  52498. var compileToFunctions = ref$1.compileToFunctions;
  52499. /* */
  52500. // check whether current browser encodes a char inside attribute values
  52501. var div;
  52502. function getShouldDecode (href) {
  52503. div = div || document.createElement('div');
  52504. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52505. return div.innerHTML.indexOf('&#10;') > 0
  52506. }
  52507. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52508. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52509. // #6828: chrome encodes content in a[href]
  52510. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52511. /* */
  52512. var idToTemplate = cached(function (id) {
  52513. var el = query(id);
  52514. return el && el.innerHTML
  52515. });
  52516. var mount = Vue.prototype.$mount;
  52517. Vue.prototype.$mount = function (
  52518. el,
  52519. hydrating
  52520. ) {
  52521. el = el && query(el);
  52522. /* istanbul ignore if */
  52523. if (el === document.body || el === document.documentElement) {
  52524. warn(
  52525. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52526. );
  52527. return this
  52528. }
  52529. var options = this.$options;
  52530. // resolve template/el and convert to render function
  52531. if (!options.render) {
  52532. var template = options.template;
  52533. if (template) {
  52534. if (typeof template === 'string') {
  52535. if (template.charAt(0) === '#') {
  52536. template = idToTemplate(template);
  52537. /* istanbul ignore if */
  52538. if (!template) {
  52539. warn(
  52540. ("Template element not found or is empty: " + (options.template)),
  52541. this
  52542. );
  52543. }
  52544. }
  52545. } else if (template.nodeType) {
  52546. template = template.innerHTML;
  52547. } else {
  52548. {
  52549. warn('invalid template option:' + template, this);
  52550. }
  52551. return this
  52552. }
  52553. } else if (el) {
  52554. template = getOuterHTML(el);
  52555. }
  52556. if (template) {
  52557. /* istanbul ignore if */
  52558. if (config.performance && mark) {
  52559. mark('compile');
  52560. }
  52561. var ref = compileToFunctions(template, {
  52562. outputSourceRange: "development" !== 'production',
  52563. shouldDecodeNewlines: shouldDecodeNewlines,
  52564. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52565. delimiters: options.delimiters,
  52566. comments: options.comments
  52567. }, this);
  52568. var render = ref.render;
  52569. var staticRenderFns = ref.staticRenderFns;
  52570. options.render = render;
  52571. options.staticRenderFns = staticRenderFns;
  52572. /* istanbul ignore if */
  52573. if (config.performance && mark) {
  52574. mark('compile end');
  52575. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52576. }
  52577. }
  52578. }
  52579. return mount.call(this, el, hydrating)
  52580. };
  52581. /**
  52582. * Get outerHTML of elements, taking care
  52583. * of SVG elements in IE as well.
  52584. */
  52585. function getOuterHTML (el) {
  52586. if (el.outerHTML) {
  52587. return el.outerHTML
  52588. } else {
  52589. var container = document.createElement('div');
  52590. container.appendChild(el.cloneNode(true));
  52591. return container.innerHTML
  52592. }
  52593. }
  52594. Vue.compile = compileToFunctions;
  52595. module.exports = Vue;
  52596. /* 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))
  52597. /***/ }),
  52598. /***/ "./node_modules/vue/dist/vue.common.js":
  52599. /*!*********************************************!*\
  52600. !*** ./node_modules/vue/dist/vue.common.js ***!
  52601. \*********************************************/
  52602. /*! no static exports found */
  52603. /***/ (function(module, exports, __webpack_require__) {
  52604. if (false) {} else {
  52605. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52606. }
  52607. /***/ }),
  52608. /***/ "./node_modules/webpack/buildin/global.js":
  52609. /*!***********************************!*\
  52610. !*** (webpack)/buildin/global.js ***!
  52611. \***********************************/
  52612. /*! no static exports found */
  52613. /***/ (function(module, exports) {
  52614. var g;
  52615. // This works in non-strict mode
  52616. g = (function() {
  52617. return this;
  52618. })();
  52619. try {
  52620. // This works if eval is allowed (see CSP)
  52621. g = g || new Function("return this")();
  52622. } catch (e) {
  52623. // This works if the window reference is available
  52624. if (typeof window === "object") g = window;
  52625. }
  52626. // g can still be undefined, but nothing to do about it...
  52627. // We return undefined, instead of nothing here, so it's
  52628. // easier to handle this case. if(!global) { ...}
  52629. module.exports = g;
  52630. /***/ }),
  52631. /***/ "./node_modules/webpack/buildin/module.js":
  52632. /*!***********************************!*\
  52633. !*** (webpack)/buildin/module.js ***!
  52634. \***********************************/
  52635. /*! no static exports found */
  52636. /***/ (function(module, exports) {
  52637. module.exports = function(module) {
  52638. if (!module.webpackPolyfill) {
  52639. module.deprecate = function() {};
  52640. module.paths = [];
  52641. // module.parent = undefined by default
  52642. if (!module.children) module.children = [];
  52643. Object.defineProperty(module, "loaded", {
  52644. enumerable: true,
  52645. get: function() {
  52646. return module.l;
  52647. }
  52648. });
  52649. Object.defineProperty(module, "id", {
  52650. enumerable: true,
  52651. get: function() {
  52652. return module.i;
  52653. }
  52654. });
  52655. module.webpackPolyfill = 1;
  52656. }
  52657. return module;
  52658. };
  52659. /***/ }),
  52660. /***/ "./resources/js/app.js":
  52661. /*!*****************************!*\
  52662. !*** ./resources/js/app.js ***!
  52663. \*****************************/
  52664. /*! no static exports found */
  52665. /***/ (function(module, exports, __webpack_require__) {
  52666. /**
  52667. * First we will load all of this project's JavaScript dependencies which
  52668. * includes Vue and other libraries. It is a great starting point when
  52669. * building robust, powerful web applications using Vue and Laravel.
  52670. */
  52671. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52672. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52673. /**
  52674. * The following block of code may be used to automatically register your
  52675. * Vue components. It will recursively scan this directory for the Vue
  52676. * components and automatically register them with their "basename".
  52677. *
  52678. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52679. */
  52680. // const files = require.context('./', true, /\.vue$/i)
  52681. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52682. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52683. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  52684. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  52685. /**
  52686. * Next, we will create a fresh Vue application instance and attach it to
  52687. * the page. Then, you may begin adding components to this application
  52688. * or customize the JavaScript scaffolding to fit your unique needs.
  52689. */
  52690. var app = new Vue({
  52691. el: '#app'
  52692. });
  52693. /***/ }),
  52694. /***/ "./resources/js/bootstrap.js":
  52695. /*!***********************************!*\
  52696. !*** ./resources/js/bootstrap.js ***!
  52697. \***********************************/
  52698. /*! no exports provided */
  52699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52700. "use strict";
  52701. __webpack_require__.r(__webpack_exports__);
  52702. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52703. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52704. /**
  52705. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52706. * for JavaScript based Bootstrap features such as modals and tabs. This
  52707. * code may be modified to fit the specific needs of your application.
  52708. */
  52709. try {
  52710. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52711. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52712. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52713. } catch (e) {}
  52714. /**
  52715. * We'll load the axios HTTP library which allows us to easily issue requests
  52716. * to our Laravel back-end. This library automatically handles sending the
  52717. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52718. */
  52719. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52720. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52721. /**
  52722. * Echo exposes an expressive API for subscribing to channels and listening
  52723. * for events that are broadcast by Laravel. Echo and event broadcasting
  52724. * allows your team to easily build robust real-time web applications.
  52725. */
  52726. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52727. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52728. broadcaster: 'pusher',
  52729. key: "upccrt",
  52730. wsHost: window.location.hostname,
  52731. wsPort: 6001,
  52732. disableStats: true
  52733. });
  52734. /***/ }),
  52735. /***/ "./resources/js/components/ExampleComponent.vue":
  52736. /*!******************************************************!*\
  52737. !*** ./resources/js/components/ExampleComponent.vue ***!
  52738. \******************************************************/
  52739. /*! exports provided: default */
  52740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52741. "use strict";
  52742. __webpack_require__.r(__webpack_exports__);
  52743. /* 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&");
  52744. /* 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&");
  52745. /* 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");
  52746. /* normalize component */
  52747. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52748. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52749. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52750. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52751. false,
  52752. null,
  52753. null,
  52754. null
  52755. )
  52756. /* hot reload */
  52757. if (false) { var api; }
  52758. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52759. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52760. /***/ }),
  52761. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52762. /*!*******************************************************************************!*\
  52763. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52764. \*******************************************************************************/
  52765. /*! exports provided: default */
  52766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52767. "use strict";
  52768. __webpack_require__.r(__webpack_exports__);
  52769. /* 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&");
  52770. /* 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"]);
  52771. /***/ }),
  52772. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52773. /*!*************************************************************************************!*\
  52774. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52775. \*************************************************************************************/
  52776. /*! exports provided: render, staticRenderFns */
  52777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52778. "use strict";
  52779. __webpack_require__.r(__webpack_exports__);
  52780. /* 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&");
  52781. /* 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"]; });
  52782. /* 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"]; });
  52783. /***/ }),
  52784. /***/ "./resources/js/components/assetinfo.vue":
  52785. /*!***********************************************!*\
  52786. !*** ./resources/js/components/assetinfo.vue ***!
  52787. \***********************************************/
  52788. /*! exports provided: default */
  52789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52790. "use strict";
  52791. __webpack_require__.r(__webpack_exports__);
  52792. /* harmony import */ var _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  52793. /* harmony import */ var _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  52794. /* 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");
  52795. /* normalize component */
  52796. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52797. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52798. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  52799. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52800. false,
  52801. null,
  52802. null,
  52803. null
  52804. )
  52805. /* hot reload */
  52806. if (false) { var api; }
  52807. component.options.__file = "resources/js/components/assetinfo.vue"
  52808. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52809. /***/ }),
  52810. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  52811. /*!************************************************************************!*\
  52812. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  52813. \************************************************************************/
  52814. /*! exports provided: default */
  52815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52816. "use strict";
  52817. __webpack_require__.r(__webpack_exports__);
  52818. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_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!./assetinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  52819. /* 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_assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52820. /***/ }),
  52821. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  52822. /*!******************************************************************************!*\
  52823. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  52824. \******************************************************************************/
  52825. /*! exports provided: render, staticRenderFns */
  52826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52827. "use strict";
  52828. __webpack_require__.r(__webpack_exports__);
  52829. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___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!./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  52830. /* 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_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52831. /* 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_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52832. /***/ }),
  52833. /***/ "./resources/js/components/woinfo.vue":
  52834. /*!********************************************!*\
  52835. !*** ./resources/js/components/woinfo.vue ***!
  52836. \********************************************/
  52837. /*! exports provided: default */
  52838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52839. "use strict";
  52840. __webpack_require__.r(__webpack_exports__);
  52841. /* harmony import */ var _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./woinfo.vue?vue&type=template&id=33ce32de& */ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  52842. /* harmony import */ var _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./woinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  52843. /* 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");
  52844. /* normalize component */
  52845. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52846. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52847. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  52848. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52849. false,
  52850. null,
  52851. null,
  52852. null
  52853. )
  52854. /* hot reload */
  52855. if (false) { var api; }
  52856. component.options.__file = "resources/js/components/woinfo.vue"
  52857. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52858. /***/ }),
  52859. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  52860. /*!*********************************************************************!*\
  52861. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  52862. \*********************************************************************/
  52863. /*! exports provided: default */
  52864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52865. "use strict";
  52866. __webpack_require__.r(__webpack_exports__);
  52867. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_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!./woinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  52868. /* 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_woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52869. /***/ }),
  52870. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  52871. /*!***************************************************************************!*\
  52872. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  52873. \***************************************************************************/
  52874. /*! exports provided: render, staticRenderFns */
  52875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52876. "use strict";
  52877. __webpack_require__.r(__webpack_exports__);
  52878. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___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!./woinfo.vue?vue&type=template&id=33ce32de& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  52879. /* 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_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52880. /* 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_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52881. /***/ }),
  52882. /***/ "./resources/sass/app.scss":
  52883. /*!*********************************!*\
  52884. !*** ./resources/sass/app.scss ***!
  52885. \*********************************/
  52886. /*! no static exports found */
  52887. /***/ (function(module, exports) {
  52888. // removed by extract-text-webpack-plugin
  52889. /***/ }),
  52890. /***/ 0:
  52891. /*!*************************************************************!*\
  52892. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  52893. \*************************************************************/
  52894. /*! no static exports found */
  52895. /***/ (function(module, exports, __webpack_require__) {
  52896. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  52897. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  52898. /***/ })
  52899. /******/ });