app.js 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934
  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. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1641. //
  1642. //
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. //
  1653. //
  1654. //
  1655. //
  1656. //
  1657. //
  1658. //
  1659. //
  1660. /* harmony default export */ __webpack_exports__["default"] = ({
  1661. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1662. props: ['workOrder'],
  1663. data: function data() {
  1664. return {
  1665. data: JSON.parse(this.workOrder)
  1666. };
  1667. },
  1668. mounted: function mounted() {
  1669. var _this = this;
  1670. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1671. _this.data = JSON.parse(e.data);
  1672. });
  1673. }
  1674. });
  1675. /***/ }),
  1676. /***/ "./node_modules/base64-js/index.js":
  1677. /*!*****************************************!*\
  1678. !*** ./node_modules/base64-js/index.js ***!
  1679. \*****************************************/
  1680. /*! no static exports found */
  1681. /***/ (function(module, exports, __webpack_require__) {
  1682. "use strict";
  1683. exports.byteLength = byteLength
  1684. exports.toByteArray = toByteArray
  1685. exports.fromByteArray = fromByteArray
  1686. var lookup = []
  1687. var revLookup = []
  1688. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1689. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1690. for (var i = 0, len = code.length; i < len; ++i) {
  1691. lookup[i] = code[i]
  1692. revLookup[code.charCodeAt(i)] = i
  1693. }
  1694. // Support decoding URL-safe base64 strings, as Node.js does.
  1695. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1696. revLookup['-'.charCodeAt(0)] = 62
  1697. revLookup['_'.charCodeAt(0)] = 63
  1698. function getLens (b64) {
  1699. var len = b64.length
  1700. if (len % 4 > 0) {
  1701. throw new Error('Invalid string. Length must be a multiple of 4')
  1702. }
  1703. // Trim off extra bytes after placeholder bytes are found
  1704. // See: https://github.com/beatgammit/base64-js/issues/42
  1705. var validLen = b64.indexOf('=')
  1706. if (validLen === -1) validLen = len
  1707. var placeHoldersLen = validLen === len
  1708. ? 0
  1709. : 4 - (validLen % 4)
  1710. return [validLen, placeHoldersLen]
  1711. }
  1712. // base64 is 4/3 + up to two characters of the original data
  1713. function byteLength (b64) {
  1714. var lens = getLens(b64)
  1715. var validLen = lens[0]
  1716. var placeHoldersLen = lens[1]
  1717. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1718. }
  1719. function _byteLength (b64, validLen, placeHoldersLen) {
  1720. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1721. }
  1722. function toByteArray (b64) {
  1723. var tmp
  1724. var lens = getLens(b64)
  1725. var validLen = lens[0]
  1726. var placeHoldersLen = lens[1]
  1727. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1728. var curByte = 0
  1729. // if there are placeholders, only get up to the last complete 4 chars
  1730. var len = placeHoldersLen > 0
  1731. ? validLen - 4
  1732. : validLen
  1733. var i
  1734. for (i = 0; i < len; i += 4) {
  1735. tmp =
  1736. (revLookup[b64.charCodeAt(i)] << 18) |
  1737. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1738. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1739. revLookup[b64.charCodeAt(i + 3)]
  1740. arr[curByte++] = (tmp >> 16) & 0xFF
  1741. arr[curByte++] = (tmp >> 8) & 0xFF
  1742. arr[curByte++] = tmp & 0xFF
  1743. }
  1744. if (placeHoldersLen === 2) {
  1745. tmp =
  1746. (revLookup[b64.charCodeAt(i)] << 2) |
  1747. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1748. arr[curByte++] = tmp & 0xFF
  1749. }
  1750. if (placeHoldersLen === 1) {
  1751. tmp =
  1752. (revLookup[b64.charCodeAt(i)] << 10) |
  1753. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1754. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1755. arr[curByte++] = (tmp >> 8) & 0xFF
  1756. arr[curByte++] = tmp & 0xFF
  1757. }
  1758. return arr
  1759. }
  1760. function tripletToBase64 (num) {
  1761. return lookup[num >> 18 & 0x3F] +
  1762. lookup[num >> 12 & 0x3F] +
  1763. lookup[num >> 6 & 0x3F] +
  1764. lookup[num & 0x3F]
  1765. }
  1766. function encodeChunk (uint8, start, end) {
  1767. var tmp
  1768. var output = []
  1769. for (var i = start; i < end; i += 3) {
  1770. tmp =
  1771. ((uint8[i] << 16) & 0xFF0000) +
  1772. ((uint8[i + 1] << 8) & 0xFF00) +
  1773. (uint8[i + 2] & 0xFF)
  1774. output.push(tripletToBase64(tmp))
  1775. }
  1776. return output.join('')
  1777. }
  1778. function fromByteArray (uint8) {
  1779. var tmp
  1780. var len = uint8.length
  1781. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1782. var parts = []
  1783. var maxChunkLength = 16383 // must be multiple of 3
  1784. // go through the array every three bytes, we'll deal with trailing stuff later
  1785. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1786. parts.push(encodeChunk(
  1787. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1788. ))
  1789. }
  1790. // pad the end with zeros, but make sure to not forget the extra bytes
  1791. if (extraBytes === 1) {
  1792. tmp = uint8[len - 1]
  1793. parts.push(
  1794. lookup[tmp >> 2] +
  1795. lookup[(tmp << 4) & 0x3F] +
  1796. '=='
  1797. )
  1798. } else if (extraBytes === 2) {
  1799. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1800. parts.push(
  1801. lookup[tmp >> 10] +
  1802. lookup[(tmp >> 4) & 0x3F] +
  1803. lookup[(tmp << 2) & 0x3F] +
  1804. '='
  1805. )
  1806. }
  1807. return parts.join('')
  1808. }
  1809. /***/ }),
  1810. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1811. /*!*****************************************************!*\
  1812. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1813. \*****************************************************/
  1814. /*! no static exports found */
  1815. /***/ (function(module, exports, __webpack_require__) {
  1816. /*!
  1817. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1818. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1819. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1820. */
  1821. (function (global, factory) {
  1822. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1823. undefined;
  1824. }(this, (function (exports, $, Popper) { 'use strict';
  1825. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1826. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1827. function _defineProperties(target, props) {
  1828. for (var i = 0; i < props.length; i++) {
  1829. var descriptor = props[i];
  1830. descriptor.enumerable = descriptor.enumerable || false;
  1831. descriptor.configurable = true;
  1832. if ("value" in descriptor) descriptor.writable = true;
  1833. Object.defineProperty(target, descriptor.key, descriptor);
  1834. }
  1835. }
  1836. function _createClass(Constructor, protoProps, staticProps) {
  1837. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1838. if (staticProps) _defineProperties(Constructor, staticProps);
  1839. return Constructor;
  1840. }
  1841. function _defineProperty(obj, key, value) {
  1842. if (key in obj) {
  1843. Object.defineProperty(obj, key, {
  1844. value: value,
  1845. enumerable: true,
  1846. configurable: true,
  1847. writable: true
  1848. });
  1849. } else {
  1850. obj[key] = value;
  1851. }
  1852. return obj;
  1853. }
  1854. function ownKeys(object, enumerableOnly) {
  1855. var keys = Object.keys(object);
  1856. if (Object.getOwnPropertySymbols) {
  1857. var symbols = Object.getOwnPropertySymbols(object);
  1858. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1859. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1860. });
  1861. keys.push.apply(keys, symbols);
  1862. }
  1863. return keys;
  1864. }
  1865. function _objectSpread2(target) {
  1866. for (var i = 1; i < arguments.length; i++) {
  1867. var source = arguments[i] != null ? arguments[i] : {};
  1868. if (i % 2) {
  1869. ownKeys(Object(source), true).forEach(function (key) {
  1870. _defineProperty(target, key, source[key]);
  1871. });
  1872. } else if (Object.getOwnPropertyDescriptors) {
  1873. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1874. } else {
  1875. ownKeys(Object(source)).forEach(function (key) {
  1876. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1877. });
  1878. }
  1879. }
  1880. return target;
  1881. }
  1882. function _inheritsLoose(subClass, superClass) {
  1883. subClass.prototype = Object.create(superClass.prototype);
  1884. subClass.prototype.constructor = subClass;
  1885. subClass.__proto__ = superClass;
  1886. }
  1887. /**
  1888. * --------------------------------------------------------------------------
  1889. * Bootstrap (v4.4.1): util.js
  1890. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1891. * --------------------------------------------------------------------------
  1892. */
  1893. /**
  1894. * ------------------------------------------------------------------------
  1895. * Private TransitionEnd Helpers
  1896. * ------------------------------------------------------------------------
  1897. */
  1898. var TRANSITION_END = 'transitionend';
  1899. var MAX_UID = 1000000;
  1900. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1901. function toType(obj) {
  1902. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1903. }
  1904. function getSpecialTransitionEndEvent() {
  1905. return {
  1906. bindType: TRANSITION_END,
  1907. delegateType: TRANSITION_END,
  1908. handle: function handle(event) {
  1909. if ($(event.target).is(this)) {
  1910. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1911. }
  1912. return undefined; // eslint-disable-line no-undefined
  1913. }
  1914. };
  1915. }
  1916. function transitionEndEmulator(duration) {
  1917. var _this = this;
  1918. var called = false;
  1919. $(this).one(Util.TRANSITION_END, function () {
  1920. called = true;
  1921. });
  1922. setTimeout(function () {
  1923. if (!called) {
  1924. Util.triggerTransitionEnd(_this);
  1925. }
  1926. }, duration);
  1927. return this;
  1928. }
  1929. function setTransitionEndSupport() {
  1930. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1931. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1932. }
  1933. /**
  1934. * --------------------------------------------------------------------------
  1935. * Public Util Api
  1936. * --------------------------------------------------------------------------
  1937. */
  1938. var Util = {
  1939. TRANSITION_END: 'bsTransitionEnd',
  1940. getUID: function getUID(prefix) {
  1941. do {
  1942. // eslint-disable-next-line no-bitwise
  1943. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1944. } while (document.getElementById(prefix));
  1945. return prefix;
  1946. },
  1947. getSelectorFromElement: function getSelectorFromElement(element) {
  1948. var selector = element.getAttribute('data-target');
  1949. if (!selector || selector === '#') {
  1950. var hrefAttr = element.getAttribute('href');
  1951. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1952. }
  1953. try {
  1954. return document.querySelector(selector) ? selector : null;
  1955. } catch (err) {
  1956. return null;
  1957. }
  1958. },
  1959. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1960. if (!element) {
  1961. return 0;
  1962. } // Get transition-duration of the element
  1963. var transitionDuration = $(element).css('transition-duration');
  1964. var transitionDelay = $(element).css('transition-delay');
  1965. var floatTransitionDuration = parseFloat(transitionDuration);
  1966. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1967. if (!floatTransitionDuration && !floatTransitionDelay) {
  1968. return 0;
  1969. } // If multiple durations are defined, take the first
  1970. transitionDuration = transitionDuration.split(',')[0];
  1971. transitionDelay = transitionDelay.split(',')[0];
  1972. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1973. },
  1974. reflow: function reflow(element) {
  1975. return element.offsetHeight;
  1976. },
  1977. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1978. $(element).trigger(TRANSITION_END);
  1979. },
  1980. // TODO: Remove in v5
  1981. supportsTransitionEnd: function supportsTransitionEnd() {
  1982. return Boolean(TRANSITION_END);
  1983. },
  1984. isElement: function isElement(obj) {
  1985. return (obj[0] || obj).nodeType;
  1986. },
  1987. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1988. for (var property in configTypes) {
  1989. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1990. var expectedTypes = configTypes[property];
  1991. var value = config[property];
  1992. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1993. if (!new RegExp(expectedTypes).test(valueType)) {
  1994. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1995. }
  1996. }
  1997. }
  1998. },
  1999. findShadowRoot: function findShadowRoot(element) {
  2000. if (!document.documentElement.attachShadow) {
  2001. return null;
  2002. } // Can find the shadow root otherwise it'll return the document
  2003. if (typeof element.getRootNode === 'function') {
  2004. var root = element.getRootNode();
  2005. return root instanceof ShadowRoot ? root : null;
  2006. }
  2007. if (element instanceof ShadowRoot) {
  2008. return element;
  2009. } // when we don't find a shadow root
  2010. if (!element.parentNode) {
  2011. return null;
  2012. }
  2013. return Util.findShadowRoot(element.parentNode);
  2014. },
  2015. jQueryDetection: function jQueryDetection() {
  2016. if (typeof $ === 'undefined') {
  2017. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2018. }
  2019. var version = $.fn.jquery.split(' ')[0].split('.');
  2020. var minMajor = 1;
  2021. var ltMajor = 2;
  2022. var minMinor = 9;
  2023. var minPatch = 1;
  2024. var maxMajor = 4;
  2025. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2026. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2027. }
  2028. }
  2029. };
  2030. Util.jQueryDetection();
  2031. setTransitionEndSupport();
  2032. /**
  2033. * ------------------------------------------------------------------------
  2034. * Constants
  2035. * ------------------------------------------------------------------------
  2036. */
  2037. var NAME = 'alert';
  2038. var VERSION = '4.4.1';
  2039. var DATA_KEY = 'bs.alert';
  2040. var EVENT_KEY = "." + DATA_KEY;
  2041. var DATA_API_KEY = '.data-api';
  2042. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2043. var Selector = {
  2044. DISMISS: '[data-dismiss="alert"]'
  2045. };
  2046. var Event = {
  2047. CLOSE: "close" + EVENT_KEY,
  2048. CLOSED: "closed" + EVENT_KEY,
  2049. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2050. };
  2051. var ClassName = {
  2052. ALERT: 'alert',
  2053. FADE: 'fade',
  2054. SHOW: 'show'
  2055. };
  2056. /**
  2057. * ------------------------------------------------------------------------
  2058. * Class Definition
  2059. * ------------------------------------------------------------------------
  2060. */
  2061. var Alert =
  2062. /*#__PURE__*/
  2063. function () {
  2064. function Alert(element) {
  2065. this._element = element;
  2066. } // Getters
  2067. var _proto = Alert.prototype;
  2068. // Public
  2069. _proto.close = function close(element) {
  2070. var rootElement = this._element;
  2071. if (element) {
  2072. rootElement = this._getRootElement(element);
  2073. }
  2074. var customEvent = this._triggerCloseEvent(rootElement);
  2075. if (customEvent.isDefaultPrevented()) {
  2076. return;
  2077. }
  2078. this._removeElement(rootElement);
  2079. };
  2080. _proto.dispose = function dispose() {
  2081. $.removeData(this._element, DATA_KEY);
  2082. this._element = null;
  2083. } // Private
  2084. ;
  2085. _proto._getRootElement = function _getRootElement(element) {
  2086. var selector = Util.getSelectorFromElement(element);
  2087. var parent = false;
  2088. if (selector) {
  2089. parent = document.querySelector(selector);
  2090. }
  2091. if (!parent) {
  2092. parent = $(element).closest("." + ClassName.ALERT)[0];
  2093. }
  2094. return parent;
  2095. };
  2096. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2097. var closeEvent = $.Event(Event.CLOSE);
  2098. $(element).trigger(closeEvent);
  2099. return closeEvent;
  2100. };
  2101. _proto._removeElement = function _removeElement(element) {
  2102. var _this = this;
  2103. $(element).removeClass(ClassName.SHOW);
  2104. if (!$(element).hasClass(ClassName.FADE)) {
  2105. this._destroyElement(element);
  2106. return;
  2107. }
  2108. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2109. $(element).one(Util.TRANSITION_END, function (event) {
  2110. return _this._destroyElement(element, event);
  2111. }).emulateTransitionEnd(transitionDuration);
  2112. };
  2113. _proto._destroyElement = function _destroyElement(element) {
  2114. $(element).detach().trigger(Event.CLOSED).remove();
  2115. } // Static
  2116. ;
  2117. Alert._jQueryInterface = function _jQueryInterface(config) {
  2118. return this.each(function () {
  2119. var $element = $(this);
  2120. var data = $element.data(DATA_KEY);
  2121. if (!data) {
  2122. data = new Alert(this);
  2123. $element.data(DATA_KEY, data);
  2124. }
  2125. if (config === 'close') {
  2126. data[config](this);
  2127. }
  2128. });
  2129. };
  2130. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2131. return function (event) {
  2132. if (event) {
  2133. event.preventDefault();
  2134. }
  2135. alertInstance.close(this);
  2136. };
  2137. };
  2138. _createClass(Alert, null, [{
  2139. key: "VERSION",
  2140. get: function get() {
  2141. return VERSION;
  2142. }
  2143. }]);
  2144. return Alert;
  2145. }();
  2146. /**
  2147. * ------------------------------------------------------------------------
  2148. * Data Api implementation
  2149. * ------------------------------------------------------------------------
  2150. */
  2151. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2152. /**
  2153. * ------------------------------------------------------------------------
  2154. * jQuery
  2155. * ------------------------------------------------------------------------
  2156. */
  2157. $.fn[NAME] = Alert._jQueryInterface;
  2158. $.fn[NAME].Constructor = Alert;
  2159. $.fn[NAME].noConflict = function () {
  2160. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2161. return Alert._jQueryInterface;
  2162. };
  2163. /**
  2164. * ------------------------------------------------------------------------
  2165. * Constants
  2166. * ------------------------------------------------------------------------
  2167. */
  2168. var NAME$1 = 'button';
  2169. var VERSION$1 = '4.4.1';
  2170. var DATA_KEY$1 = 'bs.button';
  2171. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2172. var DATA_API_KEY$1 = '.data-api';
  2173. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2174. var ClassName$1 = {
  2175. ACTIVE: 'active',
  2176. BUTTON: 'btn',
  2177. FOCUS: 'focus'
  2178. };
  2179. var Selector$1 = {
  2180. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2181. DATA_TOGGLES: '[data-toggle="buttons"]',
  2182. DATA_TOGGLE: '[data-toggle="button"]',
  2183. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2184. INPUT: 'input:not([type="hidden"])',
  2185. ACTIVE: '.active',
  2186. BUTTON: '.btn'
  2187. };
  2188. var Event$1 = {
  2189. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2190. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2191. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2192. };
  2193. /**
  2194. * ------------------------------------------------------------------------
  2195. * Class Definition
  2196. * ------------------------------------------------------------------------
  2197. */
  2198. var Button =
  2199. /*#__PURE__*/
  2200. function () {
  2201. function Button(element) {
  2202. this._element = element;
  2203. } // Getters
  2204. var _proto = Button.prototype;
  2205. // Public
  2206. _proto.toggle = function toggle() {
  2207. var triggerChangeEvent = true;
  2208. var addAriaPressed = true;
  2209. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2210. if (rootElement) {
  2211. var input = this._element.querySelector(Selector$1.INPUT);
  2212. if (input) {
  2213. if (input.type === 'radio') {
  2214. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2215. triggerChangeEvent = false;
  2216. } else {
  2217. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2218. if (activeElement) {
  2219. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2220. }
  2221. }
  2222. } else if (input.type === 'checkbox') {
  2223. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2224. triggerChangeEvent = false;
  2225. }
  2226. } else {
  2227. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2228. triggerChangeEvent = false;
  2229. }
  2230. if (triggerChangeEvent) {
  2231. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2232. $(input).trigger('change');
  2233. }
  2234. input.focus();
  2235. addAriaPressed = false;
  2236. }
  2237. }
  2238. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2239. if (addAriaPressed) {
  2240. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2241. }
  2242. if (triggerChangeEvent) {
  2243. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2244. }
  2245. }
  2246. };
  2247. _proto.dispose = function dispose() {
  2248. $.removeData(this._element, DATA_KEY$1);
  2249. this._element = null;
  2250. } // Static
  2251. ;
  2252. Button._jQueryInterface = function _jQueryInterface(config) {
  2253. return this.each(function () {
  2254. var data = $(this).data(DATA_KEY$1);
  2255. if (!data) {
  2256. data = new Button(this);
  2257. $(this).data(DATA_KEY$1, data);
  2258. }
  2259. if (config === 'toggle') {
  2260. data[config]();
  2261. }
  2262. });
  2263. };
  2264. _createClass(Button, null, [{
  2265. key: "VERSION",
  2266. get: function get() {
  2267. return VERSION$1;
  2268. }
  2269. }]);
  2270. return Button;
  2271. }();
  2272. /**
  2273. * ------------------------------------------------------------------------
  2274. * Data Api implementation
  2275. * ------------------------------------------------------------------------
  2276. */
  2277. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2278. var button = event.target;
  2279. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2280. button = $(button).closest(Selector$1.BUTTON)[0];
  2281. }
  2282. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2283. event.preventDefault(); // work around Firefox bug #1540995
  2284. } else {
  2285. var inputBtn = button.querySelector(Selector$1.INPUT);
  2286. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2287. event.preventDefault(); // work around Firefox bug #1540995
  2288. return;
  2289. }
  2290. Button._jQueryInterface.call($(button), 'toggle');
  2291. }
  2292. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2293. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2294. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2295. });
  2296. $(window).on(Event$1.LOAD_DATA_API, function () {
  2297. // ensure correct active class is set to match the controls' actual values/states
  2298. // find all checkboxes/readio buttons inside data-toggle groups
  2299. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2300. for (var i = 0, len = buttons.length; i < len; i++) {
  2301. var button = buttons[i];
  2302. var input = button.querySelector(Selector$1.INPUT);
  2303. if (input.checked || input.hasAttribute('checked')) {
  2304. button.classList.add(ClassName$1.ACTIVE);
  2305. } else {
  2306. button.classList.remove(ClassName$1.ACTIVE);
  2307. }
  2308. } // find all button toggles
  2309. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2310. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2311. var _button = buttons[_i];
  2312. if (_button.getAttribute('aria-pressed') === 'true') {
  2313. _button.classList.add(ClassName$1.ACTIVE);
  2314. } else {
  2315. _button.classList.remove(ClassName$1.ACTIVE);
  2316. }
  2317. }
  2318. });
  2319. /**
  2320. * ------------------------------------------------------------------------
  2321. * jQuery
  2322. * ------------------------------------------------------------------------
  2323. */
  2324. $.fn[NAME$1] = Button._jQueryInterface;
  2325. $.fn[NAME$1].Constructor = Button;
  2326. $.fn[NAME$1].noConflict = function () {
  2327. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2328. return Button._jQueryInterface;
  2329. };
  2330. /**
  2331. * ------------------------------------------------------------------------
  2332. * Constants
  2333. * ------------------------------------------------------------------------
  2334. */
  2335. var NAME$2 = 'carousel';
  2336. var VERSION$2 = '4.4.1';
  2337. var DATA_KEY$2 = 'bs.carousel';
  2338. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2339. var DATA_API_KEY$2 = '.data-api';
  2340. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2341. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2342. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2343. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2344. var SWIPE_THRESHOLD = 40;
  2345. var Default = {
  2346. interval: 5000,
  2347. keyboard: true,
  2348. slide: false,
  2349. pause: 'hover',
  2350. wrap: true,
  2351. touch: true
  2352. };
  2353. var DefaultType = {
  2354. interval: '(number|boolean)',
  2355. keyboard: 'boolean',
  2356. slide: '(boolean|string)',
  2357. pause: '(string|boolean)',
  2358. wrap: 'boolean',
  2359. touch: 'boolean'
  2360. };
  2361. var Direction = {
  2362. NEXT: 'next',
  2363. PREV: 'prev',
  2364. LEFT: 'left',
  2365. RIGHT: 'right'
  2366. };
  2367. var Event$2 = {
  2368. SLIDE: "slide" + EVENT_KEY$2,
  2369. SLID: "slid" + EVENT_KEY$2,
  2370. KEYDOWN: "keydown" + EVENT_KEY$2,
  2371. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2372. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2373. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2374. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2375. TOUCHEND: "touchend" + EVENT_KEY$2,
  2376. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2377. POINTERUP: "pointerup" + EVENT_KEY$2,
  2378. DRAG_START: "dragstart" + EVENT_KEY$2,
  2379. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2380. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2381. };
  2382. var ClassName$2 = {
  2383. CAROUSEL: 'carousel',
  2384. ACTIVE: 'active',
  2385. SLIDE: 'slide',
  2386. RIGHT: 'carousel-item-right',
  2387. LEFT: 'carousel-item-left',
  2388. NEXT: 'carousel-item-next',
  2389. PREV: 'carousel-item-prev',
  2390. ITEM: 'carousel-item',
  2391. POINTER_EVENT: 'pointer-event'
  2392. };
  2393. var Selector$2 = {
  2394. ACTIVE: '.active',
  2395. ACTIVE_ITEM: '.active.carousel-item',
  2396. ITEM: '.carousel-item',
  2397. ITEM_IMG: '.carousel-item img',
  2398. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2399. INDICATORS: '.carousel-indicators',
  2400. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2401. DATA_RIDE: '[data-ride="carousel"]'
  2402. };
  2403. var PointerType = {
  2404. TOUCH: 'touch',
  2405. PEN: 'pen'
  2406. };
  2407. /**
  2408. * ------------------------------------------------------------------------
  2409. * Class Definition
  2410. * ------------------------------------------------------------------------
  2411. */
  2412. var Carousel =
  2413. /*#__PURE__*/
  2414. function () {
  2415. function Carousel(element, config) {
  2416. this._items = null;
  2417. this._interval = null;
  2418. this._activeElement = null;
  2419. this._isPaused = false;
  2420. this._isSliding = false;
  2421. this.touchTimeout = null;
  2422. this.touchStartX = 0;
  2423. this.touchDeltaX = 0;
  2424. this._config = this._getConfig(config);
  2425. this._element = element;
  2426. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2427. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2428. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2429. this._addEventListeners();
  2430. } // Getters
  2431. var _proto = Carousel.prototype;
  2432. // Public
  2433. _proto.next = function next() {
  2434. if (!this._isSliding) {
  2435. this._slide(Direction.NEXT);
  2436. }
  2437. };
  2438. _proto.nextWhenVisible = function nextWhenVisible() {
  2439. // Don't call next when the page isn't visible
  2440. // or the carousel or its parent isn't visible
  2441. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2442. this.next();
  2443. }
  2444. };
  2445. _proto.prev = function prev() {
  2446. if (!this._isSliding) {
  2447. this._slide(Direction.PREV);
  2448. }
  2449. };
  2450. _proto.pause = function pause(event) {
  2451. if (!event) {
  2452. this._isPaused = true;
  2453. }
  2454. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2455. Util.triggerTransitionEnd(this._element);
  2456. this.cycle(true);
  2457. }
  2458. clearInterval(this._interval);
  2459. this._interval = null;
  2460. };
  2461. _proto.cycle = function cycle(event) {
  2462. if (!event) {
  2463. this._isPaused = false;
  2464. }
  2465. if (this._interval) {
  2466. clearInterval(this._interval);
  2467. this._interval = null;
  2468. }
  2469. if (this._config.interval && !this._isPaused) {
  2470. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2471. }
  2472. };
  2473. _proto.to = function to(index) {
  2474. var _this = this;
  2475. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2476. var activeIndex = this._getItemIndex(this._activeElement);
  2477. if (index > this._items.length - 1 || index < 0) {
  2478. return;
  2479. }
  2480. if (this._isSliding) {
  2481. $(this._element).one(Event$2.SLID, function () {
  2482. return _this.to(index);
  2483. });
  2484. return;
  2485. }
  2486. if (activeIndex === index) {
  2487. this.pause();
  2488. this.cycle();
  2489. return;
  2490. }
  2491. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2492. this._slide(direction, this._items[index]);
  2493. };
  2494. _proto.dispose = function dispose() {
  2495. $(this._element).off(EVENT_KEY$2);
  2496. $.removeData(this._element, DATA_KEY$2);
  2497. this._items = null;
  2498. this._config = null;
  2499. this._element = null;
  2500. this._interval = null;
  2501. this._isPaused = null;
  2502. this._isSliding = null;
  2503. this._activeElement = null;
  2504. this._indicatorsElement = null;
  2505. } // Private
  2506. ;
  2507. _proto._getConfig = function _getConfig(config) {
  2508. config = _objectSpread2({}, Default, {}, config);
  2509. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2510. return config;
  2511. };
  2512. _proto._handleSwipe = function _handleSwipe() {
  2513. var absDeltax = Math.abs(this.touchDeltaX);
  2514. if (absDeltax <= SWIPE_THRESHOLD) {
  2515. return;
  2516. }
  2517. var direction = absDeltax / this.touchDeltaX;
  2518. this.touchDeltaX = 0; // swipe left
  2519. if (direction > 0) {
  2520. this.prev();
  2521. } // swipe right
  2522. if (direction < 0) {
  2523. this.next();
  2524. }
  2525. };
  2526. _proto._addEventListeners = function _addEventListeners() {
  2527. var _this2 = this;
  2528. if (this._config.keyboard) {
  2529. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2530. return _this2._keydown(event);
  2531. });
  2532. }
  2533. if (this._config.pause === 'hover') {
  2534. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2535. return _this2.pause(event);
  2536. }).on(Event$2.MOUSELEAVE, function (event) {
  2537. return _this2.cycle(event);
  2538. });
  2539. }
  2540. if (this._config.touch) {
  2541. this._addTouchEventListeners();
  2542. }
  2543. };
  2544. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2545. var _this3 = this;
  2546. if (!this._touchSupported) {
  2547. return;
  2548. }
  2549. var start = function start(event) {
  2550. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2551. _this3.touchStartX = event.originalEvent.clientX;
  2552. } else if (!_this3._pointerEvent) {
  2553. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2554. }
  2555. };
  2556. var move = function move(event) {
  2557. // ensure swiping with one touch and not pinching
  2558. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2559. _this3.touchDeltaX = 0;
  2560. } else {
  2561. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2562. }
  2563. };
  2564. var end = function end(event) {
  2565. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2566. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2567. }
  2568. _this3._handleSwipe();
  2569. if (_this3._config.pause === 'hover') {
  2570. // If it's a touch-enabled device, mouseenter/leave are fired as
  2571. // part of the mouse compatibility events on first tap - the carousel
  2572. // would stop cycling until user tapped out of it;
  2573. // here, we listen for touchend, explicitly pause the carousel
  2574. // (as if it's the second time we tap on it, mouseenter compat event
  2575. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2576. // events to fire) we explicitly restart cycling
  2577. _this3.pause();
  2578. if (_this3.touchTimeout) {
  2579. clearTimeout(_this3.touchTimeout);
  2580. }
  2581. _this3.touchTimeout = setTimeout(function (event) {
  2582. return _this3.cycle(event);
  2583. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2584. }
  2585. };
  2586. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2587. return e.preventDefault();
  2588. });
  2589. if (this._pointerEvent) {
  2590. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2591. return start(event);
  2592. });
  2593. $(this._element).on(Event$2.POINTERUP, function (event) {
  2594. return end(event);
  2595. });
  2596. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2597. } else {
  2598. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2599. return start(event);
  2600. });
  2601. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2602. return move(event);
  2603. });
  2604. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2605. return end(event);
  2606. });
  2607. }
  2608. };
  2609. _proto._keydown = function _keydown(event) {
  2610. if (/input|textarea/i.test(event.target.tagName)) {
  2611. return;
  2612. }
  2613. switch (event.which) {
  2614. case ARROW_LEFT_KEYCODE:
  2615. event.preventDefault();
  2616. this.prev();
  2617. break;
  2618. case ARROW_RIGHT_KEYCODE:
  2619. event.preventDefault();
  2620. this.next();
  2621. break;
  2622. }
  2623. };
  2624. _proto._getItemIndex = function _getItemIndex(element) {
  2625. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2626. return this._items.indexOf(element);
  2627. };
  2628. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2629. var isNextDirection = direction === Direction.NEXT;
  2630. var isPrevDirection = direction === Direction.PREV;
  2631. var activeIndex = this._getItemIndex(activeElement);
  2632. var lastItemIndex = this._items.length - 1;
  2633. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2634. if (isGoingToWrap && !this._config.wrap) {
  2635. return activeElement;
  2636. }
  2637. var delta = direction === Direction.PREV ? -1 : 1;
  2638. var itemIndex = (activeIndex + delta) % this._items.length;
  2639. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2640. };
  2641. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2642. var targetIndex = this._getItemIndex(relatedTarget);
  2643. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2644. var slideEvent = $.Event(Event$2.SLIDE, {
  2645. relatedTarget: relatedTarget,
  2646. direction: eventDirectionName,
  2647. from: fromIndex,
  2648. to: targetIndex
  2649. });
  2650. $(this._element).trigger(slideEvent);
  2651. return slideEvent;
  2652. };
  2653. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2654. if (this._indicatorsElement) {
  2655. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2656. $(indicators).removeClass(ClassName$2.ACTIVE);
  2657. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2658. if (nextIndicator) {
  2659. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2660. }
  2661. }
  2662. };
  2663. _proto._slide = function _slide(direction, element) {
  2664. var _this4 = this;
  2665. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2666. var activeElementIndex = this._getItemIndex(activeElement);
  2667. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2668. var nextElementIndex = this._getItemIndex(nextElement);
  2669. var isCycling = Boolean(this._interval);
  2670. var directionalClassName;
  2671. var orderClassName;
  2672. var eventDirectionName;
  2673. if (direction === Direction.NEXT) {
  2674. directionalClassName = ClassName$2.LEFT;
  2675. orderClassName = ClassName$2.NEXT;
  2676. eventDirectionName = Direction.LEFT;
  2677. } else {
  2678. directionalClassName = ClassName$2.RIGHT;
  2679. orderClassName = ClassName$2.PREV;
  2680. eventDirectionName = Direction.RIGHT;
  2681. }
  2682. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2683. this._isSliding = false;
  2684. return;
  2685. }
  2686. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2687. if (slideEvent.isDefaultPrevented()) {
  2688. return;
  2689. }
  2690. if (!activeElement || !nextElement) {
  2691. // Some weirdness is happening, so we bail
  2692. return;
  2693. }
  2694. this._isSliding = true;
  2695. if (isCycling) {
  2696. this.pause();
  2697. }
  2698. this._setActiveIndicatorElement(nextElement);
  2699. var slidEvent = $.Event(Event$2.SLID, {
  2700. relatedTarget: nextElement,
  2701. direction: eventDirectionName,
  2702. from: activeElementIndex,
  2703. to: nextElementIndex
  2704. });
  2705. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2706. $(nextElement).addClass(orderClassName);
  2707. Util.reflow(nextElement);
  2708. $(activeElement).addClass(directionalClassName);
  2709. $(nextElement).addClass(directionalClassName);
  2710. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2711. if (nextElementInterval) {
  2712. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2713. this._config.interval = nextElementInterval;
  2714. } else {
  2715. this._config.interval = this._config.defaultInterval || this._config.interval;
  2716. }
  2717. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2718. $(activeElement).one(Util.TRANSITION_END, function () {
  2719. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2720. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2721. _this4._isSliding = false;
  2722. setTimeout(function () {
  2723. return $(_this4._element).trigger(slidEvent);
  2724. }, 0);
  2725. }).emulateTransitionEnd(transitionDuration);
  2726. } else {
  2727. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2728. $(nextElement).addClass(ClassName$2.ACTIVE);
  2729. this._isSliding = false;
  2730. $(this._element).trigger(slidEvent);
  2731. }
  2732. if (isCycling) {
  2733. this.cycle();
  2734. }
  2735. } // Static
  2736. ;
  2737. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2738. return this.each(function () {
  2739. var data = $(this).data(DATA_KEY$2);
  2740. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2741. if (typeof config === 'object') {
  2742. _config = _objectSpread2({}, _config, {}, config);
  2743. }
  2744. var action = typeof config === 'string' ? config : _config.slide;
  2745. if (!data) {
  2746. data = new Carousel(this, _config);
  2747. $(this).data(DATA_KEY$2, data);
  2748. }
  2749. if (typeof config === 'number') {
  2750. data.to(config);
  2751. } else if (typeof action === 'string') {
  2752. if (typeof data[action] === 'undefined') {
  2753. throw new TypeError("No method named \"" + action + "\"");
  2754. }
  2755. data[action]();
  2756. } else if (_config.interval && _config.ride) {
  2757. data.pause();
  2758. data.cycle();
  2759. }
  2760. });
  2761. };
  2762. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2763. var selector = Util.getSelectorFromElement(this);
  2764. if (!selector) {
  2765. return;
  2766. }
  2767. var target = $(selector)[0];
  2768. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2769. return;
  2770. }
  2771. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2772. var slideIndex = this.getAttribute('data-slide-to');
  2773. if (slideIndex) {
  2774. config.interval = false;
  2775. }
  2776. Carousel._jQueryInterface.call($(target), config);
  2777. if (slideIndex) {
  2778. $(target).data(DATA_KEY$2).to(slideIndex);
  2779. }
  2780. event.preventDefault();
  2781. };
  2782. _createClass(Carousel, null, [{
  2783. key: "VERSION",
  2784. get: function get() {
  2785. return VERSION$2;
  2786. }
  2787. }, {
  2788. key: "Default",
  2789. get: function get() {
  2790. return Default;
  2791. }
  2792. }]);
  2793. return Carousel;
  2794. }();
  2795. /**
  2796. * ------------------------------------------------------------------------
  2797. * Data Api implementation
  2798. * ------------------------------------------------------------------------
  2799. */
  2800. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2801. $(window).on(Event$2.LOAD_DATA_API, function () {
  2802. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2803. for (var i = 0, len = carousels.length; i < len; i++) {
  2804. var $carousel = $(carousels[i]);
  2805. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2806. }
  2807. });
  2808. /**
  2809. * ------------------------------------------------------------------------
  2810. * jQuery
  2811. * ------------------------------------------------------------------------
  2812. */
  2813. $.fn[NAME$2] = Carousel._jQueryInterface;
  2814. $.fn[NAME$2].Constructor = Carousel;
  2815. $.fn[NAME$2].noConflict = function () {
  2816. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2817. return Carousel._jQueryInterface;
  2818. };
  2819. /**
  2820. * ------------------------------------------------------------------------
  2821. * Constants
  2822. * ------------------------------------------------------------------------
  2823. */
  2824. var NAME$3 = 'collapse';
  2825. var VERSION$3 = '4.4.1';
  2826. var DATA_KEY$3 = 'bs.collapse';
  2827. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2828. var DATA_API_KEY$3 = '.data-api';
  2829. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2830. var Default$1 = {
  2831. toggle: true,
  2832. parent: ''
  2833. };
  2834. var DefaultType$1 = {
  2835. toggle: 'boolean',
  2836. parent: '(string|element)'
  2837. };
  2838. var Event$3 = {
  2839. SHOW: "show" + EVENT_KEY$3,
  2840. SHOWN: "shown" + EVENT_KEY$3,
  2841. HIDE: "hide" + EVENT_KEY$3,
  2842. HIDDEN: "hidden" + EVENT_KEY$3,
  2843. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2844. };
  2845. var ClassName$3 = {
  2846. SHOW: 'show',
  2847. COLLAPSE: 'collapse',
  2848. COLLAPSING: 'collapsing',
  2849. COLLAPSED: 'collapsed'
  2850. };
  2851. var Dimension = {
  2852. WIDTH: 'width',
  2853. HEIGHT: 'height'
  2854. };
  2855. var Selector$3 = {
  2856. ACTIVES: '.show, .collapsing',
  2857. DATA_TOGGLE: '[data-toggle="collapse"]'
  2858. };
  2859. /**
  2860. * ------------------------------------------------------------------------
  2861. * Class Definition
  2862. * ------------------------------------------------------------------------
  2863. */
  2864. var Collapse =
  2865. /*#__PURE__*/
  2866. function () {
  2867. function Collapse(element, config) {
  2868. this._isTransitioning = false;
  2869. this._element = element;
  2870. this._config = this._getConfig(config);
  2871. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2872. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2873. for (var i = 0, len = toggleList.length; i < len; i++) {
  2874. var elem = toggleList[i];
  2875. var selector = Util.getSelectorFromElement(elem);
  2876. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2877. return foundElem === element;
  2878. });
  2879. if (selector !== null && filterElement.length > 0) {
  2880. this._selector = selector;
  2881. this._triggerArray.push(elem);
  2882. }
  2883. }
  2884. this._parent = this._config.parent ? this._getParent() : null;
  2885. if (!this._config.parent) {
  2886. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2887. }
  2888. if (this._config.toggle) {
  2889. this.toggle();
  2890. }
  2891. } // Getters
  2892. var _proto = Collapse.prototype;
  2893. // Public
  2894. _proto.toggle = function toggle() {
  2895. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2896. this.hide();
  2897. } else {
  2898. this.show();
  2899. }
  2900. };
  2901. _proto.show = function show() {
  2902. var _this = this;
  2903. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2904. return;
  2905. }
  2906. var actives;
  2907. var activesData;
  2908. if (this._parent) {
  2909. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2910. if (typeof _this._config.parent === 'string') {
  2911. return elem.getAttribute('data-parent') === _this._config.parent;
  2912. }
  2913. return elem.classList.contains(ClassName$3.COLLAPSE);
  2914. });
  2915. if (actives.length === 0) {
  2916. actives = null;
  2917. }
  2918. }
  2919. if (actives) {
  2920. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2921. if (activesData && activesData._isTransitioning) {
  2922. return;
  2923. }
  2924. }
  2925. var startEvent = $.Event(Event$3.SHOW);
  2926. $(this._element).trigger(startEvent);
  2927. if (startEvent.isDefaultPrevented()) {
  2928. return;
  2929. }
  2930. if (actives) {
  2931. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2932. if (!activesData) {
  2933. $(actives).data(DATA_KEY$3, null);
  2934. }
  2935. }
  2936. var dimension = this._getDimension();
  2937. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2938. this._element.style[dimension] = 0;
  2939. if (this._triggerArray.length) {
  2940. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2941. }
  2942. this.setTransitioning(true);
  2943. var complete = function complete() {
  2944. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2945. _this._element.style[dimension] = '';
  2946. _this.setTransitioning(false);
  2947. $(_this._element).trigger(Event$3.SHOWN);
  2948. };
  2949. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2950. var scrollSize = "scroll" + capitalizedDimension;
  2951. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2952. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2953. this._element.style[dimension] = this._element[scrollSize] + "px";
  2954. };
  2955. _proto.hide = function hide() {
  2956. var _this2 = this;
  2957. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2958. return;
  2959. }
  2960. var startEvent = $.Event(Event$3.HIDE);
  2961. $(this._element).trigger(startEvent);
  2962. if (startEvent.isDefaultPrevented()) {
  2963. return;
  2964. }
  2965. var dimension = this._getDimension();
  2966. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2967. Util.reflow(this._element);
  2968. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2969. var triggerArrayLength = this._triggerArray.length;
  2970. if (triggerArrayLength > 0) {
  2971. for (var i = 0; i < triggerArrayLength; i++) {
  2972. var trigger = this._triggerArray[i];
  2973. var selector = Util.getSelectorFromElement(trigger);
  2974. if (selector !== null) {
  2975. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2976. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2977. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2978. }
  2979. }
  2980. }
  2981. }
  2982. this.setTransitioning(true);
  2983. var complete = function complete() {
  2984. _this2.setTransitioning(false);
  2985. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2986. };
  2987. this._element.style[dimension] = '';
  2988. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2989. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2990. };
  2991. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2992. this._isTransitioning = isTransitioning;
  2993. };
  2994. _proto.dispose = function dispose() {
  2995. $.removeData(this._element, DATA_KEY$3);
  2996. this._config = null;
  2997. this._parent = null;
  2998. this._element = null;
  2999. this._triggerArray = null;
  3000. this._isTransitioning = null;
  3001. } // Private
  3002. ;
  3003. _proto._getConfig = function _getConfig(config) {
  3004. config = _objectSpread2({}, Default$1, {}, config);
  3005. config.toggle = Boolean(config.toggle); // Coerce string values
  3006. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3007. return config;
  3008. };
  3009. _proto._getDimension = function _getDimension() {
  3010. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3011. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3012. };
  3013. _proto._getParent = function _getParent() {
  3014. var _this3 = this;
  3015. var parent;
  3016. if (Util.isElement(this._config.parent)) {
  3017. parent = this._config.parent; // It's a jQuery object
  3018. if (typeof this._config.parent.jquery !== 'undefined') {
  3019. parent = this._config.parent[0];
  3020. }
  3021. } else {
  3022. parent = document.querySelector(this._config.parent);
  3023. }
  3024. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3025. var children = [].slice.call(parent.querySelectorAll(selector));
  3026. $(children).each(function (i, element) {
  3027. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3028. });
  3029. return parent;
  3030. };
  3031. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3032. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3033. if (triggerArray.length) {
  3034. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3035. }
  3036. } // Static
  3037. ;
  3038. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3039. var selector = Util.getSelectorFromElement(element);
  3040. return selector ? document.querySelector(selector) : null;
  3041. };
  3042. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3043. return this.each(function () {
  3044. var $this = $(this);
  3045. var data = $this.data(DATA_KEY$3);
  3046. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3047. if (!data && _config.toggle && /show|hide/.test(config)) {
  3048. _config.toggle = false;
  3049. }
  3050. if (!data) {
  3051. data = new Collapse(this, _config);
  3052. $this.data(DATA_KEY$3, data);
  3053. }
  3054. if (typeof config === 'string') {
  3055. if (typeof data[config] === 'undefined') {
  3056. throw new TypeError("No method named \"" + config + "\"");
  3057. }
  3058. data[config]();
  3059. }
  3060. });
  3061. };
  3062. _createClass(Collapse, null, [{
  3063. key: "VERSION",
  3064. get: function get() {
  3065. return VERSION$3;
  3066. }
  3067. }, {
  3068. key: "Default",
  3069. get: function get() {
  3070. return Default$1;
  3071. }
  3072. }]);
  3073. return Collapse;
  3074. }();
  3075. /**
  3076. * ------------------------------------------------------------------------
  3077. * Data Api implementation
  3078. * ------------------------------------------------------------------------
  3079. */
  3080. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3081. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3082. if (event.currentTarget.tagName === 'A') {
  3083. event.preventDefault();
  3084. }
  3085. var $trigger = $(this);
  3086. var selector = Util.getSelectorFromElement(this);
  3087. var selectors = [].slice.call(document.querySelectorAll(selector));
  3088. $(selectors).each(function () {
  3089. var $target = $(this);
  3090. var data = $target.data(DATA_KEY$3);
  3091. var config = data ? 'toggle' : $trigger.data();
  3092. Collapse._jQueryInterface.call($target, config);
  3093. });
  3094. });
  3095. /**
  3096. * ------------------------------------------------------------------------
  3097. * jQuery
  3098. * ------------------------------------------------------------------------
  3099. */
  3100. $.fn[NAME$3] = Collapse._jQueryInterface;
  3101. $.fn[NAME$3].Constructor = Collapse;
  3102. $.fn[NAME$3].noConflict = function () {
  3103. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3104. return Collapse._jQueryInterface;
  3105. };
  3106. /**
  3107. * ------------------------------------------------------------------------
  3108. * Constants
  3109. * ------------------------------------------------------------------------
  3110. */
  3111. var NAME$4 = 'dropdown';
  3112. var VERSION$4 = '4.4.1';
  3113. var DATA_KEY$4 = 'bs.dropdown';
  3114. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3115. var DATA_API_KEY$4 = '.data-api';
  3116. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3117. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3118. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3119. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3120. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3121. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3122. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3123. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3124. var Event$4 = {
  3125. HIDE: "hide" + EVENT_KEY$4,
  3126. HIDDEN: "hidden" + EVENT_KEY$4,
  3127. SHOW: "show" + EVENT_KEY$4,
  3128. SHOWN: "shown" + EVENT_KEY$4,
  3129. CLICK: "click" + EVENT_KEY$4,
  3130. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3131. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3132. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3133. };
  3134. var ClassName$4 = {
  3135. DISABLED: 'disabled',
  3136. SHOW: 'show',
  3137. DROPUP: 'dropup',
  3138. DROPRIGHT: 'dropright',
  3139. DROPLEFT: 'dropleft',
  3140. MENURIGHT: 'dropdown-menu-right',
  3141. MENULEFT: 'dropdown-menu-left',
  3142. POSITION_STATIC: 'position-static'
  3143. };
  3144. var Selector$4 = {
  3145. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3146. FORM_CHILD: '.dropdown form',
  3147. MENU: '.dropdown-menu',
  3148. NAVBAR_NAV: '.navbar-nav',
  3149. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3150. };
  3151. var AttachmentMap = {
  3152. TOP: 'top-start',
  3153. TOPEND: 'top-end',
  3154. BOTTOM: 'bottom-start',
  3155. BOTTOMEND: 'bottom-end',
  3156. RIGHT: 'right-start',
  3157. RIGHTEND: 'right-end',
  3158. LEFT: 'left-start',
  3159. LEFTEND: 'left-end'
  3160. };
  3161. var Default$2 = {
  3162. offset: 0,
  3163. flip: true,
  3164. boundary: 'scrollParent',
  3165. reference: 'toggle',
  3166. display: 'dynamic',
  3167. popperConfig: null
  3168. };
  3169. var DefaultType$2 = {
  3170. offset: '(number|string|function)',
  3171. flip: 'boolean',
  3172. boundary: '(string|element)',
  3173. reference: '(string|element)',
  3174. display: 'string',
  3175. popperConfig: '(null|object)'
  3176. };
  3177. /**
  3178. * ------------------------------------------------------------------------
  3179. * Class Definition
  3180. * ------------------------------------------------------------------------
  3181. */
  3182. var Dropdown =
  3183. /*#__PURE__*/
  3184. function () {
  3185. function Dropdown(element, config) {
  3186. this._element = element;
  3187. this._popper = null;
  3188. this._config = this._getConfig(config);
  3189. this._menu = this._getMenuElement();
  3190. this._inNavbar = this._detectNavbar();
  3191. this._addEventListeners();
  3192. } // Getters
  3193. var _proto = Dropdown.prototype;
  3194. // Public
  3195. _proto.toggle = function toggle() {
  3196. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3197. return;
  3198. }
  3199. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3200. Dropdown._clearMenus();
  3201. if (isActive) {
  3202. return;
  3203. }
  3204. this.show(true);
  3205. };
  3206. _proto.show = function show(usePopper) {
  3207. if (usePopper === void 0) {
  3208. usePopper = false;
  3209. }
  3210. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3211. return;
  3212. }
  3213. var relatedTarget = {
  3214. relatedTarget: this._element
  3215. };
  3216. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3217. var parent = Dropdown._getParentFromElement(this._element);
  3218. $(parent).trigger(showEvent);
  3219. if (showEvent.isDefaultPrevented()) {
  3220. return;
  3221. } // Disable totally Popper.js for Dropdown in Navbar
  3222. if (!this._inNavbar && usePopper) {
  3223. /**
  3224. * Check for Popper dependency
  3225. * Popper - https://popper.js.org
  3226. */
  3227. if (typeof Popper === 'undefined') {
  3228. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3229. }
  3230. var referenceElement = this._element;
  3231. if (this._config.reference === 'parent') {
  3232. referenceElement = parent;
  3233. } else if (Util.isElement(this._config.reference)) {
  3234. referenceElement = this._config.reference; // Check if it's jQuery element
  3235. if (typeof this._config.reference.jquery !== 'undefined') {
  3236. referenceElement = this._config.reference[0];
  3237. }
  3238. } // If boundary is not `scrollParent`, then set position to `static`
  3239. // to allow the menu to "escape" the scroll parent's boundaries
  3240. // https://github.com/twbs/bootstrap/issues/24251
  3241. if (this._config.boundary !== 'scrollParent') {
  3242. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3243. }
  3244. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3245. } // If this is a touch-enabled device we add extra
  3246. // empty mouseover listeners to the body's immediate children;
  3247. // only needed because of broken event delegation on iOS
  3248. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3249. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3250. $(document.body).children().on('mouseover', null, $.noop);
  3251. }
  3252. this._element.focus();
  3253. this._element.setAttribute('aria-expanded', true);
  3254. $(this._menu).toggleClass(ClassName$4.SHOW);
  3255. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3256. };
  3257. _proto.hide = function hide() {
  3258. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3259. return;
  3260. }
  3261. var relatedTarget = {
  3262. relatedTarget: this._element
  3263. };
  3264. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3265. var parent = Dropdown._getParentFromElement(this._element);
  3266. $(parent).trigger(hideEvent);
  3267. if (hideEvent.isDefaultPrevented()) {
  3268. return;
  3269. }
  3270. if (this._popper) {
  3271. this._popper.destroy();
  3272. }
  3273. $(this._menu).toggleClass(ClassName$4.SHOW);
  3274. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3275. };
  3276. _proto.dispose = function dispose() {
  3277. $.removeData(this._element, DATA_KEY$4);
  3278. $(this._element).off(EVENT_KEY$4);
  3279. this._element = null;
  3280. this._menu = null;
  3281. if (this._popper !== null) {
  3282. this._popper.destroy();
  3283. this._popper = null;
  3284. }
  3285. };
  3286. _proto.update = function update() {
  3287. this._inNavbar = this._detectNavbar();
  3288. if (this._popper !== null) {
  3289. this._popper.scheduleUpdate();
  3290. }
  3291. } // Private
  3292. ;
  3293. _proto._addEventListeners = function _addEventListeners() {
  3294. var _this = this;
  3295. $(this._element).on(Event$4.CLICK, function (event) {
  3296. event.preventDefault();
  3297. event.stopPropagation();
  3298. _this.toggle();
  3299. });
  3300. };
  3301. _proto._getConfig = function _getConfig(config) {
  3302. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3303. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3304. return config;
  3305. };
  3306. _proto._getMenuElement = function _getMenuElement() {
  3307. if (!this._menu) {
  3308. var parent = Dropdown._getParentFromElement(this._element);
  3309. if (parent) {
  3310. this._menu = parent.querySelector(Selector$4.MENU);
  3311. }
  3312. }
  3313. return this._menu;
  3314. };
  3315. _proto._getPlacement = function _getPlacement() {
  3316. var $parentDropdown = $(this._element.parentNode);
  3317. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3318. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3319. placement = AttachmentMap.TOP;
  3320. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3321. placement = AttachmentMap.TOPEND;
  3322. }
  3323. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3324. placement = AttachmentMap.RIGHT;
  3325. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3326. placement = AttachmentMap.LEFT;
  3327. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3328. placement = AttachmentMap.BOTTOMEND;
  3329. }
  3330. return placement;
  3331. };
  3332. _proto._detectNavbar = function _detectNavbar() {
  3333. return $(this._element).closest('.navbar').length > 0;
  3334. };
  3335. _proto._getOffset = function _getOffset() {
  3336. var _this2 = this;
  3337. var offset = {};
  3338. if (typeof this._config.offset === 'function') {
  3339. offset.fn = function (data) {
  3340. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3341. return data;
  3342. };
  3343. } else {
  3344. offset.offset = this._config.offset;
  3345. }
  3346. return offset;
  3347. };
  3348. _proto._getPopperConfig = function _getPopperConfig() {
  3349. var popperConfig = {
  3350. placement: this._getPlacement(),
  3351. modifiers: {
  3352. offset: this._getOffset(),
  3353. flip: {
  3354. enabled: this._config.flip
  3355. },
  3356. preventOverflow: {
  3357. boundariesElement: this._config.boundary
  3358. }
  3359. }
  3360. }; // Disable Popper.js if we have a static display
  3361. if (this._config.display === 'static') {
  3362. popperConfig.modifiers.applyStyle = {
  3363. enabled: false
  3364. };
  3365. }
  3366. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3367. } // Static
  3368. ;
  3369. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3370. return this.each(function () {
  3371. var data = $(this).data(DATA_KEY$4);
  3372. var _config = typeof config === 'object' ? config : null;
  3373. if (!data) {
  3374. data = new Dropdown(this, _config);
  3375. $(this).data(DATA_KEY$4, data);
  3376. }
  3377. if (typeof config === 'string') {
  3378. if (typeof data[config] === 'undefined') {
  3379. throw new TypeError("No method named \"" + config + "\"");
  3380. }
  3381. data[config]();
  3382. }
  3383. });
  3384. };
  3385. Dropdown._clearMenus = function _clearMenus(event) {
  3386. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3387. return;
  3388. }
  3389. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3390. for (var i = 0, len = toggles.length; i < len; i++) {
  3391. var parent = Dropdown._getParentFromElement(toggles[i]);
  3392. var context = $(toggles[i]).data(DATA_KEY$4);
  3393. var relatedTarget = {
  3394. relatedTarget: toggles[i]
  3395. };
  3396. if (event && event.type === 'click') {
  3397. relatedTarget.clickEvent = event;
  3398. }
  3399. if (!context) {
  3400. continue;
  3401. }
  3402. var dropdownMenu = context._menu;
  3403. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3404. continue;
  3405. }
  3406. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3407. continue;
  3408. }
  3409. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3410. $(parent).trigger(hideEvent);
  3411. if (hideEvent.isDefaultPrevented()) {
  3412. continue;
  3413. } // If this is a touch-enabled device we remove the extra
  3414. // empty mouseover listeners we added for iOS support
  3415. if ('ontouchstart' in document.documentElement) {
  3416. $(document.body).children().off('mouseover', null, $.noop);
  3417. }
  3418. toggles[i].setAttribute('aria-expanded', 'false');
  3419. if (context._popper) {
  3420. context._popper.destroy();
  3421. }
  3422. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3423. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3424. }
  3425. };
  3426. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3427. var parent;
  3428. var selector = Util.getSelectorFromElement(element);
  3429. if (selector) {
  3430. parent = document.querySelector(selector);
  3431. }
  3432. return parent || element.parentNode;
  3433. } // eslint-disable-next-line complexity
  3434. ;
  3435. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3436. // If not input/textarea:
  3437. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3438. // If input/textarea:
  3439. // - If space key => not a dropdown command
  3440. // - If key is other than escape
  3441. // - If key is not up or down => not a dropdown command
  3442. // - If trigger inside the menu => not a dropdown command
  3443. 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)) {
  3444. return;
  3445. }
  3446. event.preventDefault();
  3447. event.stopPropagation();
  3448. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3449. return;
  3450. }
  3451. var parent = Dropdown._getParentFromElement(this);
  3452. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3453. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3454. return;
  3455. }
  3456. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3457. if (event.which === ESCAPE_KEYCODE) {
  3458. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3459. $(toggle).trigger('focus');
  3460. }
  3461. $(this).trigger('click');
  3462. return;
  3463. }
  3464. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3465. return $(item).is(':visible');
  3466. });
  3467. if (items.length === 0) {
  3468. return;
  3469. }
  3470. var index = items.indexOf(event.target);
  3471. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3472. // Up
  3473. index--;
  3474. }
  3475. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3476. // Down
  3477. index++;
  3478. }
  3479. if (index < 0) {
  3480. index = 0;
  3481. }
  3482. items[index].focus();
  3483. };
  3484. _createClass(Dropdown, null, [{
  3485. key: "VERSION",
  3486. get: function get() {
  3487. return VERSION$4;
  3488. }
  3489. }, {
  3490. key: "Default",
  3491. get: function get() {
  3492. return Default$2;
  3493. }
  3494. }, {
  3495. key: "DefaultType",
  3496. get: function get() {
  3497. return DefaultType$2;
  3498. }
  3499. }]);
  3500. return Dropdown;
  3501. }();
  3502. /**
  3503. * ------------------------------------------------------------------------
  3504. * Data Api implementation
  3505. * ------------------------------------------------------------------------
  3506. */
  3507. $(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) {
  3508. event.preventDefault();
  3509. event.stopPropagation();
  3510. Dropdown._jQueryInterface.call($(this), 'toggle');
  3511. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3512. e.stopPropagation();
  3513. });
  3514. /**
  3515. * ------------------------------------------------------------------------
  3516. * jQuery
  3517. * ------------------------------------------------------------------------
  3518. */
  3519. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3520. $.fn[NAME$4].Constructor = Dropdown;
  3521. $.fn[NAME$4].noConflict = function () {
  3522. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3523. return Dropdown._jQueryInterface;
  3524. };
  3525. /**
  3526. * ------------------------------------------------------------------------
  3527. * Constants
  3528. * ------------------------------------------------------------------------
  3529. */
  3530. var NAME$5 = 'modal';
  3531. var VERSION$5 = '4.4.1';
  3532. var DATA_KEY$5 = 'bs.modal';
  3533. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3534. var DATA_API_KEY$5 = '.data-api';
  3535. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3536. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3537. var Default$3 = {
  3538. backdrop: true,
  3539. keyboard: true,
  3540. focus: true,
  3541. show: true
  3542. };
  3543. var DefaultType$3 = {
  3544. backdrop: '(boolean|string)',
  3545. keyboard: 'boolean',
  3546. focus: 'boolean',
  3547. show: 'boolean'
  3548. };
  3549. var Event$5 = {
  3550. HIDE: "hide" + EVENT_KEY$5,
  3551. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3552. HIDDEN: "hidden" + EVENT_KEY$5,
  3553. SHOW: "show" + EVENT_KEY$5,
  3554. SHOWN: "shown" + EVENT_KEY$5,
  3555. FOCUSIN: "focusin" + EVENT_KEY$5,
  3556. RESIZE: "resize" + EVENT_KEY$5,
  3557. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3558. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3559. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3560. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3561. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3562. };
  3563. var ClassName$5 = {
  3564. SCROLLABLE: 'modal-dialog-scrollable',
  3565. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3566. BACKDROP: 'modal-backdrop',
  3567. OPEN: 'modal-open',
  3568. FADE: 'fade',
  3569. SHOW: 'show',
  3570. STATIC: 'modal-static'
  3571. };
  3572. var Selector$5 = {
  3573. DIALOG: '.modal-dialog',
  3574. MODAL_BODY: '.modal-body',
  3575. DATA_TOGGLE: '[data-toggle="modal"]',
  3576. DATA_DISMISS: '[data-dismiss="modal"]',
  3577. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3578. STICKY_CONTENT: '.sticky-top'
  3579. };
  3580. /**
  3581. * ------------------------------------------------------------------------
  3582. * Class Definition
  3583. * ------------------------------------------------------------------------
  3584. */
  3585. var Modal =
  3586. /*#__PURE__*/
  3587. function () {
  3588. function Modal(element, config) {
  3589. this._config = this._getConfig(config);
  3590. this._element = element;
  3591. this._dialog = element.querySelector(Selector$5.DIALOG);
  3592. this._backdrop = null;
  3593. this._isShown = false;
  3594. this._isBodyOverflowing = false;
  3595. this._ignoreBackdropClick = false;
  3596. this._isTransitioning = false;
  3597. this._scrollbarWidth = 0;
  3598. } // Getters
  3599. var _proto = Modal.prototype;
  3600. // Public
  3601. _proto.toggle = function toggle(relatedTarget) {
  3602. return this._isShown ? this.hide() : this.show(relatedTarget);
  3603. };
  3604. _proto.show = function show(relatedTarget) {
  3605. var _this = this;
  3606. if (this._isShown || this._isTransitioning) {
  3607. return;
  3608. }
  3609. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3610. this._isTransitioning = true;
  3611. }
  3612. var showEvent = $.Event(Event$5.SHOW, {
  3613. relatedTarget: relatedTarget
  3614. });
  3615. $(this._element).trigger(showEvent);
  3616. if (this._isShown || showEvent.isDefaultPrevented()) {
  3617. return;
  3618. }
  3619. this._isShown = true;
  3620. this._checkScrollbar();
  3621. this._setScrollbar();
  3622. this._adjustDialog();
  3623. this._setEscapeEvent();
  3624. this._setResizeEvent();
  3625. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3626. return _this.hide(event);
  3627. });
  3628. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3629. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3630. if ($(event.target).is(_this._element)) {
  3631. _this._ignoreBackdropClick = true;
  3632. }
  3633. });
  3634. });
  3635. this._showBackdrop(function () {
  3636. return _this._showElement(relatedTarget);
  3637. });
  3638. };
  3639. _proto.hide = function hide(event) {
  3640. var _this2 = this;
  3641. if (event) {
  3642. event.preventDefault();
  3643. }
  3644. if (!this._isShown || this._isTransitioning) {
  3645. return;
  3646. }
  3647. var hideEvent = $.Event(Event$5.HIDE);
  3648. $(this._element).trigger(hideEvent);
  3649. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3650. return;
  3651. }
  3652. this._isShown = false;
  3653. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3654. if (transition) {
  3655. this._isTransitioning = true;
  3656. }
  3657. this._setEscapeEvent();
  3658. this._setResizeEvent();
  3659. $(document).off(Event$5.FOCUSIN);
  3660. $(this._element).removeClass(ClassName$5.SHOW);
  3661. $(this._element).off(Event$5.CLICK_DISMISS);
  3662. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3663. if (transition) {
  3664. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3665. $(this._element).one(Util.TRANSITION_END, function (event) {
  3666. return _this2._hideModal(event);
  3667. }).emulateTransitionEnd(transitionDuration);
  3668. } else {
  3669. this._hideModal();
  3670. }
  3671. };
  3672. _proto.dispose = function dispose() {
  3673. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3674. return $(htmlElement).off(EVENT_KEY$5);
  3675. });
  3676. /**
  3677. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3678. * Do not move `document` in `htmlElements` array
  3679. * It will remove `Event.CLICK_DATA_API` event that should remain
  3680. */
  3681. $(document).off(Event$5.FOCUSIN);
  3682. $.removeData(this._element, DATA_KEY$5);
  3683. this._config = null;
  3684. this._element = null;
  3685. this._dialog = null;
  3686. this._backdrop = null;
  3687. this._isShown = null;
  3688. this._isBodyOverflowing = null;
  3689. this._ignoreBackdropClick = null;
  3690. this._isTransitioning = null;
  3691. this._scrollbarWidth = null;
  3692. };
  3693. _proto.handleUpdate = function handleUpdate() {
  3694. this._adjustDialog();
  3695. } // Private
  3696. ;
  3697. _proto._getConfig = function _getConfig(config) {
  3698. config = _objectSpread2({}, Default$3, {}, config);
  3699. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3700. return config;
  3701. };
  3702. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3703. var _this3 = this;
  3704. if (this._config.backdrop === 'static') {
  3705. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3706. $(this._element).trigger(hideEventPrevented);
  3707. if (hideEventPrevented.defaultPrevented) {
  3708. return;
  3709. }
  3710. this._element.classList.add(ClassName$5.STATIC);
  3711. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3712. $(this._element).one(Util.TRANSITION_END, function () {
  3713. _this3._element.classList.remove(ClassName$5.STATIC);
  3714. }).emulateTransitionEnd(modalTransitionDuration);
  3715. this._element.focus();
  3716. } else {
  3717. this.hide();
  3718. }
  3719. };
  3720. _proto._showElement = function _showElement(relatedTarget) {
  3721. var _this4 = this;
  3722. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3723. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3724. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3725. // Don't move modal's DOM position
  3726. document.body.appendChild(this._element);
  3727. }
  3728. this._element.style.display = 'block';
  3729. this._element.removeAttribute('aria-hidden');
  3730. this._element.setAttribute('aria-modal', true);
  3731. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3732. modalBody.scrollTop = 0;
  3733. } else {
  3734. this._element.scrollTop = 0;
  3735. }
  3736. if (transition) {
  3737. Util.reflow(this._element);
  3738. }
  3739. $(this._element).addClass(ClassName$5.SHOW);
  3740. if (this._config.focus) {
  3741. this._enforceFocus();
  3742. }
  3743. var shownEvent = $.Event(Event$5.SHOWN, {
  3744. relatedTarget: relatedTarget
  3745. });
  3746. var transitionComplete = function transitionComplete() {
  3747. if (_this4._config.focus) {
  3748. _this4._element.focus();
  3749. }
  3750. _this4._isTransitioning = false;
  3751. $(_this4._element).trigger(shownEvent);
  3752. };
  3753. if (transition) {
  3754. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3755. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3756. } else {
  3757. transitionComplete();
  3758. }
  3759. };
  3760. _proto._enforceFocus = function _enforceFocus() {
  3761. var _this5 = this;
  3762. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3763. .on(Event$5.FOCUSIN, function (event) {
  3764. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3765. _this5._element.focus();
  3766. }
  3767. });
  3768. };
  3769. _proto._setEscapeEvent = function _setEscapeEvent() {
  3770. var _this6 = this;
  3771. if (this._isShown && this._config.keyboard) {
  3772. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3773. if (event.which === ESCAPE_KEYCODE$1) {
  3774. _this6._triggerBackdropTransition();
  3775. }
  3776. });
  3777. } else if (!this._isShown) {
  3778. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3779. }
  3780. };
  3781. _proto._setResizeEvent = function _setResizeEvent() {
  3782. var _this7 = this;
  3783. if (this._isShown) {
  3784. $(window).on(Event$5.RESIZE, function (event) {
  3785. return _this7.handleUpdate(event);
  3786. });
  3787. } else {
  3788. $(window).off(Event$5.RESIZE);
  3789. }
  3790. };
  3791. _proto._hideModal = function _hideModal() {
  3792. var _this8 = this;
  3793. this._element.style.display = 'none';
  3794. this._element.setAttribute('aria-hidden', true);
  3795. this._element.removeAttribute('aria-modal');
  3796. this._isTransitioning = false;
  3797. this._showBackdrop(function () {
  3798. $(document.body).removeClass(ClassName$5.OPEN);
  3799. _this8._resetAdjustments();
  3800. _this8._resetScrollbar();
  3801. $(_this8._element).trigger(Event$5.HIDDEN);
  3802. });
  3803. };
  3804. _proto._removeBackdrop = function _removeBackdrop() {
  3805. if (this._backdrop) {
  3806. $(this._backdrop).remove();
  3807. this._backdrop = null;
  3808. }
  3809. };
  3810. _proto._showBackdrop = function _showBackdrop(callback) {
  3811. var _this9 = this;
  3812. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3813. if (this._isShown && this._config.backdrop) {
  3814. this._backdrop = document.createElement('div');
  3815. this._backdrop.className = ClassName$5.BACKDROP;
  3816. if (animate) {
  3817. this._backdrop.classList.add(animate);
  3818. }
  3819. $(this._backdrop).appendTo(document.body);
  3820. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3821. if (_this9._ignoreBackdropClick) {
  3822. _this9._ignoreBackdropClick = false;
  3823. return;
  3824. }
  3825. if (event.target !== event.currentTarget) {
  3826. return;
  3827. }
  3828. _this9._triggerBackdropTransition();
  3829. });
  3830. if (animate) {
  3831. Util.reflow(this._backdrop);
  3832. }
  3833. $(this._backdrop).addClass(ClassName$5.SHOW);
  3834. if (!callback) {
  3835. return;
  3836. }
  3837. if (!animate) {
  3838. callback();
  3839. return;
  3840. }
  3841. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3842. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3843. } else if (!this._isShown && this._backdrop) {
  3844. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3845. var callbackRemove = function callbackRemove() {
  3846. _this9._removeBackdrop();
  3847. if (callback) {
  3848. callback();
  3849. }
  3850. };
  3851. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3852. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3853. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3854. } else {
  3855. callbackRemove();
  3856. }
  3857. } else if (callback) {
  3858. callback();
  3859. }
  3860. } // ----------------------------------------------------------------------
  3861. // the following methods are used to handle overflowing modals
  3862. // todo (fat): these should probably be refactored out of modal.js
  3863. // ----------------------------------------------------------------------
  3864. ;
  3865. _proto._adjustDialog = function _adjustDialog() {
  3866. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3867. if (!this._isBodyOverflowing && isModalOverflowing) {
  3868. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3869. }
  3870. if (this._isBodyOverflowing && !isModalOverflowing) {
  3871. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3872. }
  3873. };
  3874. _proto._resetAdjustments = function _resetAdjustments() {
  3875. this._element.style.paddingLeft = '';
  3876. this._element.style.paddingRight = '';
  3877. };
  3878. _proto._checkScrollbar = function _checkScrollbar() {
  3879. var rect = document.body.getBoundingClientRect();
  3880. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3881. this._scrollbarWidth = this._getScrollbarWidth();
  3882. };
  3883. _proto._setScrollbar = function _setScrollbar() {
  3884. var _this10 = this;
  3885. if (this._isBodyOverflowing) {
  3886. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3887. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3888. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3889. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3890. $(fixedContent).each(function (index, element) {
  3891. var actualPadding = element.style.paddingRight;
  3892. var calculatedPadding = $(element).css('padding-right');
  3893. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3894. }); // Adjust sticky content margin
  3895. $(stickyContent).each(function (index, element) {
  3896. var actualMargin = element.style.marginRight;
  3897. var calculatedMargin = $(element).css('margin-right');
  3898. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3899. }); // Adjust body padding
  3900. var actualPadding = document.body.style.paddingRight;
  3901. var calculatedPadding = $(document.body).css('padding-right');
  3902. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3903. }
  3904. $(document.body).addClass(ClassName$5.OPEN);
  3905. };
  3906. _proto._resetScrollbar = function _resetScrollbar() {
  3907. // Restore fixed content padding
  3908. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3909. $(fixedContent).each(function (index, element) {
  3910. var padding = $(element).data('padding-right');
  3911. $(element).removeData('padding-right');
  3912. element.style.paddingRight = padding ? padding : '';
  3913. }); // Restore sticky content
  3914. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3915. $(elements).each(function (index, element) {
  3916. var margin = $(element).data('margin-right');
  3917. if (typeof margin !== 'undefined') {
  3918. $(element).css('margin-right', margin).removeData('margin-right');
  3919. }
  3920. }); // Restore body padding
  3921. var padding = $(document.body).data('padding-right');
  3922. $(document.body).removeData('padding-right');
  3923. document.body.style.paddingRight = padding ? padding : '';
  3924. };
  3925. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3926. // thx d.walsh
  3927. var scrollDiv = document.createElement('div');
  3928. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3929. document.body.appendChild(scrollDiv);
  3930. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3931. document.body.removeChild(scrollDiv);
  3932. return scrollbarWidth;
  3933. } // Static
  3934. ;
  3935. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3936. return this.each(function () {
  3937. var data = $(this).data(DATA_KEY$5);
  3938. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3939. if (!data) {
  3940. data = new Modal(this, _config);
  3941. $(this).data(DATA_KEY$5, data);
  3942. }
  3943. if (typeof config === 'string') {
  3944. if (typeof data[config] === 'undefined') {
  3945. throw new TypeError("No method named \"" + config + "\"");
  3946. }
  3947. data[config](relatedTarget);
  3948. } else if (_config.show) {
  3949. data.show(relatedTarget);
  3950. }
  3951. });
  3952. };
  3953. _createClass(Modal, null, [{
  3954. key: "VERSION",
  3955. get: function get() {
  3956. return VERSION$5;
  3957. }
  3958. }, {
  3959. key: "Default",
  3960. get: function get() {
  3961. return Default$3;
  3962. }
  3963. }]);
  3964. return Modal;
  3965. }();
  3966. /**
  3967. * ------------------------------------------------------------------------
  3968. * Data Api implementation
  3969. * ------------------------------------------------------------------------
  3970. */
  3971. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3972. var _this11 = this;
  3973. var target;
  3974. var selector = Util.getSelectorFromElement(this);
  3975. if (selector) {
  3976. target = document.querySelector(selector);
  3977. }
  3978. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3979. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3980. event.preventDefault();
  3981. }
  3982. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3983. if (showEvent.isDefaultPrevented()) {
  3984. // Only register focus restorer if modal will actually get shown
  3985. return;
  3986. }
  3987. $target.one(Event$5.HIDDEN, function () {
  3988. if ($(_this11).is(':visible')) {
  3989. _this11.focus();
  3990. }
  3991. });
  3992. });
  3993. Modal._jQueryInterface.call($(target), config, this);
  3994. });
  3995. /**
  3996. * ------------------------------------------------------------------------
  3997. * jQuery
  3998. * ------------------------------------------------------------------------
  3999. */
  4000. $.fn[NAME$5] = Modal._jQueryInterface;
  4001. $.fn[NAME$5].Constructor = Modal;
  4002. $.fn[NAME$5].noConflict = function () {
  4003. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4004. return Modal._jQueryInterface;
  4005. };
  4006. /**
  4007. * --------------------------------------------------------------------------
  4008. * Bootstrap (v4.4.1): tools/sanitizer.js
  4009. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4010. * --------------------------------------------------------------------------
  4011. */
  4012. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4013. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4014. var DefaultWhitelist = {
  4015. // Global attributes allowed on any supplied element below.
  4016. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4017. a: ['target', 'href', 'title', 'rel'],
  4018. area: [],
  4019. b: [],
  4020. br: [],
  4021. col: [],
  4022. code: [],
  4023. div: [],
  4024. em: [],
  4025. hr: [],
  4026. h1: [],
  4027. h2: [],
  4028. h3: [],
  4029. h4: [],
  4030. h5: [],
  4031. h6: [],
  4032. i: [],
  4033. img: ['src', 'alt', 'title', 'width', 'height'],
  4034. li: [],
  4035. ol: [],
  4036. p: [],
  4037. pre: [],
  4038. s: [],
  4039. small: [],
  4040. span: [],
  4041. sub: [],
  4042. sup: [],
  4043. strong: [],
  4044. u: [],
  4045. ul: []
  4046. };
  4047. /**
  4048. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4049. *
  4050. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4051. */
  4052. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4053. /**
  4054. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4055. *
  4056. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4057. */
  4058. 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;
  4059. function allowedAttribute(attr, allowedAttributeList) {
  4060. var attrName = attr.nodeName.toLowerCase();
  4061. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4062. if (uriAttrs.indexOf(attrName) !== -1) {
  4063. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4064. }
  4065. return true;
  4066. }
  4067. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4068. return attrRegex instanceof RegExp;
  4069. }); // Check if a regular expression validates the attribute.
  4070. for (var i = 0, l = regExp.length; i < l; i++) {
  4071. if (attrName.match(regExp[i])) {
  4072. return true;
  4073. }
  4074. }
  4075. return false;
  4076. }
  4077. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4078. if (unsafeHtml.length === 0) {
  4079. return unsafeHtml;
  4080. }
  4081. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4082. return sanitizeFn(unsafeHtml);
  4083. }
  4084. var domParser = new window.DOMParser();
  4085. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4086. var whitelistKeys = Object.keys(whiteList);
  4087. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4088. var _loop = function _loop(i, len) {
  4089. var el = elements[i];
  4090. var elName = el.nodeName.toLowerCase();
  4091. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4092. el.parentNode.removeChild(el);
  4093. return "continue";
  4094. }
  4095. var attributeList = [].slice.call(el.attributes);
  4096. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4097. attributeList.forEach(function (attr) {
  4098. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4099. el.removeAttribute(attr.nodeName);
  4100. }
  4101. });
  4102. };
  4103. for (var i = 0, len = elements.length; i < len; i++) {
  4104. var _ret = _loop(i);
  4105. if (_ret === "continue") continue;
  4106. }
  4107. return createdDocument.body.innerHTML;
  4108. }
  4109. /**
  4110. * ------------------------------------------------------------------------
  4111. * Constants
  4112. * ------------------------------------------------------------------------
  4113. */
  4114. var NAME$6 = 'tooltip';
  4115. var VERSION$6 = '4.4.1';
  4116. var DATA_KEY$6 = 'bs.tooltip';
  4117. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4118. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4119. var CLASS_PREFIX = 'bs-tooltip';
  4120. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4121. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4122. var DefaultType$4 = {
  4123. animation: 'boolean',
  4124. template: 'string',
  4125. title: '(string|element|function)',
  4126. trigger: 'string',
  4127. delay: '(number|object)',
  4128. html: 'boolean',
  4129. selector: '(string|boolean)',
  4130. placement: '(string|function)',
  4131. offset: '(number|string|function)',
  4132. container: '(string|element|boolean)',
  4133. fallbackPlacement: '(string|array)',
  4134. boundary: '(string|element)',
  4135. sanitize: 'boolean',
  4136. sanitizeFn: '(null|function)',
  4137. whiteList: 'object',
  4138. popperConfig: '(null|object)'
  4139. };
  4140. var AttachmentMap$1 = {
  4141. AUTO: 'auto',
  4142. TOP: 'top',
  4143. RIGHT: 'right',
  4144. BOTTOM: 'bottom',
  4145. LEFT: 'left'
  4146. };
  4147. var Default$4 = {
  4148. animation: true,
  4149. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4150. trigger: 'hover focus',
  4151. title: '',
  4152. delay: 0,
  4153. html: false,
  4154. selector: false,
  4155. placement: 'top',
  4156. offset: 0,
  4157. container: false,
  4158. fallbackPlacement: 'flip',
  4159. boundary: 'scrollParent',
  4160. sanitize: true,
  4161. sanitizeFn: null,
  4162. whiteList: DefaultWhitelist,
  4163. popperConfig: null
  4164. };
  4165. var HoverState = {
  4166. SHOW: 'show',
  4167. OUT: 'out'
  4168. };
  4169. var Event$6 = {
  4170. HIDE: "hide" + EVENT_KEY$6,
  4171. HIDDEN: "hidden" + EVENT_KEY$6,
  4172. SHOW: "show" + EVENT_KEY$6,
  4173. SHOWN: "shown" + EVENT_KEY$6,
  4174. INSERTED: "inserted" + EVENT_KEY$6,
  4175. CLICK: "click" + EVENT_KEY$6,
  4176. FOCUSIN: "focusin" + EVENT_KEY$6,
  4177. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4178. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4179. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4180. };
  4181. var ClassName$6 = {
  4182. FADE: 'fade',
  4183. SHOW: 'show'
  4184. };
  4185. var Selector$6 = {
  4186. TOOLTIP: '.tooltip',
  4187. TOOLTIP_INNER: '.tooltip-inner',
  4188. ARROW: '.arrow'
  4189. };
  4190. var Trigger = {
  4191. HOVER: 'hover',
  4192. FOCUS: 'focus',
  4193. CLICK: 'click',
  4194. MANUAL: 'manual'
  4195. };
  4196. /**
  4197. * ------------------------------------------------------------------------
  4198. * Class Definition
  4199. * ------------------------------------------------------------------------
  4200. */
  4201. var Tooltip =
  4202. /*#__PURE__*/
  4203. function () {
  4204. function Tooltip(element, config) {
  4205. if (typeof Popper === 'undefined') {
  4206. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4207. } // private
  4208. this._isEnabled = true;
  4209. this._timeout = 0;
  4210. this._hoverState = '';
  4211. this._activeTrigger = {};
  4212. this._popper = null; // Protected
  4213. this.element = element;
  4214. this.config = this._getConfig(config);
  4215. this.tip = null;
  4216. this._setListeners();
  4217. } // Getters
  4218. var _proto = Tooltip.prototype;
  4219. // Public
  4220. _proto.enable = function enable() {
  4221. this._isEnabled = true;
  4222. };
  4223. _proto.disable = function disable() {
  4224. this._isEnabled = false;
  4225. };
  4226. _proto.toggleEnabled = function toggleEnabled() {
  4227. this._isEnabled = !this._isEnabled;
  4228. };
  4229. _proto.toggle = function toggle(event) {
  4230. if (!this._isEnabled) {
  4231. return;
  4232. }
  4233. if (event) {
  4234. var dataKey = this.constructor.DATA_KEY;
  4235. var context = $(event.currentTarget).data(dataKey);
  4236. if (!context) {
  4237. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4238. $(event.currentTarget).data(dataKey, context);
  4239. }
  4240. context._activeTrigger.click = !context._activeTrigger.click;
  4241. if (context._isWithActiveTrigger()) {
  4242. context._enter(null, context);
  4243. } else {
  4244. context._leave(null, context);
  4245. }
  4246. } else {
  4247. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4248. this._leave(null, this);
  4249. return;
  4250. }
  4251. this._enter(null, this);
  4252. }
  4253. };
  4254. _proto.dispose = function dispose() {
  4255. clearTimeout(this._timeout);
  4256. $.removeData(this.element, this.constructor.DATA_KEY);
  4257. $(this.element).off(this.constructor.EVENT_KEY);
  4258. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4259. if (this.tip) {
  4260. $(this.tip).remove();
  4261. }
  4262. this._isEnabled = null;
  4263. this._timeout = null;
  4264. this._hoverState = null;
  4265. this._activeTrigger = null;
  4266. if (this._popper) {
  4267. this._popper.destroy();
  4268. }
  4269. this._popper = null;
  4270. this.element = null;
  4271. this.config = null;
  4272. this.tip = null;
  4273. };
  4274. _proto.show = function show() {
  4275. var _this = this;
  4276. if ($(this.element).css('display') === 'none') {
  4277. throw new Error('Please use show on visible elements');
  4278. }
  4279. var showEvent = $.Event(this.constructor.Event.SHOW);
  4280. if (this.isWithContent() && this._isEnabled) {
  4281. $(this.element).trigger(showEvent);
  4282. var shadowRoot = Util.findShadowRoot(this.element);
  4283. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4284. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4285. return;
  4286. }
  4287. var tip = this.getTipElement();
  4288. var tipId = Util.getUID(this.constructor.NAME);
  4289. tip.setAttribute('id', tipId);
  4290. this.element.setAttribute('aria-describedby', tipId);
  4291. this.setContent();
  4292. if (this.config.animation) {
  4293. $(tip).addClass(ClassName$6.FADE);
  4294. }
  4295. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4296. var attachment = this._getAttachment(placement);
  4297. this.addAttachmentClass(attachment);
  4298. var container = this._getContainer();
  4299. $(tip).data(this.constructor.DATA_KEY, this);
  4300. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4301. $(tip).appendTo(container);
  4302. }
  4303. $(this.element).trigger(this.constructor.Event.INSERTED);
  4304. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4305. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4306. // empty mouseover listeners to the body's immediate children;
  4307. // only needed because of broken event delegation on iOS
  4308. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4309. if ('ontouchstart' in document.documentElement) {
  4310. $(document.body).children().on('mouseover', null, $.noop);
  4311. }
  4312. var complete = function complete() {
  4313. if (_this.config.animation) {
  4314. _this._fixTransition();
  4315. }
  4316. var prevHoverState = _this._hoverState;
  4317. _this._hoverState = null;
  4318. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4319. if (prevHoverState === HoverState.OUT) {
  4320. _this._leave(null, _this);
  4321. }
  4322. };
  4323. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4324. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4325. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4326. } else {
  4327. complete();
  4328. }
  4329. }
  4330. };
  4331. _proto.hide = function hide(callback) {
  4332. var _this2 = this;
  4333. var tip = this.getTipElement();
  4334. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4335. var complete = function complete() {
  4336. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4337. tip.parentNode.removeChild(tip);
  4338. }
  4339. _this2._cleanTipClass();
  4340. _this2.element.removeAttribute('aria-describedby');
  4341. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4342. if (_this2._popper !== null) {
  4343. _this2._popper.destroy();
  4344. }
  4345. if (callback) {
  4346. callback();
  4347. }
  4348. };
  4349. $(this.element).trigger(hideEvent);
  4350. if (hideEvent.isDefaultPrevented()) {
  4351. return;
  4352. }
  4353. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4354. // empty mouseover listeners we added for iOS support
  4355. if ('ontouchstart' in document.documentElement) {
  4356. $(document.body).children().off('mouseover', null, $.noop);
  4357. }
  4358. this._activeTrigger[Trigger.CLICK] = false;
  4359. this._activeTrigger[Trigger.FOCUS] = false;
  4360. this._activeTrigger[Trigger.HOVER] = false;
  4361. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4362. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4363. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4364. } else {
  4365. complete();
  4366. }
  4367. this._hoverState = '';
  4368. };
  4369. _proto.update = function update() {
  4370. if (this._popper !== null) {
  4371. this._popper.scheduleUpdate();
  4372. }
  4373. } // Protected
  4374. ;
  4375. _proto.isWithContent = function isWithContent() {
  4376. return Boolean(this.getTitle());
  4377. };
  4378. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4379. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4380. };
  4381. _proto.getTipElement = function getTipElement() {
  4382. this.tip = this.tip || $(this.config.template)[0];
  4383. return this.tip;
  4384. };
  4385. _proto.setContent = function setContent() {
  4386. var tip = this.getTipElement();
  4387. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4388. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4389. };
  4390. _proto.setElementContent = function setElementContent($element, content) {
  4391. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4392. // Content is a DOM node or a jQuery
  4393. if (this.config.html) {
  4394. if (!$(content).parent().is($element)) {
  4395. $element.empty().append(content);
  4396. }
  4397. } else {
  4398. $element.text($(content).text());
  4399. }
  4400. return;
  4401. }
  4402. if (this.config.html) {
  4403. if (this.config.sanitize) {
  4404. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4405. }
  4406. $element.html(content);
  4407. } else {
  4408. $element.text(content);
  4409. }
  4410. };
  4411. _proto.getTitle = function getTitle() {
  4412. var title = this.element.getAttribute('data-original-title');
  4413. if (!title) {
  4414. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4415. }
  4416. return title;
  4417. } // Private
  4418. ;
  4419. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4420. var _this3 = this;
  4421. var defaultBsConfig = {
  4422. placement: attachment,
  4423. modifiers: {
  4424. offset: this._getOffset(),
  4425. flip: {
  4426. behavior: this.config.fallbackPlacement
  4427. },
  4428. arrow: {
  4429. element: Selector$6.ARROW
  4430. },
  4431. preventOverflow: {
  4432. boundariesElement: this.config.boundary
  4433. }
  4434. },
  4435. onCreate: function onCreate(data) {
  4436. if (data.originalPlacement !== data.placement) {
  4437. _this3._handlePopperPlacementChange(data);
  4438. }
  4439. },
  4440. onUpdate: function onUpdate(data) {
  4441. return _this3._handlePopperPlacementChange(data);
  4442. }
  4443. };
  4444. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4445. };
  4446. _proto._getOffset = function _getOffset() {
  4447. var _this4 = this;
  4448. var offset = {};
  4449. if (typeof this.config.offset === 'function') {
  4450. offset.fn = function (data) {
  4451. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4452. return data;
  4453. };
  4454. } else {
  4455. offset.offset = this.config.offset;
  4456. }
  4457. return offset;
  4458. };
  4459. _proto._getContainer = function _getContainer() {
  4460. if (this.config.container === false) {
  4461. return document.body;
  4462. }
  4463. if (Util.isElement(this.config.container)) {
  4464. return $(this.config.container);
  4465. }
  4466. return $(document).find(this.config.container);
  4467. };
  4468. _proto._getAttachment = function _getAttachment(placement) {
  4469. return AttachmentMap$1[placement.toUpperCase()];
  4470. };
  4471. _proto._setListeners = function _setListeners() {
  4472. var _this5 = this;
  4473. var triggers = this.config.trigger.split(' ');
  4474. triggers.forEach(function (trigger) {
  4475. if (trigger === 'click') {
  4476. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4477. return _this5.toggle(event);
  4478. });
  4479. } else if (trigger !== Trigger.MANUAL) {
  4480. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4481. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4482. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4483. return _this5._enter(event);
  4484. }).on(eventOut, _this5.config.selector, function (event) {
  4485. return _this5._leave(event);
  4486. });
  4487. }
  4488. });
  4489. this._hideModalHandler = function () {
  4490. if (_this5.element) {
  4491. _this5.hide();
  4492. }
  4493. };
  4494. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4495. if (this.config.selector) {
  4496. this.config = _objectSpread2({}, this.config, {
  4497. trigger: 'manual',
  4498. selector: ''
  4499. });
  4500. } else {
  4501. this._fixTitle();
  4502. }
  4503. };
  4504. _proto._fixTitle = function _fixTitle() {
  4505. var titleType = typeof this.element.getAttribute('data-original-title');
  4506. if (this.element.getAttribute('title') || titleType !== 'string') {
  4507. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4508. this.element.setAttribute('title', '');
  4509. }
  4510. };
  4511. _proto._enter = function _enter(event, context) {
  4512. var dataKey = this.constructor.DATA_KEY;
  4513. context = context || $(event.currentTarget).data(dataKey);
  4514. if (!context) {
  4515. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4516. $(event.currentTarget).data(dataKey, context);
  4517. }
  4518. if (event) {
  4519. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4520. }
  4521. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4522. context._hoverState = HoverState.SHOW;
  4523. return;
  4524. }
  4525. clearTimeout(context._timeout);
  4526. context._hoverState = HoverState.SHOW;
  4527. if (!context.config.delay || !context.config.delay.show) {
  4528. context.show();
  4529. return;
  4530. }
  4531. context._timeout = setTimeout(function () {
  4532. if (context._hoverState === HoverState.SHOW) {
  4533. context.show();
  4534. }
  4535. }, context.config.delay.show);
  4536. };
  4537. _proto._leave = function _leave(event, context) {
  4538. var dataKey = this.constructor.DATA_KEY;
  4539. context = context || $(event.currentTarget).data(dataKey);
  4540. if (!context) {
  4541. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4542. $(event.currentTarget).data(dataKey, context);
  4543. }
  4544. if (event) {
  4545. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4546. }
  4547. if (context._isWithActiveTrigger()) {
  4548. return;
  4549. }
  4550. clearTimeout(context._timeout);
  4551. context._hoverState = HoverState.OUT;
  4552. if (!context.config.delay || !context.config.delay.hide) {
  4553. context.hide();
  4554. return;
  4555. }
  4556. context._timeout = setTimeout(function () {
  4557. if (context._hoverState === HoverState.OUT) {
  4558. context.hide();
  4559. }
  4560. }, context.config.delay.hide);
  4561. };
  4562. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4563. for (var trigger in this._activeTrigger) {
  4564. if (this._activeTrigger[trigger]) {
  4565. return true;
  4566. }
  4567. }
  4568. return false;
  4569. };
  4570. _proto._getConfig = function _getConfig(config) {
  4571. var dataAttributes = $(this.element).data();
  4572. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4573. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4574. delete dataAttributes[dataAttr];
  4575. }
  4576. });
  4577. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4578. if (typeof config.delay === 'number') {
  4579. config.delay = {
  4580. show: config.delay,
  4581. hide: config.delay
  4582. };
  4583. }
  4584. if (typeof config.title === 'number') {
  4585. config.title = config.title.toString();
  4586. }
  4587. if (typeof config.content === 'number') {
  4588. config.content = config.content.toString();
  4589. }
  4590. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4591. if (config.sanitize) {
  4592. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4593. }
  4594. return config;
  4595. };
  4596. _proto._getDelegateConfig = function _getDelegateConfig() {
  4597. var config = {};
  4598. if (this.config) {
  4599. for (var key in this.config) {
  4600. if (this.constructor.Default[key] !== this.config[key]) {
  4601. config[key] = this.config[key];
  4602. }
  4603. }
  4604. }
  4605. return config;
  4606. };
  4607. _proto._cleanTipClass = function _cleanTipClass() {
  4608. var $tip = $(this.getTipElement());
  4609. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4610. if (tabClass !== null && tabClass.length) {
  4611. $tip.removeClass(tabClass.join(''));
  4612. }
  4613. };
  4614. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4615. var popperInstance = popperData.instance;
  4616. this.tip = popperInstance.popper;
  4617. this._cleanTipClass();
  4618. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4619. };
  4620. _proto._fixTransition = function _fixTransition() {
  4621. var tip = this.getTipElement();
  4622. var initConfigAnimation = this.config.animation;
  4623. if (tip.getAttribute('x-placement') !== null) {
  4624. return;
  4625. }
  4626. $(tip).removeClass(ClassName$6.FADE);
  4627. this.config.animation = false;
  4628. this.hide();
  4629. this.show();
  4630. this.config.animation = initConfigAnimation;
  4631. } // Static
  4632. ;
  4633. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4634. return this.each(function () {
  4635. var data = $(this).data(DATA_KEY$6);
  4636. var _config = typeof config === 'object' && config;
  4637. if (!data && /dispose|hide/.test(config)) {
  4638. return;
  4639. }
  4640. if (!data) {
  4641. data = new Tooltip(this, _config);
  4642. $(this).data(DATA_KEY$6, data);
  4643. }
  4644. if (typeof config === 'string') {
  4645. if (typeof data[config] === 'undefined') {
  4646. throw new TypeError("No method named \"" + config + "\"");
  4647. }
  4648. data[config]();
  4649. }
  4650. });
  4651. };
  4652. _createClass(Tooltip, null, [{
  4653. key: "VERSION",
  4654. get: function get() {
  4655. return VERSION$6;
  4656. }
  4657. }, {
  4658. key: "Default",
  4659. get: function get() {
  4660. return Default$4;
  4661. }
  4662. }, {
  4663. key: "NAME",
  4664. get: function get() {
  4665. return NAME$6;
  4666. }
  4667. }, {
  4668. key: "DATA_KEY",
  4669. get: function get() {
  4670. return DATA_KEY$6;
  4671. }
  4672. }, {
  4673. key: "Event",
  4674. get: function get() {
  4675. return Event$6;
  4676. }
  4677. }, {
  4678. key: "EVENT_KEY",
  4679. get: function get() {
  4680. return EVENT_KEY$6;
  4681. }
  4682. }, {
  4683. key: "DefaultType",
  4684. get: function get() {
  4685. return DefaultType$4;
  4686. }
  4687. }]);
  4688. return Tooltip;
  4689. }();
  4690. /**
  4691. * ------------------------------------------------------------------------
  4692. * jQuery
  4693. * ------------------------------------------------------------------------
  4694. */
  4695. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4696. $.fn[NAME$6].Constructor = Tooltip;
  4697. $.fn[NAME$6].noConflict = function () {
  4698. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4699. return Tooltip._jQueryInterface;
  4700. };
  4701. /**
  4702. * ------------------------------------------------------------------------
  4703. * Constants
  4704. * ------------------------------------------------------------------------
  4705. */
  4706. var NAME$7 = 'popover';
  4707. var VERSION$7 = '4.4.1';
  4708. var DATA_KEY$7 = 'bs.popover';
  4709. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4710. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4711. var CLASS_PREFIX$1 = 'bs-popover';
  4712. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4713. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4714. placement: 'right',
  4715. trigger: 'click',
  4716. content: '',
  4717. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4718. });
  4719. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4720. content: '(string|element|function)'
  4721. });
  4722. var ClassName$7 = {
  4723. FADE: 'fade',
  4724. SHOW: 'show'
  4725. };
  4726. var Selector$7 = {
  4727. TITLE: '.popover-header',
  4728. CONTENT: '.popover-body'
  4729. };
  4730. var Event$7 = {
  4731. HIDE: "hide" + EVENT_KEY$7,
  4732. HIDDEN: "hidden" + EVENT_KEY$7,
  4733. SHOW: "show" + EVENT_KEY$7,
  4734. SHOWN: "shown" + EVENT_KEY$7,
  4735. INSERTED: "inserted" + EVENT_KEY$7,
  4736. CLICK: "click" + EVENT_KEY$7,
  4737. FOCUSIN: "focusin" + EVENT_KEY$7,
  4738. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4739. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4740. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4741. };
  4742. /**
  4743. * ------------------------------------------------------------------------
  4744. * Class Definition
  4745. * ------------------------------------------------------------------------
  4746. */
  4747. var Popover =
  4748. /*#__PURE__*/
  4749. function (_Tooltip) {
  4750. _inheritsLoose(Popover, _Tooltip);
  4751. function Popover() {
  4752. return _Tooltip.apply(this, arguments) || this;
  4753. }
  4754. var _proto = Popover.prototype;
  4755. // Overrides
  4756. _proto.isWithContent = function isWithContent() {
  4757. return this.getTitle() || this._getContent();
  4758. };
  4759. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4760. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4761. };
  4762. _proto.getTipElement = function getTipElement() {
  4763. this.tip = this.tip || $(this.config.template)[0];
  4764. return this.tip;
  4765. };
  4766. _proto.setContent = function setContent() {
  4767. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4768. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4769. var content = this._getContent();
  4770. if (typeof content === 'function') {
  4771. content = content.call(this.element);
  4772. }
  4773. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4774. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4775. } // Private
  4776. ;
  4777. _proto._getContent = function _getContent() {
  4778. return this.element.getAttribute('data-content') || this.config.content;
  4779. };
  4780. _proto._cleanTipClass = function _cleanTipClass() {
  4781. var $tip = $(this.getTipElement());
  4782. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4783. if (tabClass !== null && tabClass.length > 0) {
  4784. $tip.removeClass(tabClass.join(''));
  4785. }
  4786. } // Static
  4787. ;
  4788. Popover._jQueryInterface = function _jQueryInterface(config) {
  4789. return this.each(function () {
  4790. var data = $(this).data(DATA_KEY$7);
  4791. var _config = typeof config === 'object' ? config : null;
  4792. if (!data && /dispose|hide/.test(config)) {
  4793. return;
  4794. }
  4795. if (!data) {
  4796. data = new Popover(this, _config);
  4797. $(this).data(DATA_KEY$7, data);
  4798. }
  4799. if (typeof config === 'string') {
  4800. if (typeof data[config] === 'undefined') {
  4801. throw new TypeError("No method named \"" + config + "\"");
  4802. }
  4803. data[config]();
  4804. }
  4805. });
  4806. };
  4807. _createClass(Popover, null, [{
  4808. key: "VERSION",
  4809. // Getters
  4810. get: function get() {
  4811. return VERSION$7;
  4812. }
  4813. }, {
  4814. key: "Default",
  4815. get: function get() {
  4816. return Default$5;
  4817. }
  4818. }, {
  4819. key: "NAME",
  4820. get: function get() {
  4821. return NAME$7;
  4822. }
  4823. }, {
  4824. key: "DATA_KEY",
  4825. get: function get() {
  4826. return DATA_KEY$7;
  4827. }
  4828. }, {
  4829. key: "Event",
  4830. get: function get() {
  4831. return Event$7;
  4832. }
  4833. }, {
  4834. key: "EVENT_KEY",
  4835. get: function get() {
  4836. return EVENT_KEY$7;
  4837. }
  4838. }, {
  4839. key: "DefaultType",
  4840. get: function get() {
  4841. return DefaultType$5;
  4842. }
  4843. }]);
  4844. return Popover;
  4845. }(Tooltip);
  4846. /**
  4847. * ------------------------------------------------------------------------
  4848. * jQuery
  4849. * ------------------------------------------------------------------------
  4850. */
  4851. $.fn[NAME$7] = Popover._jQueryInterface;
  4852. $.fn[NAME$7].Constructor = Popover;
  4853. $.fn[NAME$7].noConflict = function () {
  4854. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4855. return Popover._jQueryInterface;
  4856. };
  4857. /**
  4858. * ------------------------------------------------------------------------
  4859. * Constants
  4860. * ------------------------------------------------------------------------
  4861. */
  4862. var NAME$8 = 'scrollspy';
  4863. var VERSION$8 = '4.4.1';
  4864. var DATA_KEY$8 = 'bs.scrollspy';
  4865. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4866. var DATA_API_KEY$6 = '.data-api';
  4867. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4868. var Default$6 = {
  4869. offset: 10,
  4870. method: 'auto',
  4871. target: ''
  4872. };
  4873. var DefaultType$6 = {
  4874. offset: 'number',
  4875. method: 'string',
  4876. target: '(string|element)'
  4877. };
  4878. var Event$8 = {
  4879. ACTIVATE: "activate" + EVENT_KEY$8,
  4880. SCROLL: "scroll" + EVENT_KEY$8,
  4881. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4882. };
  4883. var ClassName$8 = {
  4884. DROPDOWN_ITEM: 'dropdown-item',
  4885. DROPDOWN_MENU: 'dropdown-menu',
  4886. ACTIVE: 'active'
  4887. };
  4888. var Selector$8 = {
  4889. DATA_SPY: '[data-spy="scroll"]',
  4890. ACTIVE: '.active',
  4891. NAV_LIST_GROUP: '.nav, .list-group',
  4892. NAV_LINKS: '.nav-link',
  4893. NAV_ITEMS: '.nav-item',
  4894. LIST_ITEMS: '.list-group-item',
  4895. DROPDOWN: '.dropdown',
  4896. DROPDOWN_ITEMS: '.dropdown-item',
  4897. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4898. };
  4899. var OffsetMethod = {
  4900. OFFSET: 'offset',
  4901. POSITION: 'position'
  4902. };
  4903. /**
  4904. * ------------------------------------------------------------------------
  4905. * Class Definition
  4906. * ------------------------------------------------------------------------
  4907. */
  4908. var ScrollSpy =
  4909. /*#__PURE__*/
  4910. function () {
  4911. function ScrollSpy(element, config) {
  4912. var _this = this;
  4913. this._element = element;
  4914. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4915. this._config = this._getConfig(config);
  4916. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4917. this._offsets = [];
  4918. this._targets = [];
  4919. this._activeTarget = null;
  4920. this._scrollHeight = 0;
  4921. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4922. return _this._process(event);
  4923. });
  4924. this.refresh();
  4925. this._process();
  4926. } // Getters
  4927. var _proto = ScrollSpy.prototype;
  4928. // Public
  4929. _proto.refresh = function refresh() {
  4930. var _this2 = this;
  4931. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4932. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4933. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4934. this._offsets = [];
  4935. this._targets = [];
  4936. this._scrollHeight = this._getScrollHeight();
  4937. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4938. targets.map(function (element) {
  4939. var target;
  4940. var targetSelector = Util.getSelectorFromElement(element);
  4941. if (targetSelector) {
  4942. target = document.querySelector(targetSelector);
  4943. }
  4944. if (target) {
  4945. var targetBCR = target.getBoundingClientRect();
  4946. if (targetBCR.width || targetBCR.height) {
  4947. // TODO (fat): remove sketch reliance on jQuery position/offset
  4948. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4949. }
  4950. }
  4951. return null;
  4952. }).filter(function (item) {
  4953. return item;
  4954. }).sort(function (a, b) {
  4955. return a[0] - b[0];
  4956. }).forEach(function (item) {
  4957. _this2._offsets.push(item[0]);
  4958. _this2._targets.push(item[1]);
  4959. });
  4960. };
  4961. _proto.dispose = function dispose() {
  4962. $.removeData(this._element, DATA_KEY$8);
  4963. $(this._scrollElement).off(EVENT_KEY$8);
  4964. this._element = null;
  4965. this._scrollElement = null;
  4966. this._config = null;
  4967. this._selector = null;
  4968. this._offsets = null;
  4969. this._targets = null;
  4970. this._activeTarget = null;
  4971. this._scrollHeight = null;
  4972. } // Private
  4973. ;
  4974. _proto._getConfig = function _getConfig(config) {
  4975. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4976. if (typeof config.target !== 'string') {
  4977. var id = $(config.target).attr('id');
  4978. if (!id) {
  4979. id = Util.getUID(NAME$8);
  4980. $(config.target).attr('id', id);
  4981. }
  4982. config.target = "#" + id;
  4983. }
  4984. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4985. return config;
  4986. };
  4987. _proto._getScrollTop = function _getScrollTop() {
  4988. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4989. };
  4990. _proto._getScrollHeight = function _getScrollHeight() {
  4991. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4992. };
  4993. _proto._getOffsetHeight = function _getOffsetHeight() {
  4994. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4995. };
  4996. _proto._process = function _process() {
  4997. var scrollTop = this._getScrollTop() + this._config.offset;
  4998. var scrollHeight = this._getScrollHeight();
  4999. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5000. if (this._scrollHeight !== scrollHeight) {
  5001. this.refresh();
  5002. }
  5003. if (scrollTop >= maxScroll) {
  5004. var target = this._targets[this._targets.length - 1];
  5005. if (this._activeTarget !== target) {
  5006. this._activate(target);
  5007. }
  5008. return;
  5009. }
  5010. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5011. this._activeTarget = null;
  5012. this._clear();
  5013. return;
  5014. }
  5015. var offsetLength = this._offsets.length;
  5016. for (var i = offsetLength; i--;) {
  5017. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5018. if (isActiveTarget) {
  5019. this._activate(this._targets[i]);
  5020. }
  5021. }
  5022. };
  5023. _proto._activate = function _activate(target) {
  5024. this._activeTarget = target;
  5025. this._clear();
  5026. var queries = this._selector.split(',').map(function (selector) {
  5027. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5028. });
  5029. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5030. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5031. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5032. $link.addClass(ClassName$8.ACTIVE);
  5033. } else {
  5034. // Set triggered link as active
  5035. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5036. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5037. $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
  5038. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5039. }
  5040. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5041. relatedTarget: target
  5042. });
  5043. };
  5044. _proto._clear = function _clear() {
  5045. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5046. return node.classList.contains(ClassName$8.ACTIVE);
  5047. }).forEach(function (node) {
  5048. return node.classList.remove(ClassName$8.ACTIVE);
  5049. });
  5050. } // Static
  5051. ;
  5052. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5053. return this.each(function () {
  5054. var data = $(this).data(DATA_KEY$8);
  5055. var _config = typeof config === 'object' && config;
  5056. if (!data) {
  5057. data = new ScrollSpy(this, _config);
  5058. $(this).data(DATA_KEY$8, data);
  5059. }
  5060. if (typeof config === 'string') {
  5061. if (typeof data[config] === 'undefined') {
  5062. throw new TypeError("No method named \"" + config + "\"");
  5063. }
  5064. data[config]();
  5065. }
  5066. });
  5067. };
  5068. _createClass(ScrollSpy, null, [{
  5069. key: "VERSION",
  5070. get: function get() {
  5071. return VERSION$8;
  5072. }
  5073. }, {
  5074. key: "Default",
  5075. get: function get() {
  5076. return Default$6;
  5077. }
  5078. }]);
  5079. return ScrollSpy;
  5080. }();
  5081. /**
  5082. * ------------------------------------------------------------------------
  5083. * Data Api implementation
  5084. * ------------------------------------------------------------------------
  5085. */
  5086. $(window).on(Event$8.LOAD_DATA_API, function () {
  5087. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5088. var scrollSpysLength = scrollSpys.length;
  5089. for (var i = scrollSpysLength; i--;) {
  5090. var $spy = $(scrollSpys[i]);
  5091. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5092. }
  5093. });
  5094. /**
  5095. * ------------------------------------------------------------------------
  5096. * jQuery
  5097. * ------------------------------------------------------------------------
  5098. */
  5099. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5100. $.fn[NAME$8].Constructor = ScrollSpy;
  5101. $.fn[NAME$8].noConflict = function () {
  5102. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5103. return ScrollSpy._jQueryInterface;
  5104. };
  5105. /**
  5106. * ------------------------------------------------------------------------
  5107. * Constants
  5108. * ------------------------------------------------------------------------
  5109. */
  5110. var NAME$9 = 'tab';
  5111. var VERSION$9 = '4.4.1';
  5112. var DATA_KEY$9 = 'bs.tab';
  5113. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5114. var DATA_API_KEY$7 = '.data-api';
  5115. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5116. var Event$9 = {
  5117. HIDE: "hide" + EVENT_KEY$9,
  5118. HIDDEN: "hidden" + EVENT_KEY$9,
  5119. SHOW: "show" + EVENT_KEY$9,
  5120. SHOWN: "shown" + EVENT_KEY$9,
  5121. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5122. };
  5123. var ClassName$9 = {
  5124. DROPDOWN_MENU: 'dropdown-menu',
  5125. ACTIVE: 'active',
  5126. DISABLED: 'disabled',
  5127. FADE: 'fade',
  5128. SHOW: 'show'
  5129. };
  5130. var Selector$9 = {
  5131. DROPDOWN: '.dropdown',
  5132. NAV_LIST_GROUP: '.nav, .list-group',
  5133. ACTIVE: '.active',
  5134. ACTIVE_UL: '> li > .active',
  5135. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5136. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5137. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5138. };
  5139. /**
  5140. * ------------------------------------------------------------------------
  5141. * Class Definition
  5142. * ------------------------------------------------------------------------
  5143. */
  5144. var Tab =
  5145. /*#__PURE__*/
  5146. function () {
  5147. function Tab(element) {
  5148. this._element = element;
  5149. } // Getters
  5150. var _proto = Tab.prototype;
  5151. // Public
  5152. _proto.show = function show() {
  5153. var _this = this;
  5154. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5155. return;
  5156. }
  5157. var target;
  5158. var previous;
  5159. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5160. var selector = Util.getSelectorFromElement(this._element);
  5161. if (listElement) {
  5162. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5163. previous = $.makeArray($(listElement).find(itemSelector));
  5164. previous = previous[previous.length - 1];
  5165. }
  5166. var hideEvent = $.Event(Event$9.HIDE, {
  5167. relatedTarget: this._element
  5168. });
  5169. var showEvent = $.Event(Event$9.SHOW, {
  5170. relatedTarget: previous
  5171. });
  5172. if (previous) {
  5173. $(previous).trigger(hideEvent);
  5174. }
  5175. $(this._element).trigger(showEvent);
  5176. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5177. return;
  5178. }
  5179. if (selector) {
  5180. target = document.querySelector(selector);
  5181. }
  5182. this._activate(this._element, listElement);
  5183. var complete = function complete() {
  5184. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5185. relatedTarget: _this._element
  5186. });
  5187. var shownEvent = $.Event(Event$9.SHOWN, {
  5188. relatedTarget: previous
  5189. });
  5190. $(previous).trigger(hiddenEvent);
  5191. $(_this._element).trigger(shownEvent);
  5192. };
  5193. if (target) {
  5194. this._activate(target, target.parentNode, complete);
  5195. } else {
  5196. complete();
  5197. }
  5198. };
  5199. _proto.dispose = function dispose() {
  5200. $.removeData(this._element, DATA_KEY$9);
  5201. this._element = null;
  5202. } // Private
  5203. ;
  5204. _proto._activate = function _activate(element, container, callback) {
  5205. var _this2 = this;
  5206. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5207. var active = activeElements[0];
  5208. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5209. var complete = function complete() {
  5210. return _this2._transitionComplete(element, active, callback);
  5211. };
  5212. if (active && isTransitioning) {
  5213. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5214. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5215. } else {
  5216. complete();
  5217. }
  5218. };
  5219. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5220. if (active) {
  5221. $(active).removeClass(ClassName$9.ACTIVE);
  5222. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5223. if (dropdownChild) {
  5224. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5225. }
  5226. if (active.getAttribute('role') === 'tab') {
  5227. active.setAttribute('aria-selected', false);
  5228. }
  5229. }
  5230. $(element).addClass(ClassName$9.ACTIVE);
  5231. if (element.getAttribute('role') === 'tab') {
  5232. element.setAttribute('aria-selected', true);
  5233. }
  5234. Util.reflow(element);
  5235. if (element.classList.contains(ClassName$9.FADE)) {
  5236. element.classList.add(ClassName$9.SHOW);
  5237. }
  5238. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5239. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5240. if (dropdownElement) {
  5241. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5242. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5243. }
  5244. element.setAttribute('aria-expanded', true);
  5245. }
  5246. if (callback) {
  5247. callback();
  5248. }
  5249. } // Static
  5250. ;
  5251. Tab._jQueryInterface = function _jQueryInterface(config) {
  5252. return this.each(function () {
  5253. var $this = $(this);
  5254. var data = $this.data(DATA_KEY$9);
  5255. if (!data) {
  5256. data = new Tab(this);
  5257. $this.data(DATA_KEY$9, data);
  5258. }
  5259. if (typeof config === 'string') {
  5260. if (typeof data[config] === 'undefined') {
  5261. throw new TypeError("No method named \"" + config + "\"");
  5262. }
  5263. data[config]();
  5264. }
  5265. });
  5266. };
  5267. _createClass(Tab, null, [{
  5268. key: "VERSION",
  5269. get: function get() {
  5270. return VERSION$9;
  5271. }
  5272. }]);
  5273. return Tab;
  5274. }();
  5275. /**
  5276. * ------------------------------------------------------------------------
  5277. * Data Api implementation
  5278. * ------------------------------------------------------------------------
  5279. */
  5280. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5281. event.preventDefault();
  5282. Tab._jQueryInterface.call($(this), 'show');
  5283. });
  5284. /**
  5285. * ------------------------------------------------------------------------
  5286. * jQuery
  5287. * ------------------------------------------------------------------------
  5288. */
  5289. $.fn[NAME$9] = Tab._jQueryInterface;
  5290. $.fn[NAME$9].Constructor = Tab;
  5291. $.fn[NAME$9].noConflict = function () {
  5292. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5293. return Tab._jQueryInterface;
  5294. };
  5295. /**
  5296. * ------------------------------------------------------------------------
  5297. * Constants
  5298. * ------------------------------------------------------------------------
  5299. */
  5300. var NAME$a = 'toast';
  5301. var VERSION$a = '4.4.1';
  5302. var DATA_KEY$a = 'bs.toast';
  5303. var EVENT_KEY$a = "." + DATA_KEY$a;
  5304. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5305. var Event$a = {
  5306. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5307. HIDE: "hide" + EVENT_KEY$a,
  5308. HIDDEN: "hidden" + EVENT_KEY$a,
  5309. SHOW: "show" + EVENT_KEY$a,
  5310. SHOWN: "shown" + EVENT_KEY$a
  5311. };
  5312. var ClassName$a = {
  5313. FADE: 'fade',
  5314. HIDE: 'hide',
  5315. SHOW: 'show',
  5316. SHOWING: 'showing'
  5317. };
  5318. var DefaultType$7 = {
  5319. animation: 'boolean',
  5320. autohide: 'boolean',
  5321. delay: 'number'
  5322. };
  5323. var Default$7 = {
  5324. animation: true,
  5325. autohide: true,
  5326. delay: 500
  5327. };
  5328. var Selector$a = {
  5329. DATA_DISMISS: '[data-dismiss="toast"]'
  5330. };
  5331. /**
  5332. * ------------------------------------------------------------------------
  5333. * Class Definition
  5334. * ------------------------------------------------------------------------
  5335. */
  5336. var Toast =
  5337. /*#__PURE__*/
  5338. function () {
  5339. function Toast(element, config) {
  5340. this._element = element;
  5341. this._config = this._getConfig(config);
  5342. this._timeout = null;
  5343. this._setListeners();
  5344. } // Getters
  5345. var _proto = Toast.prototype;
  5346. // Public
  5347. _proto.show = function show() {
  5348. var _this = this;
  5349. var showEvent = $.Event(Event$a.SHOW);
  5350. $(this._element).trigger(showEvent);
  5351. if (showEvent.isDefaultPrevented()) {
  5352. return;
  5353. }
  5354. if (this._config.animation) {
  5355. this._element.classList.add(ClassName$a.FADE);
  5356. }
  5357. var complete = function complete() {
  5358. _this._element.classList.remove(ClassName$a.SHOWING);
  5359. _this._element.classList.add(ClassName$a.SHOW);
  5360. $(_this._element).trigger(Event$a.SHOWN);
  5361. if (_this._config.autohide) {
  5362. _this._timeout = setTimeout(function () {
  5363. _this.hide();
  5364. }, _this._config.delay);
  5365. }
  5366. };
  5367. this._element.classList.remove(ClassName$a.HIDE);
  5368. Util.reflow(this._element);
  5369. this._element.classList.add(ClassName$a.SHOWING);
  5370. if (this._config.animation) {
  5371. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5372. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5373. } else {
  5374. complete();
  5375. }
  5376. };
  5377. _proto.hide = function hide() {
  5378. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5379. return;
  5380. }
  5381. var hideEvent = $.Event(Event$a.HIDE);
  5382. $(this._element).trigger(hideEvent);
  5383. if (hideEvent.isDefaultPrevented()) {
  5384. return;
  5385. }
  5386. this._close();
  5387. };
  5388. _proto.dispose = function dispose() {
  5389. clearTimeout(this._timeout);
  5390. this._timeout = null;
  5391. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5392. this._element.classList.remove(ClassName$a.SHOW);
  5393. }
  5394. $(this._element).off(Event$a.CLICK_DISMISS);
  5395. $.removeData(this._element, DATA_KEY$a);
  5396. this._element = null;
  5397. this._config = null;
  5398. } // Private
  5399. ;
  5400. _proto._getConfig = function _getConfig(config) {
  5401. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5402. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5403. return config;
  5404. };
  5405. _proto._setListeners = function _setListeners() {
  5406. var _this2 = this;
  5407. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5408. return _this2.hide();
  5409. });
  5410. };
  5411. _proto._close = function _close() {
  5412. var _this3 = this;
  5413. var complete = function complete() {
  5414. _this3._element.classList.add(ClassName$a.HIDE);
  5415. $(_this3._element).trigger(Event$a.HIDDEN);
  5416. };
  5417. this._element.classList.remove(ClassName$a.SHOW);
  5418. if (this._config.animation) {
  5419. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5420. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5421. } else {
  5422. complete();
  5423. }
  5424. } // Static
  5425. ;
  5426. Toast._jQueryInterface = function _jQueryInterface(config) {
  5427. return this.each(function () {
  5428. var $element = $(this);
  5429. var data = $element.data(DATA_KEY$a);
  5430. var _config = typeof config === 'object' && config;
  5431. if (!data) {
  5432. data = new Toast(this, _config);
  5433. $element.data(DATA_KEY$a, data);
  5434. }
  5435. if (typeof config === 'string') {
  5436. if (typeof data[config] === 'undefined') {
  5437. throw new TypeError("No method named \"" + config + "\"");
  5438. }
  5439. data[config](this);
  5440. }
  5441. });
  5442. };
  5443. _createClass(Toast, null, [{
  5444. key: "VERSION",
  5445. get: function get() {
  5446. return VERSION$a;
  5447. }
  5448. }, {
  5449. key: "DefaultType",
  5450. get: function get() {
  5451. return DefaultType$7;
  5452. }
  5453. }, {
  5454. key: "Default",
  5455. get: function get() {
  5456. return Default$7;
  5457. }
  5458. }]);
  5459. return Toast;
  5460. }();
  5461. /**
  5462. * ------------------------------------------------------------------------
  5463. * jQuery
  5464. * ------------------------------------------------------------------------
  5465. */
  5466. $.fn[NAME$a] = Toast._jQueryInterface;
  5467. $.fn[NAME$a].Constructor = Toast;
  5468. $.fn[NAME$a].noConflict = function () {
  5469. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5470. return Toast._jQueryInterface;
  5471. };
  5472. exports.Alert = Alert;
  5473. exports.Button = Button;
  5474. exports.Carousel = Carousel;
  5475. exports.Collapse = Collapse;
  5476. exports.Dropdown = Dropdown;
  5477. exports.Modal = Modal;
  5478. exports.Popover = Popover;
  5479. exports.Scrollspy = ScrollSpy;
  5480. exports.Tab = Tab;
  5481. exports.Toast = Toast;
  5482. exports.Tooltip = Tooltip;
  5483. exports.Util = Util;
  5484. Object.defineProperty(exports, '__esModule', { value: true });
  5485. })));
  5486. //# sourceMappingURL=bootstrap.js.map
  5487. /***/ }),
  5488. /***/ "./node_modules/buffer/index.js":
  5489. /*!**************************************!*\
  5490. !*** ./node_modules/buffer/index.js ***!
  5491. \**************************************/
  5492. /*! no static exports found */
  5493. /***/ (function(module, exports, __webpack_require__) {
  5494. "use strict";
  5495. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5496. * The buffer module from node.js, for the browser.
  5497. *
  5498. * @author Feross Aboukhadijeh <http://feross.org>
  5499. * @license MIT
  5500. */
  5501. /* eslint-disable no-proto */
  5502. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5503. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5504. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5505. exports.Buffer = Buffer
  5506. exports.SlowBuffer = SlowBuffer
  5507. exports.INSPECT_MAX_BYTES = 50
  5508. /**
  5509. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5510. * === true Use Uint8Array implementation (fastest)
  5511. * === false Use Object implementation (most compatible, even IE6)
  5512. *
  5513. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5514. * Opera 11.6+, iOS 4.2+.
  5515. *
  5516. * Due to various browser bugs, sometimes the Object implementation will be used even
  5517. * when the browser supports typed arrays.
  5518. *
  5519. * Note:
  5520. *
  5521. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5522. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5523. *
  5524. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5525. *
  5526. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5527. * incorrect length in some situations.
  5528. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5529. * get the Object implementation, which is slower but behaves correctly.
  5530. */
  5531. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5532. ? global.TYPED_ARRAY_SUPPORT
  5533. : typedArraySupport()
  5534. /*
  5535. * Export kMaxLength after typed array support is determined.
  5536. */
  5537. exports.kMaxLength = kMaxLength()
  5538. function typedArraySupport () {
  5539. try {
  5540. var arr = new Uint8Array(1)
  5541. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5542. return arr.foo() === 42 && // typed array instances can be augmented
  5543. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5544. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5545. } catch (e) {
  5546. return false
  5547. }
  5548. }
  5549. function kMaxLength () {
  5550. return Buffer.TYPED_ARRAY_SUPPORT
  5551. ? 0x7fffffff
  5552. : 0x3fffffff
  5553. }
  5554. function createBuffer (that, length) {
  5555. if (kMaxLength() < length) {
  5556. throw new RangeError('Invalid typed array length')
  5557. }
  5558. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5559. // Return an augmented `Uint8Array` instance, for best performance
  5560. that = new Uint8Array(length)
  5561. that.__proto__ = Buffer.prototype
  5562. } else {
  5563. // Fallback: Return an object instance of the Buffer class
  5564. if (that === null) {
  5565. that = new Buffer(length)
  5566. }
  5567. that.length = length
  5568. }
  5569. return that
  5570. }
  5571. /**
  5572. * The Buffer constructor returns instances of `Uint8Array` that have their
  5573. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5574. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5575. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5576. * returns a single octet.
  5577. *
  5578. * The `Uint8Array` prototype remains unmodified.
  5579. */
  5580. function Buffer (arg, encodingOrOffset, length) {
  5581. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5582. return new Buffer(arg, encodingOrOffset, length)
  5583. }
  5584. // Common case.
  5585. if (typeof arg === 'number') {
  5586. if (typeof encodingOrOffset === 'string') {
  5587. throw new Error(
  5588. 'If encoding is specified then the first argument must be a string'
  5589. )
  5590. }
  5591. return allocUnsafe(this, arg)
  5592. }
  5593. return from(this, arg, encodingOrOffset, length)
  5594. }
  5595. Buffer.poolSize = 8192 // not used by this implementation
  5596. // TODO: Legacy, not needed anymore. Remove in next major version.
  5597. Buffer._augment = function (arr) {
  5598. arr.__proto__ = Buffer.prototype
  5599. return arr
  5600. }
  5601. function from (that, value, encodingOrOffset, length) {
  5602. if (typeof value === 'number') {
  5603. throw new TypeError('"value" argument must not be a number')
  5604. }
  5605. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5606. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5607. }
  5608. if (typeof value === 'string') {
  5609. return fromString(that, value, encodingOrOffset)
  5610. }
  5611. return fromObject(that, value)
  5612. }
  5613. /**
  5614. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5615. * if value is a number.
  5616. * Buffer.from(str[, encoding])
  5617. * Buffer.from(array)
  5618. * Buffer.from(buffer)
  5619. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5620. **/
  5621. Buffer.from = function (value, encodingOrOffset, length) {
  5622. return from(null, value, encodingOrOffset, length)
  5623. }
  5624. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5625. Buffer.prototype.__proto__ = Uint8Array.prototype
  5626. Buffer.__proto__ = Uint8Array
  5627. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5628. Buffer[Symbol.species] === Buffer) {
  5629. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5630. Object.defineProperty(Buffer, Symbol.species, {
  5631. value: null,
  5632. configurable: true
  5633. })
  5634. }
  5635. }
  5636. function assertSize (size) {
  5637. if (typeof size !== 'number') {
  5638. throw new TypeError('"size" argument must be a number')
  5639. } else if (size < 0) {
  5640. throw new RangeError('"size" argument must not be negative')
  5641. }
  5642. }
  5643. function alloc (that, size, fill, encoding) {
  5644. assertSize(size)
  5645. if (size <= 0) {
  5646. return createBuffer(that, size)
  5647. }
  5648. if (fill !== undefined) {
  5649. // Only pay attention to encoding if it's a string. This
  5650. // prevents accidentally sending in a number that would
  5651. // be interpretted as a start offset.
  5652. return typeof encoding === 'string'
  5653. ? createBuffer(that, size).fill(fill, encoding)
  5654. : createBuffer(that, size).fill(fill)
  5655. }
  5656. return createBuffer(that, size)
  5657. }
  5658. /**
  5659. * Creates a new filled Buffer instance.
  5660. * alloc(size[, fill[, encoding]])
  5661. **/
  5662. Buffer.alloc = function (size, fill, encoding) {
  5663. return alloc(null, size, fill, encoding)
  5664. }
  5665. function allocUnsafe (that, size) {
  5666. assertSize(size)
  5667. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5668. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5669. for (var i = 0; i < size; ++i) {
  5670. that[i] = 0
  5671. }
  5672. }
  5673. return that
  5674. }
  5675. /**
  5676. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5677. * */
  5678. Buffer.allocUnsafe = function (size) {
  5679. return allocUnsafe(null, size)
  5680. }
  5681. /**
  5682. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5683. */
  5684. Buffer.allocUnsafeSlow = function (size) {
  5685. return allocUnsafe(null, size)
  5686. }
  5687. function fromString (that, string, encoding) {
  5688. if (typeof encoding !== 'string' || encoding === '') {
  5689. encoding = 'utf8'
  5690. }
  5691. if (!Buffer.isEncoding(encoding)) {
  5692. throw new TypeError('"encoding" must be a valid string encoding')
  5693. }
  5694. var length = byteLength(string, encoding) | 0
  5695. that = createBuffer(that, length)
  5696. var actual = that.write(string, encoding)
  5697. if (actual !== length) {
  5698. // Writing a hex string, for example, that contains invalid characters will
  5699. // cause everything after the first invalid character to be ignored. (e.g.
  5700. // 'abxxcd' will be treated as 'ab')
  5701. that = that.slice(0, actual)
  5702. }
  5703. return that
  5704. }
  5705. function fromArrayLike (that, array) {
  5706. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5707. that = createBuffer(that, length)
  5708. for (var i = 0; i < length; i += 1) {
  5709. that[i] = array[i] & 255
  5710. }
  5711. return that
  5712. }
  5713. function fromArrayBuffer (that, array, byteOffset, length) {
  5714. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5715. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5716. throw new RangeError('\'offset\' is out of bounds')
  5717. }
  5718. if (array.byteLength < byteOffset + (length || 0)) {
  5719. throw new RangeError('\'length\' is out of bounds')
  5720. }
  5721. if (byteOffset === undefined && length === undefined) {
  5722. array = new Uint8Array(array)
  5723. } else if (length === undefined) {
  5724. array = new Uint8Array(array, byteOffset)
  5725. } else {
  5726. array = new Uint8Array(array, byteOffset, length)
  5727. }
  5728. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5729. // Return an augmented `Uint8Array` instance, for best performance
  5730. that = array
  5731. that.__proto__ = Buffer.prototype
  5732. } else {
  5733. // Fallback: Return an object instance of the Buffer class
  5734. that = fromArrayLike(that, array)
  5735. }
  5736. return that
  5737. }
  5738. function fromObject (that, obj) {
  5739. if (Buffer.isBuffer(obj)) {
  5740. var len = checked(obj.length) | 0
  5741. that = createBuffer(that, len)
  5742. if (that.length === 0) {
  5743. return that
  5744. }
  5745. obj.copy(that, 0, 0, len)
  5746. return that
  5747. }
  5748. if (obj) {
  5749. if ((typeof ArrayBuffer !== 'undefined' &&
  5750. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5751. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5752. return createBuffer(that, 0)
  5753. }
  5754. return fromArrayLike(that, obj)
  5755. }
  5756. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5757. return fromArrayLike(that, obj.data)
  5758. }
  5759. }
  5760. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5761. }
  5762. function checked (length) {
  5763. // Note: cannot use `length < kMaxLength()` here because that fails when
  5764. // length is NaN (which is otherwise coerced to zero.)
  5765. if (length >= kMaxLength()) {
  5766. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5767. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5768. }
  5769. return length | 0
  5770. }
  5771. function SlowBuffer (length) {
  5772. if (+length != length) { // eslint-disable-line eqeqeq
  5773. length = 0
  5774. }
  5775. return Buffer.alloc(+length)
  5776. }
  5777. Buffer.isBuffer = function isBuffer (b) {
  5778. return !!(b != null && b._isBuffer)
  5779. }
  5780. Buffer.compare = function compare (a, b) {
  5781. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5782. throw new TypeError('Arguments must be Buffers')
  5783. }
  5784. if (a === b) return 0
  5785. var x = a.length
  5786. var y = b.length
  5787. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5788. if (a[i] !== b[i]) {
  5789. x = a[i]
  5790. y = b[i]
  5791. break
  5792. }
  5793. }
  5794. if (x < y) return -1
  5795. if (y < x) return 1
  5796. return 0
  5797. }
  5798. Buffer.isEncoding = function isEncoding (encoding) {
  5799. switch (String(encoding).toLowerCase()) {
  5800. case 'hex':
  5801. case 'utf8':
  5802. case 'utf-8':
  5803. case 'ascii':
  5804. case 'latin1':
  5805. case 'binary':
  5806. case 'base64':
  5807. case 'ucs2':
  5808. case 'ucs-2':
  5809. case 'utf16le':
  5810. case 'utf-16le':
  5811. return true
  5812. default:
  5813. return false
  5814. }
  5815. }
  5816. Buffer.concat = function concat (list, length) {
  5817. if (!isArray(list)) {
  5818. throw new TypeError('"list" argument must be an Array of Buffers')
  5819. }
  5820. if (list.length === 0) {
  5821. return Buffer.alloc(0)
  5822. }
  5823. var i
  5824. if (length === undefined) {
  5825. length = 0
  5826. for (i = 0; i < list.length; ++i) {
  5827. length += list[i].length
  5828. }
  5829. }
  5830. var buffer = Buffer.allocUnsafe(length)
  5831. var pos = 0
  5832. for (i = 0; i < list.length; ++i) {
  5833. var buf = list[i]
  5834. if (!Buffer.isBuffer(buf)) {
  5835. throw new TypeError('"list" argument must be an Array of Buffers')
  5836. }
  5837. buf.copy(buffer, pos)
  5838. pos += buf.length
  5839. }
  5840. return buffer
  5841. }
  5842. function byteLength (string, encoding) {
  5843. if (Buffer.isBuffer(string)) {
  5844. return string.length
  5845. }
  5846. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5847. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5848. return string.byteLength
  5849. }
  5850. if (typeof string !== 'string') {
  5851. string = '' + string
  5852. }
  5853. var len = string.length
  5854. if (len === 0) return 0
  5855. // Use a for loop to avoid recursion
  5856. var loweredCase = false
  5857. for (;;) {
  5858. switch (encoding) {
  5859. case 'ascii':
  5860. case 'latin1':
  5861. case 'binary':
  5862. return len
  5863. case 'utf8':
  5864. case 'utf-8':
  5865. case undefined:
  5866. return utf8ToBytes(string).length
  5867. case 'ucs2':
  5868. case 'ucs-2':
  5869. case 'utf16le':
  5870. case 'utf-16le':
  5871. return len * 2
  5872. case 'hex':
  5873. return len >>> 1
  5874. case 'base64':
  5875. return base64ToBytes(string).length
  5876. default:
  5877. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5878. encoding = ('' + encoding).toLowerCase()
  5879. loweredCase = true
  5880. }
  5881. }
  5882. }
  5883. Buffer.byteLength = byteLength
  5884. function slowToString (encoding, start, end) {
  5885. var loweredCase = false
  5886. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5887. // property of a typed array.
  5888. // This behaves neither like String nor Uint8Array in that we set start/end
  5889. // to their upper/lower bounds if the value passed is out of range.
  5890. // undefined is handled specially as per ECMA-262 6th Edition,
  5891. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5892. if (start === undefined || start < 0) {
  5893. start = 0
  5894. }
  5895. // Return early if start > this.length. Done here to prevent potential uint32
  5896. // coercion fail below.
  5897. if (start > this.length) {
  5898. return ''
  5899. }
  5900. if (end === undefined || end > this.length) {
  5901. end = this.length
  5902. }
  5903. if (end <= 0) {
  5904. return ''
  5905. }
  5906. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5907. end >>>= 0
  5908. start >>>= 0
  5909. if (end <= start) {
  5910. return ''
  5911. }
  5912. if (!encoding) encoding = 'utf8'
  5913. while (true) {
  5914. switch (encoding) {
  5915. case 'hex':
  5916. return hexSlice(this, start, end)
  5917. case 'utf8':
  5918. case 'utf-8':
  5919. return utf8Slice(this, start, end)
  5920. case 'ascii':
  5921. return asciiSlice(this, start, end)
  5922. case 'latin1':
  5923. case 'binary':
  5924. return latin1Slice(this, start, end)
  5925. case 'base64':
  5926. return base64Slice(this, start, end)
  5927. case 'ucs2':
  5928. case 'ucs-2':
  5929. case 'utf16le':
  5930. case 'utf-16le':
  5931. return utf16leSlice(this, start, end)
  5932. default:
  5933. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5934. encoding = (encoding + '').toLowerCase()
  5935. loweredCase = true
  5936. }
  5937. }
  5938. }
  5939. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5940. // Buffer instances.
  5941. Buffer.prototype._isBuffer = true
  5942. function swap (b, n, m) {
  5943. var i = b[n]
  5944. b[n] = b[m]
  5945. b[m] = i
  5946. }
  5947. Buffer.prototype.swap16 = function swap16 () {
  5948. var len = this.length
  5949. if (len % 2 !== 0) {
  5950. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5951. }
  5952. for (var i = 0; i < len; i += 2) {
  5953. swap(this, i, i + 1)
  5954. }
  5955. return this
  5956. }
  5957. Buffer.prototype.swap32 = function swap32 () {
  5958. var len = this.length
  5959. if (len % 4 !== 0) {
  5960. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5961. }
  5962. for (var i = 0; i < len; i += 4) {
  5963. swap(this, i, i + 3)
  5964. swap(this, i + 1, i + 2)
  5965. }
  5966. return this
  5967. }
  5968. Buffer.prototype.swap64 = function swap64 () {
  5969. var len = this.length
  5970. if (len % 8 !== 0) {
  5971. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5972. }
  5973. for (var i = 0; i < len; i += 8) {
  5974. swap(this, i, i + 7)
  5975. swap(this, i + 1, i + 6)
  5976. swap(this, i + 2, i + 5)
  5977. swap(this, i + 3, i + 4)
  5978. }
  5979. return this
  5980. }
  5981. Buffer.prototype.toString = function toString () {
  5982. var length = this.length | 0
  5983. if (length === 0) return ''
  5984. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5985. return slowToString.apply(this, arguments)
  5986. }
  5987. Buffer.prototype.equals = function equals (b) {
  5988. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5989. if (this === b) return true
  5990. return Buffer.compare(this, b) === 0
  5991. }
  5992. Buffer.prototype.inspect = function inspect () {
  5993. var str = ''
  5994. var max = exports.INSPECT_MAX_BYTES
  5995. if (this.length > 0) {
  5996. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5997. if (this.length > max) str += ' ... '
  5998. }
  5999. return '<Buffer ' + str + '>'
  6000. }
  6001. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6002. if (!Buffer.isBuffer(target)) {
  6003. throw new TypeError('Argument must be a Buffer')
  6004. }
  6005. if (start === undefined) {
  6006. start = 0
  6007. }
  6008. if (end === undefined) {
  6009. end = target ? target.length : 0
  6010. }
  6011. if (thisStart === undefined) {
  6012. thisStart = 0
  6013. }
  6014. if (thisEnd === undefined) {
  6015. thisEnd = this.length
  6016. }
  6017. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6018. throw new RangeError('out of range index')
  6019. }
  6020. if (thisStart >= thisEnd && start >= end) {
  6021. return 0
  6022. }
  6023. if (thisStart >= thisEnd) {
  6024. return -1
  6025. }
  6026. if (start >= end) {
  6027. return 1
  6028. }
  6029. start >>>= 0
  6030. end >>>= 0
  6031. thisStart >>>= 0
  6032. thisEnd >>>= 0
  6033. if (this === target) return 0
  6034. var x = thisEnd - thisStart
  6035. var y = end - start
  6036. var len = Math.min(x, y)
  6037. var thisCopy = this.slice(thisStart, thisEnd)
  6038. var targetCopy = target.slice(start, end)
  6039. for (var i = 0; i < len; ++i) {
  6040. if (thisCopy[i] !== targetCopy[i]) {
  6041. x = thisCopy[i]
  6042. y = targetCopy[i]
  6043. break
  6044. }
  6045. }
  6046. if (x < y) return -1
  6047. if (y < x) return 1
  6048. return 0
  6049. }
  6050. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6051. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6052. //
  6053. // Arguments:
  6054. // - buffer - a Buffer to search
  6055. // - val - a string, Buffer, or number
  6056. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6057. // - encoding - an optional encoding, relevant is val is a string
  6058. // - dir - true for indexOf, false for lastIndexOf
  6059. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6060. // Empty buffer means no match
  6061. if (buffer.length === 0) return -1
  6062. // Normalize byteOffset
  6063. if (typeof byteOffset === 'string') {
  6064. encoding = byteOffset
  6065. byteOffset = 0
  6066. } else if (byteOffset > 0x7fffffff) {
  6067. byteOffset = 0x7fffffff
  6068. } else if (byteOffset < -0x80000000) {
  6069. byteOffset = -0x80000000
  6070. }
  6071. byteOffset = +byteOffset // Coerce to Number.
  6072. if (isNaN(byteOffset)) {
  6073. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6074. byteOffset = dir ? 0 : (buffer.length - 1)
  6075. }
  6076. // Normalize byteOffset: negative offsets start from the end of the buffer
  6077. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6078. if (byteOffset >= buffer.length) {
  6079. if (dir) return -1
  6080. else byteOffset = buffer.length - 1
  6081. } else if (byteOffset < 0) {
  6082. if (dir) byteOffset = 0
  6083. else return -1
  6084. }
  6085. // Normalize val
  6086. if (typeof val === 'string') {
  6087. val = Buffer.from(val, encoding)
  6088. }
  6089. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6090. if (Buffer.isBuffer(val)) {
  6091. // Special case: looking for empty string/buffer always fails
  6092. if (val.length === 0) {
  6093. return -1
  6094. }
  6095. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6096. } else if (typeof val === 'number') {
  6097. val = val & 0xFF // Search for a byte value [0-255]
  6098. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6099. typeof Uint8Array.prototype.indexOf === 'function') {
  6100. if (dir) {
  6101. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6102. } else {
  6103. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6104. }
  6105. }
  6106. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6107. }
  6108. throw new TypeError('val must be string, number or Buffer')
  6109. }
  6110. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6111. var indexSize = 1
  6112. var arrLength = arr.length
  6113. var valLength = val.length
  6114. if (encoding !== undefined) {
  6115. encoding = String(encoding).toLowerCase()
  6116. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6117. encoding === 'utf16le' || encoding === 'utf-16le') {
  6118. if (arr.length < 2 || val.length < 2) {
  6119. return -1
  6120. }
  6121. indexSize = 2
  6122. arrLength /= 2
  6123. valLength /= 2
  6124. byteOffset /= 2
  6125. }
  6126. }
  6127. function read (buf, i) {
  6128. if (indexSize === 1) {
  6129. return buf[i]
  6130. } else {
  6131. return buf.readUInt16BE(i * indexSize)
  6132. }
  6133. }
  6134. var i
  6135. if (dir) {
  6136. var foundIndex = -1
  6137. for (i = byteOffset; i < arrLength; i++) {
  6138. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6139. if (foundIndex === -1) foundIndex = i
  6140. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6141. } else {
  6142. if (foundIndex !== -1) i -= i - foundIndex
  6143. foundIndex = -1
  6144. }
  6145. }
  6146. } else {
  6147. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6148. for (i = byteOffset; i >= 0; i--) {
  6149. var found = true
  6150. for (var j = 0; j < valLength; j++) {
  6151. if (read(arr, i + j) !== read(val, j)) {
  6152. found = false
  6153. break
  6154. }
  6155. }
  6156. if (found) return i
  6157. }
  6158. }
  6159. return -1
  6160. }
  6161. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6162. return this.indexOf(val, byteOffset, encoding) !== -1
  6163. }
  6164. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6165. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6166. }
  6167. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6168. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6169. }
  6170. function hexWrite (buf, string, offset, length) {
  6171. offset = Number(offset) || 0
  6172. var remaining = buf.length - offset
  6173. if (!length) {
  6174. length = remaining
  6175. } else {
  6176. length = Number(length)
  6177. if (length > remaining) {
  6178. length = remaining
  6179. }
  6180. }
  6181. // must be an even number of digits
  6182. var strLen = string.length
  6183. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6184. if (length > strLen / 2) {
  6185. length = strLen / 2
  6186. }
  6187. for (var i = 0; i < length; ++i) {
  6188. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6189. if (isNaN(parsed)) return i
  6190. buf[offset + i] = parsed
  6191. }
  6192. return i
  6193. }
  6194. function utf8Write (buf, string, offset, length) {
  6195. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6196. }
  6197. function asciiWrite (buf, string, offset, length) {
  6198. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6199. }
  6200. function latin1Write (buf, string, offset, length) {
  6201. return asciiWrite(buf, string, offset, length)
  6202. }
  6203. function base64Write (buf, string, offset, length) {
  6204. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6205. }
  6206. function ucs2Write (buf, string, offset, length) {
  6207. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6208. }
  6209. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6210. // Buffer#write(string)
  6211. if (offset === undefined) {
  6212. encoding = 'utf8'
  6213. length = this.length
  6214. offset = 0
  6215. // Buffer#write(string, encoding)
  6216. } else if (length === undefined && typeof offset === 'string') {
  6217. encoding = offset
  6218. length = this.length
  6219. offset = 0
  6220. // Buffer#write(string, offset[, length][, encoding])
  6221. } else if (isFinite(offset)) {
  6222. offset = offset | 0
  6223. if (isFinite(length)) {
  6224. length = length | 0
  6225. if (encoding === undefined) encoding = 'utf8'
  6226. } else {
  6227. encoding = length
  6228. length = undefined
  6229. }
  6230. // legacy write(string, encoding, offset, length) - remove in v0.13
  6231. } else {
  6232. throw new Error(
  6233. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6234. )
  6235. }
  6236. var remaining = this.length - offset
  6237. if (length === undefined || length > remaining) length = remaining
  6238. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6239. throw new RangeError('Attempt to write outside buffer bounds')
  6240. }
  6241. if (!encoding) encoding = 'utf8'
  6242. var loweredCase = false
  6243. for (;;) {
  6244. switch (encoding) {
  6245. case 'hex':
  6246. return hexWrite(this, string, offset, length)
  6247. case 'utf8':
  6248. case 'utf-8':
  6249. return utf8Write(this, string, offset, length)
  6250. case 'ascii':
  6251. return asciiWrite(this, string, offset, length)
  6252. case 'latin1':
  6253. case 'binary':
  6254. return latin1Write(this, string, offset, length)
  6255. case 'base64':
  6256. // Warning: maxLength not taken into account in base64Write
  6257. return base64Write(this, string, offset, length)
  6258. case 'ucs2':
  6259. case 'ucs-2':
  6260. case 'utf16le':
  6261. case 'utf-16le':
  6262. return ucs2Write(this, string, offset, length)
  6263. default:
  6264. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6265. encoding = ('' + encoding).toLowerCase()
  6266. loweredCase = true
  6267. }
  6268. }
  6269. }
  6270. Buffer.prototype.toJSON = function toJSON () {
  6271. return {
  6272. type: 'Buffer',
  6273. data: Array.prototype.slice.call(this._arr || this, 0)
  6274. }
  6275. }
  6276. function base64Slice (buf, start, end) {
  6277. if (start === 0 && end === buf.length) {
  6278. return base64.fromByteArray(buf)
  6279. } else {
  6280. return base64.fromByteArray(buf.slice(start, end))
  6281. }
  6282. }
  6283. function utf8Slice (buf, start, end) {
  6284. end = Math.min(buf.length, end)
  6285. var res = []
  6286. var i = start
  6287. while (i < end) {
  6288. var firstByte = buf[i]
  6289. var codePoint = null
  6290. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6291. : (firstByte > 0xDF) ? 3
  6292. : (firstByte > 0xBF) ? 2
  6293. : 1
  6294. if (i + bytesPerSequence <= end) {
  6295. var secondByte, thirdByte, fourthByte, tempCodePoint
  6296. switch (bytesPerSequence) {
  6297. case 1:
  6298. if (firstByte < 0x80) {
  6299. codePoint = firstByte
  6300. }
  6301. break
  6302. case 2:
  6303. secondByte = buf[i + 1]
  6304. if ((secondByte & 0xC0) === 0x80) {
  6305. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6306. if (tempCodePoint > 0x7F) {
  6307. codePoint = tempCodePoint
  6308. }
  6309. }
  6310. break
  6311. case 3:
  6312. secondByte = buf[i + 1]
  6313. thirdByte = buf[i + 2]
  6314. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6315. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6316. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6317. codePoint = tempCodePoint
  6318. }
  6319. }
  6320. break
  6321. case 4:
  6322. secondByte = buf[i + 1]
  6323. thirdByte = buf[i + 2]
  6324. fourthByte = buf[i + 3]
  6325. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6326. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6327. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6328. codePoint = tempCodePoint
  6329. }
  6330. }
  6331. }
  6332. }
  6333. if (codePoint === null) {
  6334. // we did not generate a valid codePoint so insert a
  6335. // replacement char (U+FFFD) and advance only 1 byte
  6336. codePoint = 0xFFFD
  6337. bytesPerSequence = 1
  6338. } else if (codePoint > 0xFFFF) {
  6339. // encode to utf16 (surrogate pair dance)
  6340. codePoint -= 0x10000
  6341. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6342. codePoint = 0xDC00 | codePoint & 0x3FF
  6343. }
  6344. res.push(codePoint)
  6345. i += bytesPerSequence
  6346. }
  6347. return decodeCodePointsArray(res)
  6348. }
  6349. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6350. // the lowest limit is Chrome, with 0x10000 args.
  6351. // We go 1 magnitude less, for safety
  6352. var MAX_ARGUMENTS_LENGTH = 0x1000
  6353. function decodeCodePointsArray (codePoints) {
  6354. var len = codePoints.length
  6355. if (len <= MAX_ARGUMENTS_LENGTH) {
  6356. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6357. }
  6358. // Decode in chunks to avoid "call stack size exceeded".
  6359. var res = ''
  6360. var i = 0
  6361. while (i < len) {
  6362. res += String.fromCharCode.apply(
  6363. String,
  6364. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6365. )
  6366. }
  6367. return res
  6368. }
  6369. function asciiSlice (buf, start, end) {
  6370. var ret = ''
  6371. end = Math.min(buf.length, end)
  6372. for (var i = start; i < end; ++i) {
  6373. ret += String.fromCharCode(buf[i] & 0x7F)
  6374. }
  6375. return ret
  6376. }
  6377. function latin1Slice (buf, start, end) {
  6378. var ret = ''
  6379. end = Math.min(buf.length, end)
  6380. for (var i = start; i < end; ++i) {
  6381. ret += String.fromCharCode(buf[i])
  6382. }
  6383. return ret
  6384. }
  6385. function hexSlice (buf, start, end) {
  6386. var len = buf.length
  6387. if (!start || start < 0) start = 0
  6388. if (!end || end < 0 || end > len) end = len
  6389. var out = ''
  6390. for (var i = start; i < end; ++i) {
  6391. out += toHex(buf[i])
  6392. }
  6393. return out
  6394. }
  6395. function utf16leSlice (buf, start, end) {
  6396. var bytes = buf.slice(start, end)
  6397. var res = ''
  6398. for (var i = 0; i < bytes.length; i += 2) {
  6399. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6400. }
  6401. return res
  6402. }
  6403. Buffer.prototype.slice = function slice (start, end) {
  6404. var len = this.length
  6405. start = ~~start
  6406. end = end === undefined ? len : ~~end
  6407. if (start < 0) {
  6408. start += len
  6409. if (start < 0) start = 0
  6410. } else if (start > len) {
  6411. start = len
  6412. }
  6413. if (end < 0) {
  6414. end += len
  6415. if (end < 0) end = 0
  6416. } else if (end > len) {
  6417. end = len
  6418. }
  6419. if (end < start) end = start
  6420. var newBuf
  6421. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6422. newBuf = this.subarray(start, end)
  6423. newBuf.__proto__ = Buffer.prototype
  6424. } else {
  6425. var sliceLen = end - start
  6426. newBuf = new Buffer(sliceLen, undefined)
  6427. for (var i = 0; i < sliceLen; ++i) {
  6428. newBuf[i] = this[i + start]
  6429. }
  6430. }
  6431. return newBuf
  6432. }
  6433. /*
  6434. * Need to make sure that buffer isn't trying to write out of bounds.
  6435. */
  6436. function checkOffset (offset, ext, length) {
  6437. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6438. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6439. }
  6440. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6441. offset = offset | 0
  6442. byteLength = byteLength | 0
  6443. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6444. var val = this[offset]
  6445. var mul = 1
  6446. var i = 0
  6447. while (++i < byteLength && (mul *= 0x100)) {
  6448. val += this[offset + i] * mul
  6449. }
  6450. return val
  6451. }
  6452. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6453. offset = offset | 0
  6454. byteLength = byteLength | 0
  6455. if (!noAssert) {
  6456. checkOffset(offset, byteLength, this.length)
  6457. }
  6458. var val = this[offset + --byteLength]
  6459. var mul = 1
  6460. while (byteLength > 0 && (mul *= 0x100)) {
  6461. val += this[offset + --byteLength] * mul
  6462. }
  6463. return val
  6464. }
  6465. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6466. if (!noAssert) checkOffset(offset, 1, this.length)
  6467. return this[offset]
  6468. }
  6469. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6470. if (!noAssert) checkOffset(offset, 2, this.length)
  6471. return this[offset] | (this[offset + 1] << 8)
  6472. }
  6473. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6474. if (!noAssert) checkOffset(offset, 2, this.length)
  6475. return (this[offset] << 8) | this[offset + 1]
  6476. }
  6477. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6478. if (!noAssert) checkOffset(offset, 4, this.length)
  6479. return ((this[offset]) |
  6480. (this[offset + 1] << 8) |
  6481. (this[offset + 2] << 16)) +
  6482. (this[offset + 3] * 0x1000000)
  6483. }
  6484. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6485. if (!noAssert) checkOffset(offset, 4, this.length)
  6486. return (this[offset] * 0x1000000) +
  6487. ((this[offset + 1] << 16) |
  6488. (this[offset + 2] << 8) |
  6489. this[offset + 3])
  6490. }
  6491. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6492. offset = offset | 0
  6493. byteLength = byteLength | 0
  6494. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6495. var val = this[offset]
  6496. var mul = 1
  6497. var i = 0
  6498. while (++i < byteLength && (mul *= 0x100)) {
  6499. val += this[offset + i] * mul
  6500. }
  6501. mul *= 0x80
  6502. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6503. return val
  6504. }
  6505. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6506. offset = offset | 0
  6507. byteLength = byteLength | 0
  6508. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6509. var i = byteLength
  6510. var mul = 1
  6511. var val = this[offset + --i]
  6512. while (i > 0 && (mul *= 0x100)) {
  6513. val += this[offset + --i] * mul
  6514. }
  6515. mul *= 0x80
  6516. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6517. return val
  6518. }
  6519. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6520. if (!noAssert) checkOffset(offset, 1, this.length)
  6521. if (!(this[offset] & 0x80)) return (this[offset])
  6522. return ((0xff - this[offset] + 1) * -1)
  6523. }
  6524. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6525. if (!noAssert) checkOffset(offset, 2, this.length)
  6526. var val = this[offset] | (this[offset + 1] << 8)
  6527. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6528. }
  6529. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6530. if (!noAssert) checkOffset(offset, 2, this.length)
  6531. var val = this[offset + 1] | (this[offset] << 8)
  6532. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6533. }
  6534. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6535. if (!noAssert) checkOffset(offset, 4, this.length)
  6536. return (this[offset]) |
  6537. (this[offset + 1] << 8) |
  6538. (this[offset + 2] << 16) |
  6539. (this[offset + 3] << 24)
  6540. }
  6541. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6542. if (!noAssert) checkOffset(offset, 4, this.length)
  6543. return (this[offset] << 24) |
  6544. (this[offset + 1] << 16) |
  6545. (this[offset + 2] << 8) |
  6546. (this[offset + 3])
  6547. }
  6548. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6549. if (!noAssert) checkOffset(offset, 4, this.length)
  6550. return ieee754.read(this, offset, true, 23, 4)
  6551. }
  6552. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6553. if (!noAssert) checkOffset(offset, 4, this.length)
  6554. return ieee754.read(this, offset, false, 23, 4)
  6555. }
  6556. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6557. if (!noAssert) checkOffset(offset, 8, this.length)
  6558. return ieee754.read(this, offset, true, 52, 8)
  6559. }
  6560. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6561. if (!noAssert) checkOffset(offset, 8, this.length)
  6562. return ieee754.read(this, offset, false, 52, 8)
  6563. }
  6564. function checkInt (buf, value, offset, ext, max, min) {
  6565. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6566. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6567. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6568. }
  6569. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6570. value = +value
  6571. offset = offset | 0
  6572. byteLength = byteLength | 0
  6573. if (!noAssert) {
  6574. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6575. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6576. }
  6577. var mul = 1
  6578. var i = 0
  6579. this[offset] = value & 0xFF
  6580. while (++i < byteLength && (mul *= 0x100)) {
  6581. this[offset + i] = (value / mul) & 0xFF
  6582. }
  6583. return offset + byteLength
  6584. }
  6585. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6586. value = +value
  6587. offset = offset | 0
  6588. byteLength = byteLength | 0
  6589. if (!noAssert) {
  6590. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6591. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6592. }
  6593. var i = byteLength - 1
  6594. var mul = 1
  6595. this[offset + i] = value & 0xFF
  6596. while (--i >= 0 && (mul *= 0x100)) {
  6597. this[offset + i] = (value / mul) & 0xFF
  6598. }
  6599. return offset + byteLength
  6600. }
  6601. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6602. value = +value
  6603. offset = offset | 0
  6604. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6605. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6606. this[offset] = (value & 0xff)
  6607. return offset + 1
  6608. }
  6609. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6610. if (value < 0) value = 0xffff + value + 1
  6611. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6612. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6613. (littleEndian ? i : 1 - i) * 8
  6614. }
  6615. }
  6616. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6617. value = +value
  6618. offset = offset | 0
  6619. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6620. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6621. this[offset] = (value & 0xff)
  6622. this[offset + 1] = (value >>> 8)
  6623. } else {
  6624. objectWriteUInt16(this, value, offset, true)
  6625. }
  6626. return offset + 2
  6627. }
  6628. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6629. value = +value
  6630. offset = offset | 0
  6631. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6632. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6633. this[offset] = (value >>> 8)
  6634. this[offset + 1] = (value & 0xff)
  6635. } else {
  6636. objectWriteUInt16(this, value, offset, false)
  6637. }
  6638. return offset + 2
  6639. }
  6640. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6641. if (value < 0) value = 0xffffffff + value + 1
  6642. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6643. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6644. }
  6645. }
  6646. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6647. value = +value
  6648. offset = offset | 0
  6649. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6650. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6651. this[offset + 3] = (value >>> 24)
  6652. this[offset + 2] = (value >>> 16)
  6653. this[offset + 1] = (value >>> 8)
  6654. this[offset] = (value & 0xff)
  6655. } else {
  6656. objectWriteUInt32(this, value, offset, true)
  6657. }
  6658. return offset + 4
  6659. }
  6660. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6661. value = +value
  6662. offset = offset | 0
  6663. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6664. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6665. this[offset] = (value >>> 24)
  6666. this[offset + 1] = (value >>> 16)
  6667. this[offset + 2] = (value >>> 8)
  6668. this[offset + 3] = (value & 0xff)
  6669. } else {
  6670. objectWriteUInt32(this, value, offset, false)
  6671. }
  6672. return offset + 4
  6673. }
  6674. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6675. value = +value
  6676. offset = offset | 0
  6677. if (!noAssert) {
  6678. var limit = Math.pow(2, 8 * byteLength - 1)
  6679. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6680. }
  6681. var i = 0
  6682. var mul = 1
  6683. var sub = 0
  6684. this[offset] = value & 0xFF
  6685. while (++i < byteLength && (mul *= 0x100)) {
  6686. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6687. sub = 1
  6688. }
  6689. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6690. }
  6691. return offset + byteLength
  6692. }
  6693. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6694. value = +value
  6695. offset = offset | 0
  6696. if (!noAssert) {
  6697. var limit = Math.pow(2, 8 * byteLength - 1)
  6698. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6699. }
  6700. var i = byteLength - 1
  6701. var mul = 1
  6702. var sub = 0
  6703. this[offset + i] = value & 0xFF
  6704. while (--i >= 0 && (mul *= 0x100)) {
  6705. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6706. sub = 1
  6707. }
  6708. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6709. }
  6710. return offset + byteLength
  6711. }
  6712. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6713. value = +value
  6714. offset = offset | 0
  6715. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6716. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6717. if (value < 0) value = 0xff + value + 1
  6718. this[offset] = (value & 0xff)
  6719. return offset + 1
  6720. }
  6721. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6722. value = +value
  6723. offset = offset | 0
  6724. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6725. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6726. this[offset] = (value & 0xff)
  6727. this[offset + 1] = (value >>> 8)
  6728. } else {
  6729. objectWriteUInt16(this, value, offset, true)
  6730. }
  6731. return offset + 2
  6732. }
  6733. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6734. value = +value
  6735. offset = offset | 0
  6736. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6737. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6738. this[offset] = (value >>> 8)
  6739. this[offset + 1] = (value & 0xff)
  6740. } else {
  6741. objectWriteUInt16(this, value, offset, false)
  6742. }
  6743. return offset + 2
  6744. }
  6745. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6746. value = +value
  6747. offset = offset | 0
  6748. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6749. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6750. this[offset] = (value & 0xff)
  6751. this[offset + 1] = (value >>> 8)
  6752. this[offset + 2] = (value >>> 16)
  6753. this[offset + 3] = (value >>> 24)
  6754. } else {
  6755. objectWriteUInt32(this, value, offset, true)
  6756. }
  6757. return offset + 4
  6758. }
  6759. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6760. value = +value
  6761. offset = offset | 0
  6762. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6763. if (value < 0) value = 0xffffffff + value + 1
  6764. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6765. this[offset] = (value >>> 24)
  6766. this[offset + 1] = (value >>> 16)
  6767. this[offset + 2] = (value >>> 8)
  6768. this[offset + 3] = (value & 0xff)
  6769. } else {
  6770. objectWriteUInt32(this, value, offset, false)
  6771. }
  6772. return offset + 4
  6773. }
  6774. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6775. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6776. if (offset < 0) throw new RangeError('Index out of range')
  6777. }
  6778. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6779. if (!noAssert) {
  6780. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6781. }
  6782. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6783. return offset + 4
  6784. }
  6785. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6786. return writeFloat(this, value, offset, true, noAssert)
  6787. }
  6788. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6789. return writeFloat(this, value, offset, false, noAssert)
  6790. }
  6791. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6792. if (!noAssert) {
  6793. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6794. }
  6795. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6796. return offset + 8
  6797. }
  6798. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6799. return writeDouble(this, value, offset, true, noAssert)
  6800. }
  6801. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6802. return writeDouble(this, value, offset, false, noAssert)
  6803. }
  6804. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6805. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6806. if (!start) start = 0
  6807. if (!end && end !== 0) end = this.length
  6808. if (targetStart >= target.length) targetStart = target.length
  6809. if (!targetStart) targetStart = 0
  6810. if (end > 0 && end < start) end = start
  6811. // Copy 0 bytes; we're done
  6812. if (end === start) return 0
  6813. if (target.length === 0 || this.length === 0) return 0
  6814. // Fatal error conditions
  6815. if (targetStart < 0) {
  6816. throw new RangeError('targetStart out of bounds')
  6817. }
  6818. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6819. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6820. // Are we oob?
  6821. if (end > this.length) end = this.length
  6822. if (target.length - targetStart < end - start) {
  6823. end = target.length - targetStart + start
  6824. }
  6825. var len = end - start
  6826. var i
  6827. if (this === target && start < targetStart && targetStart < end) {
  6828. // descending copy from end
  6829. for (i = len - 1; i >= 0; --i) {
  6830. target[i + targetStart] = this[i + start]
  6831. }
  6832. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6833. // ascending copy from start
  6834. for (i = 0; i < len; ++i) {
  6835. target[i + targetStart] = this[i + start]
  6836. }
  6837. } else {
  6838. Uint8Array.prototype.set.call(
  6839. target,
  6840. this.subarray(start, start + len),
  6841. targetStart
  6842. )
  6843. }
  6844. return len
  6845. }
  6846. // Usage:
  6847. // buffer.fill(number[, offset[, end]])
  6848. // buffer.fill(buffer[, offset[, end]])
  6849. // buffer.fill(string[, offset[, end]][, encoding])
  6850. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6851. // Handle string cases:
  6852. if (typeof val === 'string') {
  6853. if (typeof start === 'string') {
  6854. encoding = start
  6855. start = 0
  6856. end = this.length
  6857. } else if (typeof end === 'string') {
  6858. encoding = end
  6859. end = this.length
  6860. }
  6861. if (val.length === 1) {
  6862. var code = val.charCodeAt(0)
  6863. if (code < 256) {
  6864. val = code
  6865. }
  6866. }
  6867. if (encoding !== undefined && typeof encoding !== 'string') {
  6868. throw new TypeError('encoding must be a string')
  6869. }
  6870. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6871. throw new TypeError('Unknown encoding: ' + encoding)
  6872. }
  6873. } else if (typeof val === 'number') {
  6874. val = val & 255
  6875. }
  6876. // Invalid ranges are not set to a default, so can range check early.
  6877. if (start < 0 || this.length < start || this.length < end) {
  6878. throw new RangeError('Out of range index')
  6879. }
  6880. if (end <= start) {
  6881. return this
  6882. }
  6883. start = start >>> 0
  6884. end = end === undefined ? this.length : end >>> 0
  6885. if (!val) val = 0
  6886. var i
  6887. if (typeof val === 'number') {
  6888. for (i = start; i < end; ++i) {
  6889. this[i] = val
  6890. }
  6891. } else {
  6892. var bytes = Buffer.isBuffer(val)
  6893. ? val
  6894. : utf8ToBytes(new Buffer(val, encoding).toString())
  6895. var len = bytes.length
  6896. for (i = 0; i < end - start; ++i) {
  6897. this[i + start] = bytes[i % len]
  6898. }
  6899. }
  6900. return this
  6901. }
  6902. // HELPER FUNCTIONS
  6903. // ================
  6904. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6905. function base64clean (str) {
  6906. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6907. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6908. // Node converts strings with length < 2 to ''
  6909. if (str.length < 2) return ''
  6910. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6911. while (str.length % 4 !== 0) {
  6912. str = str + '='
  6913. }
  6914. return str
  6915. }
  6916. function stringtrim (str) {
  6917. if (str.trim) return str.trim()
  6918. return str.replace(/^\s+|\s+$/g, '')
  6919. }
  6920. function toHex (n) {
  6921. if (n < 16) return '0' + n.toString(16)
  6922. return n.toString(16)
  6923. }
  6924. function utf8ToBytes (string, units) {
  6925. units = units || Infinity
  6926. var codePoint
  6927. var length = string.length
  6928. var leadSurrogate = null
  6929. var bytes = []
  6930. for (var i = 0; i < length; ++i) {
  6931. codePoint = string.charCodeAt(i)
  6932. // is surrogate component
  6933. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6934. // last char was a lead
  6935. if (!leadSurrogate) {
  6936. // no lead yet
  6937. if (codePoint > 0xDBFF) {
  6938. // unexpected trail
  6939. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6940. continue
  6941. } else if (i + 1 === length) {
  6942. // unpaired lead
  6943. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6944. continue
  6945. }
  6946. // valid lead
  6947. leadSurrogate = codePoint
  6948. continue
  6949. }
  6950. // 2 leads in a row
  6951. if (codePoint < 0xDC00) {
  6952. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6953. leadSurrogate = codePoint
  6954. continue
  6955. }
  6956. // valid surrogate pair
  6957. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6958. } else if (leadSurrogate) {
  6959. // valid bmp char, but last char was a lead
  6960. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6961. }
  6962. leadSurrogate = null
  6963. // encode utf8
  6964. if (codePoint < 0x80) {
  6965. if ((units -= 1) < 0) break
  6966. bytes.push(codePoint)
  6967. } else if (codePoint < 0x800) {
  6968. if ((units -= 2) < 0) break
  6969. bytes.push(
  6970. codePoint >> 0x6 | 0xC0,
  6971. codePoint & 0x3F | 0x80
  6972. )
  6973. } else if (codePoint < 0x10000) {
  6974. if ((units -= 3) < 0) break
  6975. bytes.push(
  6976. codePoint >> 0xC | 0xE0,
  6977. codePoint >> 0x6 & 0x3F | 0x80,
  6978. codePoint & 0x3F | 0x80
  6979. )
  6980. } else if (codePoint < 0x110000) {
  6981. if ((units -= 4) < 0) break
  6982. bytes.push(
  6983. codePoint >> 0x12 | 0xF0,
  6984. codePoint >> 0xC & 0x3F | 0x80,
  6985. codePoint >> 0x6 & 0x3F | 0x80,
  6986. codePoint & 0x3F | 0x80
  6987. )
  6988. } else {
  6989. throw new Error('Invalid code point')
  6990. }
  6991. }
  6992. return bytes
  6993. }
  6994. function asciiToBytes (str) {
  6995. var byteArray = []
  6996. for (var i = 0; i < str.length; ++i) {
  6997. // Node's code seems to be doing this and not & 0x7F..
  6998. byteArray.push(str.charCodeAt(i) & 0xFF)
  6999. }
  7000. return byteArray
  7001. }
  7002. function utf16leToBytes (str, units) {
  7003. var c, hi, lo
  7004. var byteArray = []
  7005. for (var i = 0; i < str.length; ++i) {
  7006. if ((units -= 2) < 0) break
  7007. c = str.charCodeAt(i)
  7008. hi = c >> 8
  7009. lo = c % 256
  7010. byteArray.push(lo)
  7011. byteArray.push(hi)
  7012. }
  7013. return byteArray
  7014. }
  7015. function base64ToBytes (str) {
  7016. return base64.toByteArray(base64clean(str))
  7017. }
  7018. function blitBuffer (src, dst, offset, length) {
  7019. for (var i = 0; i < length; ++i) {
  7020. if ((i + offset >= dst.length) || (i >= src.length)) break
  7021. dst[i + offset] = src[i]
  7022. }
  7023. return i
  7024. }
  7025. function isnan (val) {
  7026. return val !== val // eslint-disable-line no-self-compare
  7027. }
  7028. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7029. /***/ }),
  7030. /***/ "./node_modules/ieee754/index.js":
  7031. /*!***************************************!*\
  7032. !*** ./node_modules/ieee754/index.js ***!
  7033. \***************************************/
  7034. /*! no static exports found */
  7035. /***/ (function(module, exports) {
  7036. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7037. var e, m
  7038. var eLen = (nBytes * 8) - mLen - 1
  7039. var eMax = (1 << eLen) - 1
  7040. var eBias = eMax >> 1
  7041. var nBits = -7
  7042. var i = isLE ? (nBytes - 1) : 0
  7043. var d = isLE ? -1 : 1
  7044. var s = buffer[offset + i]
  7045. i += d
  7046. e = s & ((1 << (-nBits)) - 1)
  7047. s >>= (-nBits)
  7048. nBits += eLen
  7049. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7050. m = e & ((1 << (-nBits)) - 1)
  7051. e >>= (-nBits)
  7052. nBits += mLen
  7053. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7054. if (e === 0) {
  7055. e = 1 - eBias
  7056. } else if (e === eMax) {
  7057. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7058. } else {
  7059. m = m + Math.pow(2, mLen)
  7060. e = e - eBias
  7061. }
  7062. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7063. }
  7064. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7065. var e, m, c
  7066. var eLen = (nBytes * 8) - mLen - 1
  7067. var eMax = (1 << eLen) - 1
  7068. var eBias = eMax >> 1
  7069. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7070. var i = isLE ? 0 : (nBytes - 1)
  7071. var d = isLE ? 1 : -1
  7072. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7073. value = Math.abs(value)
  7074. if (isNaN(value) || value === Infinity) {
  7075. m = isNaN(value) ? 1 : 0
  7076. e = eMax
  7077. } else {
  7078. e = Math.floor(Math.log(value) / Math.LN2)
  7079. if (value * (c = Math.pow(2, -e)) < 1) {
  7080. e--
  7081. c *= 2
  7082. }
  7083. if (e + eBias >= 1) {
  7084. value += rt / c
  7085. } else {
  7086. value += rt * Math.pow(2, 1 - eBias)
  7087. }
  7088. if (value * c >= 2) {
  7089. e++
  7090. c /= 2
  7091. }
  7092. if (e + eBias >= eMax) {
  7093. m = 0
  7094. e = eMax
  7095. } else if (e + eBias >= 1) {
  7096. m = ((value * c) - 1) * Math.pow(2, mLen)
  7097. e = e + eBias
  7098. } else {
  7099. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7100. e = 0
  7101. }
  7102. }
  7103. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7104. e = (e << mLen) | m
  7105. eLen += mLen
  7106. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7107. buffer[offset + i - d] |= s * 128
  7108. }
  7109. /***/ }),
  7110. /***/ "./node_modules/isarray/index.js":
  7111. /*!***************************************!*\
  7112. !*** ./node_modules/isarray/index.js ***!
  7113. \***************************************/
  7114. /*! no static exports found */
  7115. /***/ (function(module, exports) {
  7116. var toString = {}.toString;
  7117. module.exports = Array.isArray || function (arr) {
  7118. return toString.call(arr) == '[object Array]';
  7119. };
  7120. /***/ }),
  7121. /***/ "./node_modules/jquery/dist/jquery.js":
  7122. /*!********************************************!*\
  7123. !*** ./node_modules/jquery/dist/jquery.js ***!
  7124. \********************************************/
  7125. /*! no static exports found */
  7126. /***/ (function(module, exports, __webpack_require__) {
  7127. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7128. * jQuery JavaScript Library v3.4.1
  7129. * https://jquery.com/
  7130. *
  7131. * Includes Sizzle.js
  7132. * https://sizzlejs.com/
  7133. *
  7134. * Copyright JS Foundation and other contributors
  7135. * Released under the MIT license
  7136. * https://jquery.org/license
  7137. *
  7138. * Date: 2019-05-01T21:04Z
  7139. */
  7140. ( function( global, factory ) {
  7141. "use strict";
  7142. if ( true && typeof module.exports === "object" ) {
  7143. // For CommonJS and CommonJS-like environments where a proper `window`
  7144. // is present, execute the factory and get jQuery.
  7145. // For environments that do not have a `window` with a `document`
  7146. // (such as Node.js), expose a factory as module.exports.
  7147. // This accentuates the need for the creation of a real `window`.
  7148. // e.g. var jQuery = require("jquery")(window);
  7149. // See ticket #14549 for more info.
  7150. module.exports = global.document ?
  7151. factory( global, true ) :
  7152. function( w ) {
  7153. if ( !w.document ) {
  7154. throw new Error( "jQuery requires a window with a document" );
  7155. }
  7156. return factory( w );
  7157. };
  7158. } else {
  7159. factory( global );
  7160. }
  7161. // Pass this if window is not defined yet
  7162. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7163. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7164. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7165. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7166. // enough that all such attempts are guarded in a try block.
  7167. "use strict";
  7168. var arr = [];
  7169. var document = window.document;
  7170. var getProto = Object.getPrototypeOf;
  7171. var slice = arr.slice;
  7172. var concat = arr.concat;
  7173. var push = arr.push;
  7174. var indexOf = arr.indexOf;
  7175. var class2type = {};
  7176. var toString = class2type.toString;
  7177. var hasOwn = class2type.hasOwnProperty;
  7178. var fnToString = hasOwn.toString;
  7179. var ObjectFunctionString = fnToString.call( Object );
  7180. var support = {};
  7181. var isFunction = function isFunction( obj ) {
  7182. // Support: Chrome <=57, Firefox <=52
  7183. // In some browsers, typeof returns "function" for HTML <object> elements
  7184. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7185. // We don't want to classify *any* DOM node as a function.
  7186. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7187. };
  7188. var isWindow = function isWindow( obj ) {
  7189. return obj != null && obj === obj.window;
  7190. };
  7191. var preservedScriptAttributes = {
  7192. type: true,
  7193. src: true,
  7194. nonce: true,
  7195. noModule: true
  7196. };
  7197. function DOMEval( code, node, doc ) {
  7198. doc = doc || document;
  7199. var i, val,
  7200. script = doc.createElement( "script" );
  7201. script.text = code;
  7202. if ( node ) {
  7203. for ( i in preservedScriptAttributes ) {
  7204. // Support: Firefox 64+, Edge 18+
  7205. // Some browsers don't support the "nonce" property on scripts.
  7206. // On the other hand, just using `getAttribute` is not enough as
  7207. // the `nonce` attribute is reset to an empty string whenever it
  7208. // becomes browsing-context connected.
  7209. // See https://github.com/whatwg/html/issues/2369
  7210. // See https://html.spec.whatwg.org/#nonce-attributes
  7211. // The `node.getAttribute` check was added for the sake of
  7212. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7213. // via an object.
  7214. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7215. if ( val ) {
  7216. script.setAttribute( i, val );
  7217. }
  7218. }
  7219. }
  7220. doc.head.appendChild( script ).parentNode.removeChild( script );
  7221. }
  7222. function toType( obj ) {
  7223. if ( obj == null ) {
  7224. return obj + "";
  7225. }
  7226. // Support: Android <=2.3 only (functionish RegExp)
  7227. return typeof obj === "object" || typeof obj === "function" ?
  7228. class2type[ toString.call( obj ) ] || "object" :
  7229. typeof obj;
  7230. }
  7231. /* global Symbol */
  7232. // Defining this global in .eslintrc.json would create a danger of using the global
  7233. // unguarded in another place, it seems safer to define global only for this module
  7234. var
  7235. version = "3.4.1",
  7236. // Define a local copy of jQuery
  7237. jQuery = function( selector, context ) {
  7238. // The jQuery object is actually just the init constructor 'enhanced'
  7239. // Need init if jQuery is called (just allow error to be thrown if not included)
  7240. return new jQuery.fn.init( selector, context );
  7241. },
  7242. // Support: Android <=4.0 only
  7243. // Make sure we trim BOM and NBSP
  7244. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7245. jQuery.fn = jQuery.prototype = {
  7246. // The current version of jQuery being used
  7247. jquery: version,
  7248. constructor: jQuery,
  7249. // The default length of a jQuery object is 0
  7250. length: 0,
  7251. toArray: function() {
  7252. return slice.call( this );
  7253. },
  7254. // Get the Nth element in the matched element set OR
  7255. // Get the whole matched element set as a clean array
  7256. get: function( num ) {
  7257. // Return all the elements in a clean array
  7258. if ( num == null ) {
  7259. return slice.call( this );
  7260. }
  7261. // Return just the one element from the set
  7262. return num < 0 ? this[ num + this.length ] : this[ num ];
  7263. },
  7264. // Take an array of elements and push it onto the stack
  7265. // (returning the new matched element set)
  7266. pushStack: function( elems ) {
  7267. // Build a new jQuery matched element set
  7268. var ret = jQuery.merge( this.constructor(), elems );
  7269. // Add the old object onto the stack (as a reference)
  7270. ret.prevObject = this;
  7271. // Return the newly-formed element set
  7272. return ret;
  7273. },
  7274. // Execute a callback for every element in the matched set.
  7275. each: function( callback ) {
  7276. return jQuery.each( this, callback );
  7277. },
  7278. map: function( callback ) {
  7279. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7280. return callback.call( elem, i, elem );
  7281. } ) );
  7282. },
  7283. slice: function() {
  7284. return this.pushStack( slice.apply( this, arguments ) );
  7285. },
  7286. first: function() {
  7287. return this.eq( 0 );
  7288. },
  7289. last: function() {
  7290. return this.eq( -1 );
  7291. },
  7292. eq: function( i ) {
  7293. var len = this.length,
  7294. j = +i + ( i < 0 ? len : 0 );
  7295. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7296. },
  7297. end: function() {
  7298. return this.prevObject || this.constructor();
  7299. },
  7300. // For internal use only.
  7301. // Behaves like an Array's method, not like a jQuery method.
  7302. push: push,
  7303. sort: arr.sort,
  7304. splice: arr.splice
  7305. };
  7306. jQuery.extend = jQuery.fn.extend = function() {
  7307. var options, name, src, copy, copyIsArray, clone,
  7308. target = arguments[ 0 ] || {},
  7309. i = 1,
  7310. length = arguments.length,
  7311. deep = false;
  7312. // Handle a deep copy situation
  7313. if ( typeof target === "boolean" ) {
  7314. deep = target;
  7315. // Skip the boolean and the target
  7316. target = arguments[ i ] || {};
  7317. i++;
  7318. }
  7319. // Handle case when target is a string or something (possible in deep copy)
  7320. if ( typeof target !== "object" && !isFunction( target ) ) {
  7321. target = {};
  7322. }
  7323. // Extend jQuery itself if only one argument is passed
  7324. if ( i === length ) {
  7325. target = this;
  7326. i--;
  7327. }
  7328. for ( ; i < length; i++ ) {
  7329. // Only deal with non-null/undefined values
  7330. if ( ( options = arguments[ i ] ) != null ) {
  7331. // Extend the base object
  7332. for ( name in options ) {
  7333. copy = options[ name ];
  7334. // Prevent Object.prototype pollution
  7335. // Prevent never-ending loop
  7336. if ( name === "__proto__" || target === copy ) {
  7337. continue;
  7338. }
  7339. // Recurse if we're merging plain objects or arrays
  7340. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7341. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7342. src = target[ name ];
  7343. // Ensure proper type for the source value
  7344. if ( copyIsArray && !Array.isArray( src ) ) {
  7345. clone = [];
  7346. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7347. clone = {};
  7348. } else {
  7349. clone = src;
  7350. }
  7351. copyIsArray = false;
  7352. // Never move original objects, clone them
  7353. target[ name ] = jQuery.extend( deep, clone, copy );
  7354. // Don't bring in undefined values
  7355. } else if ( copy !== undefined ) {
  7356. target[ name ] = copy;
  7357. }
  7358. }
  7359. }
  7360. }
  7361. // Return the modified object
  7362. return target;
  7363. };
  7364. jQuery.extend( {
  7365. // Unique for each copy of jQuery on the page
  7366. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7367. // Assume jQuery is ready without the ready module
  7368. isReady: true,
  7369. error: function( msg ) {
  7370. throw new Error( msg );
  7371. },
  7372. noop: function() {},
  7373. isPlainObject: function( obj ) {
  7374. var proto, Ctor;
  7375. // Detect obvious negatives
  7376. // Use toString instead of jQuery.type to catch host objects
  7377. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7378. return false;
  7379. }
  7380. proto = getProto( obj );
  7381. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7382. if ( !proto ) {
  7383. return true;
  7384. }
  7385. // Objects with prototype are plain iff they were constructed by a global Object function
  7386. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7387. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7388. },
  7389. isEmptyObject: function( obj ) {
  7390. var name;
  7391. for ( name in obj ) {
  7392. return false;
  7393. }
  7394. return true;
  7395. },
  7396. // Evaluates a script in a global context
  7397. globalEval: function( code, options ) {
  7398. DOMEval( code, { nonce: options && options.nonce } );
  7399. },
  7400. each: function( obj, callback ) {
  7401. var length, i = 0;
  7402. if ( isArrayLike( obj ) ) {
  7403. length = obj.length;
  7404. for ( ; i < length; i++ ) {
  7405. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7406. break;
  7407. }
  7408. }
  7409. } else {
  7410. for ( i in obj ) {
  7411. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7412. break;
  7413. }
  7414. }
  7415. }
  7416. return obj;
  7417. },
  7418. // Support: Android <=4.0 only
  7419. trim: function( text ) {
  7420. return text == null ?
  7421. "" :
  7422. ( text + "" ).replace( rtrim, "" );
  7423. },
  7424. // results is for internal usage only
  7425. makeArray: function( arr, results ) {
  7426. var ret = results || [];
  7427. if ( arr != null ) {
  7428. if ( isArrayLike( Object( arr ) ) ) {
  7429. jQuery.merge( ret,
  7430. typeof arr === "string" ?
  7431. [ arr ] : arr
  7432. );
  7433. } else {
  7434. push.call( ret, arr );
  7435. }
  7436. }
  7437. return ret;
  7438. },
  7439. inArray: function( elem, arr, i ) {
  7440. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7441. },
  7442. // Support: Android <=4.0 only, PhantomJS 1 only
  7443. // push.apply(_, arraylike) throws on ancient WebKit
  7444. merge: function( first, second ) {
  7445. var len = +second.length,
  7446. j = 0,
  7447. i = first.length;
  7448. for ( ; j < len; j++ ) {
  7449. first[ i++ ] = second[ j ];
  7450. }
  7451. first.length = i;
  7452. return first;
  7453. },
  7454. grep: function( elems, callback, invert ) {
  7455. var callbackInverse,
  7456. matches = [],
  7457. i = 0,
  7458. length = elems.length,
  7459. callbackExpect = !invert;
  7460. // Go through the array, only saving the items
  7461. // that pass the validator function
  7462. for ( ; i < length; i++ ) {
  7463. callbackInverse = !callback( elems[ i ], i );
  7464. if ( callbackInverse !== callbackExpect ) {
  7465. matches.push( elems[ i ] );
  7466. }
  7467. }
  7468. return matches;
  7469. },
  7470. // arg is for internal usage only
  7471. map: function( elems, callback, arg ) {
  7472. var length, value,
  7473. i = 0,
  7474. ret = [];
  7475. // Go through the array, translating each of the items to their new values
  7476. if ( isArrayLike( elems ) ) {
  7477. length = elems.length;
  7478. for ( ; i < length; i++ ) {
  7479. value = callback( elems[ i ], i, arg );
  7480. if ( value != null ) {
  7481. ret.push( value );
  7482. }
  7483. }
  7484. // Go through every key on the object,
  7485. } else {
  7486. for ( i in elems ) {
  7487. value = callback( elems[ i ], i, arg );
  7488. if ( value != null ) {
  7489. ret.push( value );
  7490. }
  7491. }
  7492. }
  7493. // Flatten any nested arrays
  7494. return concat.apply( [], ret );
  7495. },
  7496. // A global GUID counter for objects
  7497. guid: 1,
  7498. // jQuery.support is not used in Core but other projects attach their
  7499. // properties to it so it needs to exist.
  7500. support: support
  7501. } );
  7502. if ( typeof Symbol === "function" ) {
  7503. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7504. }
  7505. // Populate the class2type map
  7506. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7507. function( i, name ) {
  7508. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7509. } );
  7510. function isArrayLike( obj ) {
  7511. // Support: real iOS 8.2 only (not reproducible in simulator)
  7512. // `in` check used to prevent JIT error (gh-2145)
  7513. // hasOwn isn't used here due to false negatives
  7514. // regarding Nodelist length in IE
  7515. var length = !!obj && "length" in obj && obj.length,
  7516. type = toType( obj );
  7517. if ( isFunction( obj ) || isWindow( obj ) ) {
  7518. return false;
  7519. }
  7520. return type === "array" || length === 0 ||
  7521. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7522. }
  7523. var Sizzle =
  7524. /*!
  7525. * Sizzle CSS Selector Engine v2.3.4
  7526. * https://sizzlejs.com/
  7527. *
  7528. * Copyright JS Foundation and other contributors
  7529. * Released under the MIT license
  7530. * https://js.foundation/
  7531. *
  7532. * Date: 2019-04-08
  7533. */
  7534. (function( window ) {
  7535. var i,
  7536. support,
  7537. Expr,
  7538. getText,
  7539. isXML,
  7540. tokenize,
  7541. compile,
  7542. select,
  7543. outermostContext,
  7544. sortInput,
  7545. hasDuplicate,
  7546. // Local document vars
  7547. setDocument,
  7548. document,
  7549. docElem,
  7550. documentIsHTML,
  7551. rbuggyQSA,
  7552. rbuggyMatches,
  7553. matches,
  7554. contains,
  7555. // Instance-specific data
  7556. expando = "sizzle" + 1 * new Date(),
  7557. preferredDoc = window.document,
  7558. dirruns = 0,
  7559. done = 0,
  7560. classCache = createCache(),
  7561. tokenCache = createCache(),
  7562. compilerCache = createCache(),
  7563. nonnativeSelectorCache = createCache(),
  7564. sortOrder = function( a, b ) {
  7565. if ( a === b ) {
  7566. hasDuplicate = true;
  7567. }
  7568. return 0;
  7569. },
  7570. // Instance methods
  7571. hasOwn = ({}).hasOwnProperty,
  7572. arr = [],
  7573. pop = arr.pop,
  7574. push_native = arr.push,
  7575. push = arr.push,
  7576. slice = arr.slice,
  7577. // Use a stripped-down indexOf as it's faster than native
  7578. // https://jsperf.com/thor-indexof-vs-for/5
  7579. indexOf = function( list, elem ) {
  7580. var i = 0,
  7581. len = list.length;
  7582. for ( ; i < len; i++ ) {
  7583. if ( list[i] === elem ) {
  7584. return i;
  7585. }
  7586. }
  7587. return -1;
  7588. },
  7589. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7590. // Regular expressions
  7591. // http://www.w3.org/TR/css3-selectors/#whitespace
  7592. whitespace = "[\\x20\\t\\r\\n\\f]",
  7593. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7594. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7595. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7596. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7597. // Operator (capture 2)
  7598. "*([*^$|!~]?=)" + whitespace +
  7599. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7600. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7601. "*\\]",
  7602. pseudos = ":(" + identifier + ")(?:\\((" +
  7603. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7604. // 1. quoted (capture 3; capture 4 or capture 5)
  7605. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7606. // 2. simple (capture 6)
  7607. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7608. // 3. anything else (capture 2)
  7609. ".*" +
  7610. ")\\)|)",
  7611. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7612. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7613. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7614. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7615. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7616. rdescend = new RegExp( whitespace + "|>" ),
  7617. rpseudo = new RegExp( pseudos ),
  7618. ridentifier = new RegExp( "^" + identifier + "$" ),
  7619. matchExpr = {
  7620. "ID": new RegExp( "^#(" + identifier + ")" ),
  7621. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7622. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7623. "ATTR": new RegExp( "^" + attributes ),
  7624. "PSEUDO": new RegExp( "^" + pseudos ),
  7625. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7626. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7627. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7628. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7629. // For use in libraries implementing .is()
  7630. // We use this for POS matching in `select`
  7631. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7632. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7633. },
  7634. rhtml = /HTML$/i,
  7635. rinputs = /^(?:input|select|textarea|button)$/i,
  7636. rheader = /^h\d$/i,
  7637. rnative = /^[^{]+\{\s*\[native \w/,
  7638. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7639. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7640. rsibling = /[+~]/,
  7641. // CSS escapes
  7642. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7643. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7644. funescape = function( _, escaped, escapedWhitespace ) {
  7645. var high = "0x" + escaped - 0x10000;
  7646. // NaN means non-codepoint
  7647. // Support: Firefox<24
  7648. // Workaround erroneous numeric interpretation of +"0x"
  7649. return high !== high || escapedWhitespace ?
  7650. escaped :
  7651. high < 0 ?
  7652. // BMP codepoint
  7653. String.fromCharCode( high + 0x10000 ) :
  7654. // Supplemental Plane codepoint (surrogate pair)
  7655. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7656. },
  7657. // CSS string/identifier serialization
  7658. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7659. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7660. fcssescape = function( ch, asCodePoint ) {
  7661. if ( asCodePoint ) {
  7662. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7663. if ( ch === "\0" ) {
  7664. return "\uFFFD";
  7665. }
  7666. // Control characters and (dependent upon position) numbers get escaped as code points
  7667. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7668. }
  7669. // Other potentially-special ASCII characters get backslash-escaped
  7670. return "\\" + ch;
  7671. },
  7672. // Used for iframes
  7673. // See setDocument()
  7674. // Removing the function wrapper causes a "Permission Denied"
  7675. // error in IE
  7676. unloadHandler = function() {
  7677. setDocument();
  7678. },
  7679. inDisabledFieldset = addCombinator(
  7680. function( elem ) {
  7681. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7682. },
  7683. { dir: "parentNode", next: "legend" }
  7684. );
  7685. // Optimize for push.apply( _, NodeList )
  7686. try {
  7687. push.apply(
  7688. (arr = slice.call( preferredDoc.childNodes )),
  7689. preferredDoc.childNodes
  7690. );
  7691. // Support: Android<4.0
  7692. // Detect silently failing push.apply
  7693. arr[ preferredDoc.childNodes.length ].nodeType;
  7694. } catch ( e ) {
  7695. push = { apply: arr.length ?
  7696. // Leverage slice if possible
  7697. function( target, els ) {
  7698. push_native.apply( target, slice.call(els) );
  7699. } :
  7700. // Support: IE<9
  7701. // Otherwise append directly
  7702. function( target, els ) {
  7703. var j = target.length,
  7704. i = 0;
  7705. // Can't trust NodeList.length
  7706. while ( (target[j++] = els[i++]) ) {}
  7707. target.length = j - 1;
  7708. }
  7709. };
  7710. }
  7711. function Sizzle( selector, context, results, seed ) {
  7712. var m, i, elem, nid, match, groups, newSelector,
  7713. newContext = context && context.ownerDocument,
  7714. // nodeType defaults to 9, since context defaults to document
  7715. nodeType = context ? context.nodeType : 9;
  7716. results = results || [];
  7717. // Return early from calls with invalid selector or context
  7718. if ( typeof selector !== "string" || !selector ||
  7719. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7720. return results;
  7721. }
  7722. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7723. if ( !seed ) {
  7724. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7725. setDocument( context );
  7726. }
  7727. context = context || document;
  7728. if ( documentIsHTML ) {
  7729. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7730. // (excepting DocumentFragment context, where the methods don't exist)
  7731. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7732. // ID selector
  7733. if ( (m = match[1]) ) {
  7734. // Document context
  7735. if ( nodeType === 9 ) {
  7736. if ( (elem = context.getElementById( m )) ) {
  7737. // Support: IE, Opera, Webkit
  7738. // TODO: identify versions
  7739. // getElementById can match elements by name instead of ID
  7740. if ( elem.id === m ) {
  7741. results.push( elem );
  7742. return results;
  7743. }
  7744. } else {
  7745. return results;
  7746. }
  7747. // Element context
  7748. } else {
  7749. // Support: IE, Opera, Webkit
  7750. // TODO: identify versions
  7751. // getElementById can match elements by name instead of ID
  7752. if ( newContext && (elem = newContext.getElementById( m )) &&
  7753. contains( context, elem ) &&
  7754. elem.id === m ) {
  7755. results.push( elem );
  7756. return results;
  7757. }
  7758. }
  7759. // Type selector
  7760. } else if ( match[2] ) {
  7761. push.apply( results, context.getElementsByTagName( selector ) );
  7762. return results;
  7763. // Class selector
  7764. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7765. context.getElementsByClassName ) {
  7766. push.apply( results, context.getElementsByClassName( m ) );
  7767. return results;
  7768. }
  7769. }
  7770. // Take advantage of querySelectorAll
  7771. if ( support.qsa &&
  7772. !nonnativeSelectorCache[ selector + " " ] &&
  7773. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7774. // Support: IE 8 only
  7775. // Exclude object elements
  7776. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7777. newSelector = selector;
  7778. newContext = context;
  7779. // qSA considers elements outside a scoping root when evaluating child or
  7780. // descendant combinators, which is not what we want.
  7781. // In such cases, we work around the behavior by prefixing every selector in the
  7782. // list with an ID selector referencing the scope context.
  7783. // Thanks to Andrew Dupont for this technique.
  7784. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7785. // Capture the context ID, setting it first if necessary
  7786. if ( (nid = context.getAttribute( "id" )) ) {
  7787. nid = nid.replace( rcssescape, fcssescape );
  7788. } else {
  7789. context.setAttribute( "id", (nid = expando) );
  7790. }
  7791. // Prefix every selector in the list
  7792. groups = tokenize( selector );
  7793. i = groups.length;
  7794. while ( i-- ) {
  7795. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7796. }
  7797. newSelector = groups.join( "," );
  7798. // Expand context for sibling selectors
  7799. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7800. context;
  7801. }
  7802. try {
  7803. push.apply( results,
  7804. newContext.querySelectorAll( newSelector )
  7805. );
  7806. return results;
  7807. } catch ( qsaError ) {
  7808. nonnativeSelectorCache( selector, true );
  7809. } finally {
  7810. if ( nid === expando ) {
  7811. context.removeAttribute( "id" );
  7812. }
  7813. }
  7814. }
  7815. }
  7816. }
  7817. // All others
  7818. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7819. }
  7820. /**
  7821. * Create key-value caches of limited size
  7822. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7823. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7824. * deleting the oldest entry
  7825. */
  7826. function createCache() {
  7827. var keys = [];
  7828. function cache( key, value ) {
  7829. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7830. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7831. // Only keep the most recent entries
  7832. delete cache[ keys.shift() ];
  7833. }
  7834. return (cache[ key + " " ] = value);
  7835. }
  7836. return cache;
  7837. }
  7838. /**
  7839. * Mark a function for special use by Sizzle
  7840. * @param {Function} fn The function to mark
  7841. */
  7842. function markFunction( fn ) {
  7843. fn[ expando ] = true;
  7844. return fn;
  7845. }
  7846. /**
  7847. * Support testing using an element
  7848. * @param {Function} fn Passed the created element and returns a boolean result
  7849. */
  7850. function assert( fn ) {
  7851. var el = document.createElement("fieldset");
  7852. try {
  7853. return !!fn( el );
  7854. } catch (e) {
  7855. return false;
  7856. } finally {
  7857. // Remove from its parent by default
  7858. if ( el.parentNode ) {
  7859. el.parentNode.removeChild( el );
  7860. }
  7861. // release memory in IE
  7862. el = null;
  7863. }
  7864. }
  7865. /**
  7866. * Adds the same handler for all of the specified attrs
  7867. * @param {String} attrs Pipe-separated list of attributes
  7868. * @param {Function} handler The method that will be applied
  7869. */
  7870. function addHandle( attrs, handler ) {
  7871. var arr = attrs.split("|"),
  7872. i = arr.length;
  7873. while ( i-- ) {
  7874. Expr.attrHandle[ arr[i] ] = handler;
  7875. }
  7876. }
  7877. /**
  7878. * Checks document order of two siblings
  7879. * @param {Element} a
  7880. * @param {Element} b
  7881. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7882. */
  7883. function siblingCheck( a, b ) {
  7884. var cur = b && a,
  7885. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7886. a.sourceIndex - b.sourceIndex;
  7887. // Use IE sourceIndex if available on both nodes
  7888. if ( diff ) {
  7889. return diff;
  7890. }
  7891. // Check if b follows a
  7892. if ( cur ) {
  7893. while ( (cur = cur.nextSibling) ) {
  7894. if ( cur === b ) {
  7895. return -1;
  7896. }
  7897. }
  7898. }
  7899. return a ? 1 : -1;
  7900. }
  7901. /**
  7902. * Returns a function to use in pseudos for input types
  7903. * @param {String} type
  7904. */
  7905. function createInputPseudo( type ) {
  7906. return function( elem ) {
  7907. var name = elem.nodeName.toLowerCase();
  7908. return name === "input" && elem.type === type;
  7909. };
  7910. }
  7911. /**
  7912. * Returns a function to use in pseudos for buttons
  7913. * @param {String} type
  7914. */
  7915. function createButtonPseudo( type ) {
  7916. return function( elem ) {
  7917. var name = elem.nodeName.toLowerCase();
  7918. return (name === "input" || name === "button") && elem.type === type;
  7919. };
  7920. }
  7921. /**
  7922. * Returns a function to use in pseudos for :enabled/:disabled
  7923. * @param {Boolean} disabled true for :disabled; false for :enabled
  7924. */
  7925. function createDisabledPseudo( disabled ) {
  7926. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7927. return function( elem ) {
  7928. // Only certain elements can match :enabled or :disabled
  7929. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7930. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7931. if ( "form" in elem ) {
  7932. // Check for inherited disabledness on relevant non-disabled elements:
  7933. // * listed form-associated elements in a disabled fieldset
  7934. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7935. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7936. // * option elements in a disabled optgroup
  7937. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7938. // All such elements have a "form" property.
  7939. if ( elem.parentNode && elem.disabled === false ) {
  7940. // Option elements defer to a parent optgroup if present
  7941. if ( "label" in elem ) {
  7942. if ( "label" in elem.parentNode ) {
  7943. return elem.parentNode.disabled === disabled;
  7944. } else {
  7945. return elem.disabled === disabled;
  7946. }
  7947. }
  7948. // Support: IE 6 - 11
  7949. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7950. return elem.isDisabled === disabled ||
  7951. // Where there is no isDisabled, check manually
  7952. /* jshint -W018 */
  7953. elem.isDisabled !== !disabled &&
  7954. inDisabledFieldset( elem ) === disabled;
  7955. }
  7956. return elem.disabled === disabled;
  7957. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7958. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7959. // even exist on them, let alone have a boolean value.
  7960. } else if ( "label" in elem ) {
  7961. return elem.disabled === disabled;
  7962. }
  7963. // Remaining elements are neither :enabled nor :disabled
  7964. return false;
  7965. };
  7966. }
  7967. /**
  7968. * Returns a function to use in pseudos for positionals
  7969. * @param {Function} fn
  7970. */
  7971. function createPositionalPseudo( fn ) {
  7972. return markFunction(function( argument ) {
  7973. argument = +argument;
  7974. return markFunction(function( seed, matches ) {
  7975. var j,
  7976. matchIndexes = fn( [], seed.length, argument ),
  7977. i = matchIndexes.length;
  7978. // Match elements found at the specified indexes
  7979. while ( i-- ) {
  7980. if ( seed[ (j = matchIndexes[i]) ] ) {
  7981. seed[j] = !(matches[j] = seed[j]);
  7982. }
  7983. }
  7984. });
  7985. });
  7986. }
  7987. /**
  7988. * Checks a node for validity as a Sizzle context
  7989. * @param {Element|Object=} context
  7990. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  7991. */
  7992. function testContext( context ) {
  7993. return context && typeof context.getElementsByTagName !== "undefined" && context;
  7994. }
  7995. // Expose support vars for convenience
  7996. support = Sizzle.support = {};
  7997. /**
  7998. * Detects XML nodes
  7999. * @param {Element|Object} elem An element or a document
  8000. * @returns {Boolean} True iff elem is a non-HTML XML node
  8001. */
  8002. isXML = Sizzle.isXML = function( elem ) {
  8003. var namespace = elem.namespaceURI,
  8004. docElem = (elem.ownerDocument || elem).documentElement;
  8005. // Support: IE <=8
  8006. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8007. // https://bugs.jquery.com/ticket/4833
  8008. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8009. };
  8010. /**
  8011. * Sets document-related variables once based on the current document
  8012. * @param {Element|Object} [doc] An element or document object to use to set the document
  8013. * @returns {Object} Returns the current document
  8014. */
  8015. setDocument = Sizzle.setDocument = function( node ) {
  8016. var hasCompare, subWindow,
  8017. doc = node ? node.ownerDocument || node : preferredDoc;
  8018. // Return early if doc is invalid or already selected
  8019. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8020. return document;
  8021. }
  8022. // Update global variables
  8023. document = doc;
  8024. docElem = document.documentElement;
  8025. documentIsHTML = !isXML( document );
  8026. // Support: IE 9-11, Edge
  8027. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8028. if ( preferredDoc !== document &&
  8029. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8030. // Support: IE 11, Edge
  8031. if ( subWindow.addEventListener ) {
  8032. subWindow.addEventListener( "unload", unloadHandler, false );
  8033. // Support: IE 9 - 10 only
  8034. } else if ( subWindow.attachEvent ) {
  8035. subWindow.attachEvent( "onunload", unloadHandler );
  8036. }
  8037. }
  8038. /* Attributes
  8039. ---------------------------------------------------------------------- */
  8040. // Support: IE<8
  8041. // Verify that getAttribute really returns attributes and not properties
  8042. // (excepting IE8 booleans)
  8043. support.attributes = assert(function( el ) {
  8044. el.className = "i";
  8045. return !el.getAttribute("className");
  8046. });
  8047. /* getElement(s)By*
  8048. ---------------------------------------------------------------------- */
  8049. // Check if getElementsByTagName("*") returns only elements
  8050. support.getElementsByTagName = assert(function( el ) {
  8051. el.appendChild( document.createComment("") );
  8052. return !el.getElementsByTagName("*").length;
  8053. });
  8054. // Support: IE<9
  8055. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8056. // Support: IE<10
  8057. // Check if getElementById returns elements by name
  8058. // The broken getElementById methods don't pick up programmatically-set names,
  8059. // so use a roundabout getElementsByName test
  8060. support.getById = assert(function( el ) {
  8061. docElem.appendChild( el ).id = expando;
  8062. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8063. });
  8064. // ID filter and find
  8065. if ( support.getById ) {
  8066. Expr.filter["ID"] = function( id ) {
  8067. var attrId = id.replace( runescape, funescape );
  8068. return function( elem ) {
  8069. return elem.getAttribute("id") === attrId;
  8070. };
  8071. };
  8072. Expr.find["ID"] = function( id, context ) {
  8073. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8074. var elem = context.getElementById( id );
  8075. return elem ? [ elem ] : [];
  8076. }
  8077. };
  8078. } else {
  8079. Expr.filter["ID"] = function( id ) {
  8080. var attrId = id.replace( runescape, funescape );
  8081. return function( elem ) {
  8082. var node = typeof elem.getAttributeNode !== "undefined" &&
  8083. elem.getAttributeNode("id");
  8084. return node && node.value === attrId;
  8085. };
  8086. };
  8087. // Support: IE 6 - 7 only
  8088. // getElementById is not reliable as a find shortcut
  8089. Expr.find["ID"] = function( id, context ) {
  8090. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8091. var node, i, elems,
  8092. elem = context.getElementById( id );
  8093. if ( elem ) {
  8094. // Verify the id attribute
  8095. node = elem.getAttributeNode("id");
  8096. if ( node && node.value === id ) {
  8097. return [ elem ];
  8098. }
  8099. // Fall back on getElementsByName
  8100. elems = context.getElementsByName( id );
  8101. i = 0;
  8102. while ( (elem = elems[i++]) ) {
  8103. node = elem.getAttributeNode("id");
  8104. if ( node && node.value === id ) {
  8105. return [ elem ];
  8106. }
  8107. }
  8108. }
  8109. return [];
  8110. }
  8111. };
  8112. }
  8113. // Tag
  8114. Expr.find["TAG"] = support.getElementsByTagName ?
  8115. function( tag, context ) {
  8116. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8117. return context.getElementsByTagName( tag );
  8118. // DocumentFragment nodes don't have gEBTN
  8119. } else if ( support.qsa ) {
  8120. return context.querySelectorAll( tag );
  8121. }
  8122. } :
  8123. function( tag, context ) {
  8124. var elem,
  8125. tmp = [],
  8126. i = 0,
  8127. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8128. results = context.getElementsByTagName( tag );
  8129. // Filter out possible comments
  8130. if ( tag === "*" ) {
  8131. while ( (elem = results[i++]) ) {
  8132. if ( elem.nodeType === 1 ) {
  8133. tmp.push( elem );
  8134. }
  8135. }
  8136. return tmp;
  8137. }
  8138. return results;
  8139. };
  8140. // Class
  8141. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8142. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8143. return context.getElementsByClassName( className );
  8144. }
  8145. };
  8146. /* QSA/matchesSelector
  8147. ---------------------------------------------------------------------- */
  8148. // QSA and matchesSelector support
  8149. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8150. rbuggyMatches = [];
  8151. // qSa(:focus) reports false when true (Chrome 21)
  8152. // We allow this because of a bug in IE8/9 that throws an error
  8153. // whenever `document.activeElement` is accessed on an iframe
  8154. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8155. // See https://bugs.jquery.com/ticket/13378
  8156. rbuggyQSA = [];
  8157. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8158. // Build QSA regex
  8159. // Regex strategy adopted from Diego Perini
  8160. assert(function( el ) {
  8161. // Select is set to empty string on purpose
  8162. // This is to test IE's treatment of not explicitly
  8163. // setting a boolean content attribute,
  8164. // since its presence should be enough
  8165. // https://bugs.jquery.com/ticket/12359
  8166. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8167. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8168. "<option selected=''></option></select>";
  8169. // Support: IE8, Opera 11-12.16
  8170. // Nothing should be selected when empty strings follow ^= or $= or *=
  8171. // The test attribute must be unknown in Opera but "safe" for WinRT
  8172. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8173. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8174. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8175. }
  8176. // Support: IE8
  8177. // Boolean attributes and "value" are not treated correctly
  8178. if ( !el.querySelectorAll("[selected]").length ) {
  8179. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8180. }
  8181. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8182. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8183. rbuggyQSA.push("~=");
  8184. }
  8185. // Webkit/Opera - :checked should return selected option elements
  8186. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8187. // IE8 throws error here and will not see later tests
  8188. if ( !el.querySelectorAll(":checked").length ) {
  8189. rbuggyQSA.push(":checked");
  8190. }
  8191. // Support: Safari 8+, iOS 8+
  8192. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8193. // In-page `selector#id sibling-combinator selector` fails
  8194. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8195. rbuggyQSA.push(".#.+[+~]");
  8196. }
  8197. });
  8198. assert(function( el ) {
  8199. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8200. "<select disabled='disabled'><option/></select>";
  8201. // Support: Windows 8 Native Apps
  8202. // The type and name attributes are restricted during .innerHTML assignment
  8203. var input = document.createElement("input");
  8204. input.setAttribute( "type", "hidden" );
  8205. el.appendChild( input ).setAttribute( "name", "D" );
  8206. // Support: IE8
  8207. // Enforce case-sensitivity of name attribute
  8208. if ( el.querySelectorAll("[name=d]").length ) {
  8209. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8210. }
  8211. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8212. // IE8 throws error here and will not see later tests
  8213. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8214. rbuggyQSA.push( ":enabled", ":disabled" );
  8215. }
  8216. // Support: IE9-11+
  8217. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8218. docElem.appendChild( el ).disabled = true;
  8219. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8220. rbuggyQSA.push( ":enabled", ":disabled" );
  8221. }
  8222. // Opera 10-11 does not throw on post-comma invalid pseudos
  8223. el.querySelectorAll("*,:x");
  8224. rbuggyQSA.push(",.*:");
  8225. });
  8226. }
  8227. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8228. docElem.webkitMatchesSelector ||
  8229. docElem.mozMatchesSelector ||
  8230. docElem.oMatchesSelector ||
  8231. docElem.msMatchesSelector) )) ) {
  8232. assert(function( el ) {
  8233. // Check to see if it's possible to do matchesSelector
  8234. // on a disconnected node (IE 9)
  8235. support.disconnectedMatch = matches.call( el, "*" );
  8236. // This should fail with an exception
  8237. // Gecko does not error, returns false instead
  8238. matches.call( el, "[s!='']:x" );
  8239. rbuggyMatches.push( "!=", pseudos );
  8240. });
  8241. }
  8242. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8243. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8244. /* Contains
  8245. ---------------------------------------------------------------------- */
  8246. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8247. // Element contains another
  8248. // Purposefully self-exclusive
  8249. // As in, an element does not contain itself
  8250. contains = hasCompare || rnative.test( docElem.contains ) ?
  8251. function( a, b ) {
  8252. var adown = a.nodeType === 9 ? a.documentElement : a,
  8253. bup = b && b.parentNode;
  8254. return a === bup || !!( bup && bup.nodeType === 1 && (
  8255. adown.contains ?
  8256. adown.contains( bup ) :
  8257. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8258. ));
  8259. } :
  8260. function( a, b ) {
  8261. if ( b ) {
  8262. while ( (b = b.parentNode) ) {
  8263. if ( b === a ) {
  8264. return true;
  8265. }
  8266. }
  8267. }
  8268. return false;
  8269. };
  8270. /* Sorting
  8271. ---------------------------------------------------------------------- */
  8272. // Document order sorting
  8273. sortOrder = hasCompare ?
  8274. function( a, b ) {
  8275. // Flag for duplicate removal
  8276. if ( a === b ) {
  8277. hasDuplicate = true;
  8278. return 0;
  8279. }
  8280. // Sort on method existence if only one input has compareDocumentPosition
  8281. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8282. if ( compare ) {
  8283. return compare;
  8284. }
  8285. // Calculate position if both inputs belong to the same document
  8286. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8287. a.compareDocumentPosition( b ) :
  8288. // Otherwise we know they are disconnected
  8289. 1;
  8290. // Disconnected nodes
  8291. if ( compare & 1 ||
  8292. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8293. // Choose the first element that is related to our preferred document
  8294. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8295. return -1;
  8296. }
  8297. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8298. return 1;
  8299. }
  8300. // Maintain original order
  8301. return sortInput ?
  8302. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8303. 0;
  8304. }
  8305. return compare & 4 ? -1 : 1;
  8306. } :
  8307. function( a, b ) {
  8308. // Exit early if the nodes are identical
  8309. if ( a === b ) {
  8310. hasDuplicate = true;
  8311. return 0;
  8312. }
  8313. var cur,
  8314. i = 0,
  8315. aup = a.parentNode,
  8316. bup = b.parentNode,
  8317. ap = [ a ],
  8318. bp = [ b ];
  8319. // Parentless nodes are either documents or disconnected
  8320. if ( !aup || !bup ) {
  8321. return a === document ? -1 :
  8322. b === document ? 1 :
  8323. aup ? -1 :
  8324. bup ? 1 :
  8325. sortInput ?
  8326. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8327. 0;
  8328. // If the nodes are siblings, we can do a quick check
  8329. } else if ( aup === bup ) {
  8330. return siblingCheck( a, b );
  8331. }
  8332. // Otherwise we need full lists of their ancestors for comparison
  8333. cur = a;
  8334. while ( (cur = cur.parentNode) ) {
  8335. ap.unshift( cur );
  8336. }
  8337. cur = b;
  8338. while ( (cur = cur.parentNode) ) {
  8339. bp.unshift( cur );
  8340. }
  8341. // Walk down the tree looking for a discrepancy
  8342. while ( ap[i] === bp[i] ) {
  8343. i++;
  8344. }
  8345. return i ?
  8346. // Do a sibling check if the nodes have a common ancestor
  8347. siblingCheck( ap[i], bp[i] ) :
  8348. // Otherwise nodes in our document sort first
  8349. ap[i] === preferredDoc ? -1 :
  8350. bp[i] === preferredDoc ? 1 :
  8351. 0;
  8352. };
  8353. return document;
  8354. };
  8355. Sizzle.matches = function( expr, elements ) {
  8356. return Sizzle( expr, null, null, elements );
  8357. };
  8358. Sizzle.matchesSelector = function( elem, expr ) {
  8359. // Set document vars if needed
  8360. if ( ( elem.ownerDocument || elem ) !== document ) {
  8361. setDocument( elem );
  8362. }
  8363. if ( support.matchesSelector && documentIsHTML &&
  8364. !nonnativeSelectorCache[ expr + " " ] &&
  8365. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8366. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8367. try {
  8368. var ret = matches.call( elem, expr );
  8369. // IE 9's matchesSelector returns false on disconnected nodes
  8370. if ( ret || support.disconnectedMatch ||
  8371. // As well, disconnected nodes are said to be in a document
  8372. // fragment in IE 9
  8373. elem.document && elem.document.nodeType !== 11 ) {
  8374. return ret;
  8375. }
  8376. } catch (e) {
  8377. nonnativeSelectorCache( expr, true );
  8378. }
  8379. }
  8380. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8381. };
  8382. Sizzle.contains = function( context, elem ) {
  8383. // Set document vars if needed
  8384. if ( ( context.ownerDocument || context ) !== document ) {
  8385. setDocument( context );
  8386. }
  8387. return contains( context, elem );
  8388. };
  8389. Sizzle.attr = function( elem, name ) {
  8390. // Set document vars if needed
  8391. if ( ( elem.ownerDocument || elem ) !== document ) {
  8392. setDocument( elem );
  8393. }
  8394. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8395. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8396. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8397. fn( elem, name, !documentIsHTML ) :
  8398. undefined;
  8399. return val !== undefined ?
  8400. val :
  8401. support.attributes || !documentIsHTML ?
  8402. elem.getAttribute( name ) :
  8403. (val = elem.getAttributeNode(name)) && val.specified ?
  8404. val.value :
  8405. null;
  8406. };
  8407. Sizzle.escape = function( sel ) {
  8408. return (sel + "").replace( rcssescape, fcssescape );
  8409. };
  8410. Sizzle.error = function( msg ) {
  8411. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8412. };
  8413. /**
  8414. * Document sorting and removing duplicates
  8415. * @param {ArrayLike} results
  8416. */
  8417. Sizzle.uniqueSort = function( results ) {
  8418. var elem,
  8419. duplicates = [],
  8420. j = 0,
  8421. i = 0;
  8422. // Unless we *know* we can detect duplicates, assume their presence
  8423. hasDuplicate = !support.detectDuplicates;
  8424. sortInput = !support.sortStable && results.slice( 0 );
  8425. results.sort( sortOrder );
  8426. if ( hasDuplicate ) {
  8427. while ( (elem = results[i++]) ) {
  8428. if ( elem === results[ i ] ) {
  8429. j = duplicates.push( i );
  8430. }
  8431. }
  8432. while ( j-- ) {
  8433. results.splice( duplicates[ j ], 1 );
  8434. }
  8435. }
  8436. // Clear input after sorting to release objects
  8437. // See https://github.com/jquery/sizzle/pull/225
  8438. sortInput = null;
  8439. return results;
  8440. };
  8441. /**
  8442. * Utility function for retrieving the text value of an array of DOM nodes
  8443. * @param {Array|Element} elem
  8444. */
  8445. getText = Sizzle.getText = function( elem ) {
  8446. var node,
  8447. ret = "",
  8448. i = 0,
  8449. nodeType = elem.nodeType;
  8450. if ( !nodeType ) {
  8451. // If no nodeType, this is expected to be an array
  8452. while ( (node = elem[i++]) ) {
  8453. // Do not traverse comment nodes
  8454. ret += getText( node );
  8455. }
  8456. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8457. // Use textContent for elements
  8458. // innerText usage removed for consistency of new lines (jQuery #11153)
  8459. if ( typeof elem.textContent === "string" ) {
  8460. return elem.textContent;
  8461. } else {
  8462. // Traverse its children
  8463. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8464. ret += getText( elem );
  8465. }
  8466. }
  8467. } else if ( nodeType === 3 || nodeType === 4 ) {
  8468. return elem.nodeValue;
  8469. }
  8470. // Do not include comment or processing instruction nodes
  8471. return ret;
  8472. };
  8473. Expr = Sizzle.selectors = {
  8474. // Can be adjusted by the user
  8475. cacheLength: 50,
  8476. createPseudo: markFunction,
  8477. match: matchExpr,
  8478. attrHandle: {},
  8479. find: {},
  8480. relative: {
  8481. ">": { dir: "parentNode", first: true },
  8482. " ": { dir: "parentNode" },
  8483. "+": { dir: "previousSibling", first: true },
  8484. "~": { dir: "previousSibling" }
  8485. },
  8486. preFilter: {
  8487. "ATTR": function( match ) {
  8488. match[1] = match[1].replace( runescape, funescape );
  8489. // Move the given value to match[3] whether quoted or unquoted
  8490. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8491. if ( match[2] === "~=" ) {
  8492. match[3] = " " + match[3] + " ";
  8493. }
  8494. return match.slice( 0, 4 );
  8495. },
  8496. "CHILD": function( match ) {
  8497. /* matches from matchExpr["CHILD"]
  8498. 1 type (only|nth|...)
  8499. 2 what (child|of-type)
  8500. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8501. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8502. 5 sign of xn-component
  8503. 6 x of xn-component
  8504. 7 sign of y-component
  8505. 8 y of y-component
  8506. */
  8507. match[1] = match[1].toLowerCase();
  8508. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8509. // nth-* requires argument
  8510. if ( !match[3] ) {
  8511. Sizzle.error( match[0] );
  8512. }
  8513. // numeric x and y parameters for Expr.filter.CHILD
  8514. // remember that false/true cast respectively to 0/1
  8515. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8516. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8517. // other types prohibit arguments
  8518. } else if ( match[3] ) {
  8519. Sizzle.error( match[0] );
  8520. }
  8521. return match;
  8522. },
  8523. "PSEUDO": function( match ) {
  8524. var excess,
  8525. unquoted = !match[6] && match[2];
  8526. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8527. return null;
  8528. }
  8529. // Accept quoted arguments as-is
  8530. if ( match[3] ) {
  8531. match[2] = match[4] || match[5] || "";
  8532. // Strip excess characters from unquoted arguments
  8533. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8534. // Get excess from tokenize (recursively)
  8535. (excess = tokenize( unquoted, true )) &&
  8536. // advance to the next closing parenthesis
  8537. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8538. // excess is a negative index
  8539. match[0] = match[0].slice( 0, excess );
  8540. match[2] = unquoted.slice( 0, excess );
  8541. }
  8542. // Return only captures needed by the pseudo filter method (type and argument)
  8543. return match.slice( 0, 3 );
  8544. }
  8545. },
  8546. filter: {
  8547. "TAG": function( nodeNameSelector ) {
  8548. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8549. return nodeNameSelector === "*" ?
  8550. function() { return true; } :
  8551. function( elem ) {
  8552. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8553. };
  8554. },
  8555. "CLASS": function( className ) {
  8556. var pattern = classCache[ className + " " ];
  8557. return pattern ||
  8558. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8559. classCache( className, function( elem ) {
  8560. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8561. });
  8562. },
  8563. "ATTR": function( name, operator, check ) {
  8564. return function( elem ) {
  8565. var result = Sizzle.attr( elem, name );
  8566. if ( result == null ) {
  8567. return operator === "!=";
  8568. }
  8569. if ( !operator ) {
  8570. return true;
  8571. }
  8572. result += "";
  8573. return operator === "=" ? result === check :
  8574. operator === "!=" ? result !== check :
  8575. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8576. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8577. operator === "$=" ? check && result.slice( -check.length ) === check :
  8578. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8579. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8580. false;
  8581. };
  8582. },
  8583. "CHILD": function( type, what, argument, first, last ) {
  8584. var simple = type.slice( 0, 3 ) !== "nth",
  8585. forward = type.slice( -4 ) !== "last",
  8586. ofType = what === "of-type";
  8587. return first === 1 && last === 0 ?
  8588. // Shortcut for :nth-*(n)
  8589. function( elem ) {
  8590. return !!elem.parentNode;
  8591. } :
  8592. function( elem, context, xml ) {
  8593. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8594. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8595. parent = elem.parentNode,
  8596. name = ofType && elem.nodeName.toLowerCase(),
  8597. useCache = !xml && !ofType,
  8598. diff = false;
  8599. if ( parent ) {
  8600. // :(first|last|only)-(child|of-type)
  8601. if ( simple ) {
  8602. while ( dir ) {
  8603. node = elem;
  8604. while ( (node = node[ dir ]) ) {
  8605. if ( ofType ?
  8606. node.nodeName.toLowerCase() === name :
  8607. node.nodeType === 1 ) {
  8608. return false;
  8609. }
  8610. }
  8611. // Reverse direction for :only-* (if we haven't yet done so)
  8612. start = dir = type === "only" && !start && "nextSibling";
  8613. }
  8614. return true;
  8615. }
  8616. start = [ forward ? parent.firstChild : parent.lastChild ];
  8617. // non-xml :nth-child(...) stores cache data on `parent`
  8618. if ( forward && useCache ) {
  8619. // Seek `elem` from a previously-cached index
  8620. // ...in a gzip-friendly way
  8621. node = parent;
  8622. outerCache = node[ expando ] || (node[ expando ] = {});
  8623. // Support: IE <9 only
  8624. // Defend against cloned attroperties (jQuery gh-1709)
  8625. uniqueCache = outerCache[ node.uniqueID ] ||
  8626. (outerCache[ node.uniqueID ] = {});
  8627. cache = uniqueCache[ type ] || [];
  8628. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8629. diff = nodeIndex && cache[ 2 ];
  8630. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8631. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8632. // Fallback to seeking `elem` from the start
  8633. (diff = nodeIndex = 0) || start.pop()) ) {
  8634. // When found, cache indexes on `parent` and break
  8635. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8636. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8637. break;
  8638. }
  8639. }
  8640. } else {
  8641. // Use previously-cached element index if available
  8642. if ( useCache ) {
  8643. // ...in a gzip-friendly way
  8644. node = elem;
  8645. outerCache = node[ expando ] || (node[ expando ] = {});
  8646. // Support: IE <9 only
  8647. // Defend against cloned attroperties (jQuery gh-1709)
  8648. uniqueCache = outerCache[ node.uniqueID ] ||
  8649. (outerCache[ node.uniqueID ] = {});
  8650. cache = uniqueCache[ type ] || [];
  8651. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8652. diff = nodeIndex;
  8653. }
  8654. // xml :nth-child(...)
  8655. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8656. if ( diff === false ) {
  8657. // Use the same loop as above to seek `elem` from the start
  8658. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8659. (diff = nodeIndex = 0) || start.pop()) ) {
  8660. if ( ( ofType ?
  8661. node.nodeName.toLowerCase() === name :
  8662. node.nodeType === 1 ) &&
  8663. ++diff ) {
  8664. // Cache the index of each encountered element
  8665. if ( useCache ) {
  8666. outerCache = node[ expando ] || (node[ expando ] = {});
  8667. // Support: IE <9 only
  8668. // Defend against cloned attroperties (jQuery gh-1709)
  8669. uniqueCache = outerCache[ node.uniqueID ] ||
  8670. (outerCache[ node.uniqueID ] = {});
  8671. uniqueCache[ type ] = [ dirruns, diff ];
  8672. }
  8673. if ( node === elem ) {
  8674. break;
  8675. }
  8676. }
  8677. }
  8678. }
  8679. }
  8680. // Incorporate the offset, then check against cycle size
  8681. diff -= last;
  8682. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8683. }
  8684. };
  8685. },
  8686. "PSEUDO": function( pseudo, argument ) {
  8687. // pseudo-class names are case-insensitive
  8688. // http://www.w3.org/TR/selectors/#pseudo-classes
  8689. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8690. // Remember that setFilters inherits from pseudos
  8691. var args,
  8692. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8693. Sizzle.error( "unsupported pseudo: " + pseudo );
  8694. // The user may use createPseudo to indicate that
  8695. // arguments are needed to create the filter function
  8696. // just as Sizzle does
  8697. if ( fn[ expando ] ) {
  8698. return fn( argument );
  8699. }
  8700. // But maintain support for old signatures
  8701. if ( fn.length > 1 ) {
  8702. args = [ pseudo, pseudo, "", argument ];
  8703. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8704. markFunction(function( seed, matches ) {
  8705. var idx,
  8706. matched = fn( seed, argument ),
  8707. i = matched.length;
  8708. while ( i-- ) {
  8709. idx = indexOf( seed, matched[i] );
  8710. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8711. }
  8712. }) :
  8713. function( elem ) {
  8714. return fn( elem, 0, args );
  8715. };
  8716. }
  8717. return fn;
  8718. }
  8719. },
  8720. pseudos: {
  8721. // Potentially complex pseudos
  8722. "not": markFunction(function( selector ) {
  8723. // Trim the selector passed to compile
  8724. // to avoid treating leading and trailing
  8725. // spaces as combinators
  8726. var input = [],
  8727. results = [],
  8728. matcher = compile( selector.replace( rtrim, "$1" ) );
  8729. return matcher[ expando ] ?
  8730. markFunction(function( seed, matches, context, xml ) {
  8731. var elem,
  8732. unmatched = matcher( seed, null, xml, [] ),
  8733. i = seed.length;
  8734. // Match elements unmatched by `matcher`
  8735. while ( i-- ) {
  8736. if ( (elem = unmatched[i]) ) {
  8737. seed[i] = !(matches[i] = elem);
  8738. }
  8739. }
  8740. }) :
  8741. function( elem, context, xml ) {
  8742. input[0] = elem;
  8743. matcher( input, null, xml, results );
  8744. // Don't keep the element (issue #299)
  8745. input[0] = null;
  8746. return !results.pop();
  8747. };
  8748. }),
  8749. "has": markFunction(function( selector ) {
  8750. return function( elem ) {
  8751. return Sizzle( selector, elem ).length > 0;
  8752. };
  8753. }),
  8754. "contains": markFunction(function( text ) {
  8755. text = text.replace( runescape, funescape );
  8756. return function( elem ) {
  8757. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8758. };
  8759. }),
  8760. // "Whether an element is represented by a :lang() selector
  8761. // is based solely on the element's language value
  8762. // being equal to the identifier C,
  8763. // or beginning with the identifier C immediately followed by "-".
  8764. // The matching of C against the element's language value is performed case-insensitively.
  8765. // The identifier C does not have to be a valid language name."
  8766. // http://www.w3.org/TR/selectors/#lang-pseudo
  8767. "lang": markFunction( function( lang ) {
  8768. // lang value must be a valid identifier
  8769. if ( !ridentifier.test(lang || "") ) {
  8770. Sizzle.error( "unsupported lang: " + lang );
  8771. }
  8772. lang = lang.replace( runescape, funescape ).toLowerCase();
  8773. return function( elem ) {
  8774. var elemLang;
  8775. do {
  8776. if ( (elemLang = documentIsHTML ?
  8777. elem.lang :
  8778. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8779. elemLang = elemLang.toLowerCase();
  8780. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8781. }
  8782. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8783. return false;
  8784. };
  8785. }),
  8786. // Miscellaneous
  8787. "target": function( elem ) {
  8788. var hash = window.location && window.location.hash;
  8789. return hash && hash.slice( 1 ) === elem.id;
  8790. },
  8791. "root": function( elem ) {
  8792. return elem === docElem;
  8793. },
  8794. "focus": function( elem ) {
  8795. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8796. },
  8797. // Boolean properties
  8798. "enabled": createDisabledPseudo( false ),
  8799. "disabled": createDisabledPseudo( true ),
  8800. "checked": function( elem ) {
  8801. // In CSS3, :checked should return both checked and selected elements
  8802. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8803. var nodeName = elem.nodeName.toLowerCase();
  8804. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8805. },
  8806. "selected": function( elem ) {
  8807. // Accessing this property makes selected-by-default
  8808. // options in Safari work properly
  8809. if ( elem.parentNode ) {
  8810. elem.parentNode.selectedIndex;
  8811. }
  8812. return elem.selected === true;
  8813. },
  8814. // Contents
  8815. "empty": function( elem ) {
  8816. // http://www.w3.org/TR/selectors/#empty-pseudo
  8817. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8818. // but not by others (comment: 8; processing instruction: 7; etc.)
  8819. // nodeType < 6 works because attributes (2) do not appear as children
  8820. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8821. if ( elem.nodeType < 6 ) {
  8822. return false;
  8823. }
  8824. }
  8825. return true;
  8826. },
  8827. "parent": function( elem ) {
  8828. return !Expr.pseudos["empty"]( elem );
  8829. },
  8830. // Element/input types
  8831. "header": function( elem ) {
  8832. return rheader.test( elem.nodeName );
  8833. },
  8834. "input": function( elem ) {
  8835. return rinputs.test( elem.nodeName );
  8836. },
  8837. "button": function( elem ) {
  8838. var name = elem.nodeName.toLowerCase();
  8839. return name === "input" && elem.type === "button" || name === "button";
  8840. },
  8841. "text": function( elem ) {
  8842. var attr;
  8843. return elem.nodeName.toLowerCase() === "input" &&
  8844. elem.type === "text" &&
  8845. // Support: IE<8
  8846. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8847. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8848. },
  8849. // Position-in-collection
  8850. "first": createPositionalPseudo(function() {
  8851. return [ 0 ];
  8852. }),
  8853. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8854. return [ length - 1 ];
  8855. }),
  8856. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8857. return [ argument < 0 ? argument + length : argument ];
  8858. }),
  8859. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8860. var i = 0;
  8861. for ( ; i < length; i += 2 ) {
  8862. matchIndexes.push( i );
  8863. }
  8864. return matchIndexes;
  8865. }),
  8866. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8867. var i = 1;
  8868. for ( ; i < length; i += 2 ) {
  8869. matchIndexes.push( i );
  8870. }
  8871. return matchIndexes;
  8872. }),
  8873. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8874. var i = argument < 0 ?
  8875. argument + length :
  8876. argument > length ?
  8877. length :
  8878. argument;
  8879. for ( ; --i >= 0; ) {
  8880. matchIndexes.push( i );
  8881. }
  8882. return matchIndexes;
  8883. }),
  8884. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8885. var i = argument < 0 ? argument + length : argument;
  8886. for ( ; ++i < length; ) {
  8887. matchIndexes.push( i );
  8888. }
  8889. return matchIndexes;
  8890. })
  8891. }
  8892. };
  8893. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8894. // Add button/input type pseudos
  8895. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8896. Expr.pseudos[ i ] = createInputPseudo( i );
  8897. }
  8898. for ( i in { submit: true, reset: true } ) {
  8899. Expr.pseudos[ i ] = createButtonPseudo( i );
  8900. }
  8901. // Easy API for creating new setFilters
  8902. function setFilters() {}
  8903. setFilters.prototype = Expr.filters = Expr.pseudos;
  8904. Expr.setFilters = new setFilters();
  8905. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8906. var matched, match, tokens, type,
  8907. soFar, groups, preFilters,
  8908. cached = tokenCache[ selector + " " ];
  8909. if ( cached ) {
  8910. return parseOnly ? 0 : cached.slice( 0 );
  8911. }
  8912. soFar = selector;
  8913. groups = [];
  8914. preFilters = Expr.preFilter;
  8915. while ( soFar ) {
  8916. // Comma and first run
  8917. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8918. if ( match ) {
  8919. // Don't consume trailing commas as valid
  8920. soFar = soFar.slice( match[0].length ) || soFar;
  8921. }
  8922. groups.push( (tokens = []) );
  8923. }
  8924. matched = false;
  8925. // Combinators
  8926. if ( (match = rcombinators.exec( soFar )) ) {
  8927. matched = match.shift();
  8928. tokens.push({
  8929. value: matched,
  8930. // Cast descendant combinators to space
  8931. type: match[0].replace( rtrim, " " )
  8932. });
  8933. soFar = soFar.slice( matched.length );
  8934. }
  8935. // Filters
  8936. for ( type in Expr.filter ) {
  8937. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8938. (match = preFilters[ type ]( match ))) ) {
  8939. matched = match.shift();
  8940. tokens.push({
  8941. value: matched,
  8942. type: type,
  8943. matches: match
  8944. });
  8945. soFar = soFar.slice( matched.length );
  8946. }
  8947. }
  8948. if ( !matched ) {
  8949. break;
  8950. }
  8951. }
  8952. // Return the length of the invalid excess
  8953. // if we're just parsing
  8954. // Otherwise, throw an error or return tokens
  8955. return parseOnly ?
  8956. soFar.length :
  8957. soFar ?
  8958. Sizzle.error( selector ) :
  8959. // Cache the tokens
  8960. tokenCache( selector, groups ).slice( 0 );
  8961. };
  8962. function toSelector( tokens ) {
  8963. var i = 0,
  8964. len = tokens.length,
  8965. selector = "";
  8966. for ( ; i < len; i++ ) {
  8967. selector += tokens[i].value;
  8968. }
  8969. return selector;
  8970. }
  8971. function addCombinator( matcher, combinator, base ) {
  8972. var dir = combinator.dir,
  8973. skip = combinator.next,
  8974. key = skip || dir,
  8975. checkNonElements = base && key === "parentNode",
  8976. doneName = done++;
  8977. return combinator.first ?
  8978. // Check against closest ancestor/preceding element
  8979. function( elem, context, xml ) {
  8980. while ( (elem = elem[ dir ]) ) {
  8981. if ( elem.nodeType === 1 || checkNonElements ) {
  8982. return matcher( elem, context, xml );
  8983. }
  8984. }
  8985. return false;
  8986. } :
  8987. // Check against all ancestor/preceding elements
  8988. function( elem, context, xml ) {
  8989. var oldCache, uniqueCache, outerCache,
  8990. newCache = [ dirruns, doneName ];
  8991. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  8992. if ( xml ) {
  8993. while ( (elem = elem[ dir ]) ) {
  8994. if ( elem.nodeType === 1 || checkNonElements ) {
  8995. if ( matcher( elem, context, xml ) ) {
  8996. return true;
  8997. }
  8998. }
  8999. }
  9000. } else {
  9001. while ( (elem = elem[ dir ]) ) {
  9002. if ( elem.nodeType === 1 || checkNonElements ) {
  9003. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9004. // Support: IE <9 only
  9005. // Defend against cloned attroperties (jQuery gh-1709)
  9006. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9007. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9008. elem = elem[ dir ] || elem;
  9009. } else if ( (oldCache = uniqueCache[ key ]) &&
  9010. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9011. // Assign to newCache so results back-propagate to previous elements
  9012. return (newCache[ 2 ] = oldCache[ 2 ]);
  9013. } else {
  9014. // Reuse newcache so results back-propagate to previous elements
  9015. uniqueCache[ key ] = newCache;
  9016. // A match means we're done; a fail means we have to keep checking
  9017. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9018. return true;
  9019. }
  9020. }
  9021. }
  9022. }
  9023. }
  9024. return false;
  9025. };
  9026. }
  9027. function elementMatcher( matchers ) {
  9028. return matchers.length > 1 ?
  9029. function( elem, context, xml ) {
  9030. var i = matchers.length;
  9031. while ( i-- ) {
  9032. if ( !matchers[i]( elem, context, xml ) ) {
  9033. return false;
  9034. }
  9035. }
  9036. return true;
  9037. } :
  9038. matchers[0];
  9039. }
  9040. function multipleContexts( selector, contexts, results ) {
  9041. var i = 0,
  9042. len = contexts.length;
  9043. for ( ; i < len; i++ ) {
  9044. Sizzle( selector, contexts[i], results );
  9045. }
  9046. return results;
  9047. }
  9048. function condense( unmatched, map, filter, context, xml ) {
  9049. var elem,
  9050. newUnmatched = [],
  9051. i = 0,
  9052. len = unmatched.length,
  9053. mapped = map != null;
  9054. for ( ; i < len; i++ ) {
  9055. if ( (elem = unmatched[i]) ) {
  9056. if ( !filter || filter( elem, context, xml ) ) {
  9057. newUnmatched.push( elem );
  9058. if ( mapped ) {
  9059. map.push( i );
  9060. }
  9061. }
  9062. }
  9063. }
  9064. return newUnmatched;
  9065. }
  9066. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9067. if ( postFilter && !postFilter[ expando ] ) {
  9068. postFilter = setMatcher( postFilter );
  9069. }
  9070. if ( postFinder && !postFinder[ expando ] ) {
  9071. postFinder = setMatcher( postFinder, postSelector );
  9072. }
  9073. return markFunction(function( seed, results, context, xml ) {
  9074. var temp, i, elem,
  9075. preMap = [],
  9076. postMap = [],
  9077. preexisting = results.length,
  9078. // Get initial elements from seed or context
  9079. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9080. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9081. matcherIn = preFilter && ( seed || !selector ) ?
  9082. condense( elems, preMap, preFilter, context, xml ) :
  9083. elems,
  9084. matcherOut = matcher ?
  9085. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9086. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9087. // ...intermediate processing is necessary
  9088. [] :
  9089. // ...otherwise use results directly
  9090. results :
  9091. matcherIn;
  9092. // Find primary matches
  9093. if ( matcher ) {
  9094. matcher( matcherIn, matcherOut, context, xml );
  9095. }
  9096. // Apply postFilter
  9097. if ( postFilter ) {
  9098. temp = condense( matcherOut, postMap );
  9099. postFilter( temp, [], context, xml );
  9100. // Un-match failing elements by moving them back to matcherIn
  9101. i = temp.length;
  9102. while ( i-- ) {
  9103. if ( (elem = temp[i]) ) {
  9104. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9105. }
  9106. }
  9107. }
  9108. if ( seed ) {
  9109. if ( postFinder || preFilter ) {
  9110. if ( postFinder ) {
  9111. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9112. temp = [];
  9113. i = matcherOut.length;
  9114. while ( i-- ) {
  9115. if ( (elem = matcherOut[i]) ) {
  9116. // Restore matcherIn since elem is not yet a final match
  9117. temp.push( (matcherIn[i] = elem) );
  9118. }
  9119. }
  9120. postFinder( null, (matcherOut = []), temp, xml );
  9121. }
  9122. // Move matched elements from seed to results to keep them synchronized
  9123. i = matcherOut.length;
  9124. while ( i-- ) {
  9125. if ( (elem = matcherOut[i]) &&
  9126. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9127. seed[temp] = !(results[temp] = elem);
  9128. }
  9129. }
  9130. }
  9131. // Add elements to results, through postFinder if defined
  9132. } else {
  9133. matcherOut = condense(
  9134. matcherOut === results ?
  9135. matcherOut.splice( preexisting, matcherOut.length ) :
  9136. matcherOut
  9137. );
  9138. if ( postFinder ) {
  9139. postFinder( null, results, matcherOut, xml );
  9140. } else {
  9141. push.apply( results, matcherOut );
  9142. }
  9143. }
  9144. });
  9145. }
  9146. function matcherFromTokens( tokens ) {
  9147. var checkContext, matcher, j,
  9148. len = tokens.length,
  9149. leadingRelative = Expr.relative[ tokens[0].type ],
  9150. implicitRelative = leadingRelative || Expr.relative[" "],
  9151. i = leadingRelative ? 1 : 0,
  9152. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9153. matchContext = addCombinator( function( elem ) {
  9154. return elem === checkContext;
  9155. }, implicitRelative, true ),
  9156. matchAnyContext = addCombinator( function( elem ) {
  9157. return indexOf( checkContext, elem ) > -1;
  9158. }, implicitRelative, true ),
  9159. matchers = [ function( elem, context, xml ) {
  9160. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9161. (checkContext = context).nodeType ?
  9162. matchContext( elem, context, xml ) :
  9163. matchAnyContext( elem, context, xml ) );
  9164. // Avoid hanging onto element (issue #299)
  9165. checkContext = null;
  9166. return ret;
  9167. } ];
  9168. for ( ; i < len; i++ ) {
  9169. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9170. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9171. } else {
  9172. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9173. // Return special upon seeing a positional matcher
  9174. if ( matcher[ expando ] ) {
  9175. // Find the next relative operator (if any) for proper handling
  9176. j = ++i;
  9177. for ( ; j < len; j++ ) {
  9178. if ( Expr.relative[ tokens[j].type ] ) {
  9179. break;
  9180. }
  9181. }
  9182. return setMatcher(
  9183. i > 1 && elementMatcher( matchers ),
  9184. i > 1 && toSelector(
  9185. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9186. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9187. ).replace( rtrim, "$1" ),
  9188. matcher,
  9189. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9190. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9191. j < len && toSelector( tokens )
  9192. );
  9193. }
  9194. matchers.push( matcher );
  9195. }
  9196. }
  9197. return elementMatcher( matchers );
  9198. }
  9199. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9200. var bySet = setMatchers.length > 0,
  9201. byElement = elementMatchers.length > 0,
  9202. superMatcher = function( seed, context, xml, results, outermost ) {
  9203. var elem, j, matcher,
  9204. matchedCount = 0,
  9205. i = "0",
  9206. unmatched = seed && [],
  9207. setMatched = [],
  9208. contextBackup = outermostContext,
  9209. // We must always have either seed elements or outermost context
  9210. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9211. // Use integer dirruns iff this is the outermost matcher
  9212. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9213. len = elems.length;
  9214. if ( outermost ) {
  9215. outermostContext = context === document || context || outermost;
  9216. }
  9217. // Add elements passing elementMatchers directly to results
  9218. // Support: IE<9, Safari
  9219. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9220. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9221. if ( byElement && elem ) {
  9222. j = 0;
  9223. if ( !context && elem.ownerDocument !== document ) {
  9224. setDocument( elem );
  9225. xml = !documentIsHTML;
  9226. }
  9227. while ( (matcher = elementMatchers[j++]) ) {
  9228. if ( matcher( elem, context || document, xml) ) {
  9229. results.push( elem );
  9230. break;
  9231. }
  9232. }
  9233. if ( outermost ) {
  9234. dirruns = dirrunsUnique;
  9235. }
  9236. }
  9237. // Track unmatched elements for set filters
  9238. if ( bySet ) {
  9239. // They will have gone through all possible matchers
  9240. if ( (elem = !matcher && elem) ) {
  9241. matchedCount--;
  9242. }
  9243. // Lengthen the array for every element, matched or not
  9244. if ( seed ) {
  9245. unmatched.push( elem );
  9246. }
  9247. }
  9248. }
  9249. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9250. // makes the latter nonnegative.
  9251. matchedCount += i;
  9252. // Apply set filters to unmatched elements
  9253. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9254. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9255. // no element matchers and no seed.
  9256. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9257. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9258. // numerically zero.
  9259. if ( bySet && i !== matchedCount ) {
  9260. j = 0;
  9261. while ( (matcher = setMatchers[j++]) ) {
  9262. matcher( unmatched, setMatched, context, xml );
  9263. }
  9264. if ( seed ) {
  9265. // Reintegrate element matches to eliminate the need for sorting
  9266. if ( matchedCount > 0 ) {
  9267. while ( i-- ) {
  9268. if ( !(unmatched[i] || setMatched[i]) ) {
  9269. setMatched[i] = pop.call( results );
  9270. }
  9271. }
  9272. }
  9273. // Discard index placeholder values to get only actual matches
  9274. setMatched = condense( setMatched );
  9275. }
  9276. // Add matches to results
  9277. push.apply( results, setMatched );
  9278. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9279. if ( outermost && !seed && setMatched.length > 0 &&
  9280. ( matchedCount + setMatchers.length ) > 1 ) {
  9281. Sizzle.uniqueSort( results );
  9282. }
  9283. }
  9284. // Override manipulation of globals by nested matchers
  9285. if ( outermost ) {
  9286. dirruns = dirrunsUnique;
  9287. outermostContext = contextBackup;
  9288. }
  9289. return unmatched;
  9290. };
  9291. return bySet ?
  9292. markFunction( superMatcher ) :
  9293. superMatcher;
  9294. }
  9295. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9296. var i,
  9297. setMatchers = [],
  9298. elementMatchers = [],
  9299. cached = compilerCache[ selector + " " ];
  9300. if ( !cached ) {
  9301. // Generate a function of recursive functions that can be used to check each element
  9302. if ( !match ) {
  9303. match = tokenize( selector );
  9304. }
  9305. i = match.length;
  9306. while ( i-- ) {
  9307. cached = matcherFromTokens( match[i] );
  9308. if ( cached[ expando ] ) {
  9309. setMatchers.push( cached );
  9310. } else {
  9311. elementMatchers.push( cached );
  9312. }
  9313. }
  9314. // Cache the compiled function
  9315. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9316. // Save selector and tokenization
  9317. cached.selector = selector;
  9318. }
  9319. return cached;
  9320. };
  9321. /**
  9322. * A low-level selection function that works with Sizzle's compiled
  9323. * selector functions
  9324. * @param {String|Function} selector A selector or a pre-compiled
  9325. * selector function built with Sizzle.compile
  9326. * @param {Element} context
  9327. * @param {Array} [results]
  9328. * @param {Array} [seed] A set of elements to match against
  9329. */
  9330. select = Sizzle.select = function( selector, context, results, seed ) {
  9331. var i, tokens, token, type, find,
  9332. compiled = typeof selector === "function" && selector,
  9333. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9334. results = results || [];
  9335. // Try to minimize operations if there is only one selector in the list and no seed
  9336. // (the latter of which guarantees us context)
  9337. if ( match.length === 1 ) {
  9338. // Reduce context if the leading compound selector is an ID
  9339. tokens = match[0] = match[0].slice( 0 );
  9340. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9341. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9342. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9343. if ( !context ) {
  9344. return results;
  9345. // Precompiled matchers will still verify ancestry, so step up a level
  9346. } else if ( compiled ) {
  9347. context = context.parentNode;
  9348. }
  9349. selector = selector.slice( tokens.shift().value.length );
  9350. }
  9351. // Fetch a seed set for right-to-left matching
  9352. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9353. while ( i-- ) {
  9354. token = tokens[i];
  9355. // Abort if we hit a combinator
  9356. if ( Expr.relative[ (type = token.type) ] ) {
  9357. break;
  9358. }
  9359. if ( (find = Expr.find[ type ]) ) {
  9360. // Search, expanding context for leading sibling combinators
  9361. if ( (seed = find(
  9362. token.matches[0].replace( runescape, funescape ),
  9363. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9364. )) ) {
  9365. // If seed is empty or no tokens remain, we can return early
  9366. tokens.splice( i, 1 );
  9367. selector = seed.length && toSelector( tokens );
  9368. if ( !selector ) {
  9369. push.apply( results, seed );
  9370. return results;
  9371. }
  9372. break;
  9373. }
  9374. }
  9375. }
  9376. }
  9377. // Compile and execute a filtering function if one is not provided
  9378. // Provide `match` to avoid retokenization if we modified the selector above
  9379. ( compiled || compile( selector, match ) )(
  9380. seed,
  9381. context,
  9382. !documentIsHTML,
  9383. results,
  9384. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9385. );
  9386. return results;
  9387. };
  9388. // One-time assignments
  9389. // Sort stability
  9390. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9391. // Support: Chrome 14-35+
  9392. // Always assume duplicates if they aren't passed to the comparison function
  9393. support.detectDuplicates = !!hasDuplicate;
  9394. // Initialize against the default document
  9395. setDocument();
  9396. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9397. // Detached nodes confoundingly follow *each other*
  9398. support.sortDetached = assert(function( el ) {
  9399. // Should return 1, but returns 4 (following)
  9400. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9401. });
  9402. // Support: IE<8
  9403. // Prevent attribute/property "interpolation"
  9404. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9405. if ( !assert(function( el ) {
  9406. el.innerHTML = "<a href='#'></a>";
  9407. return el.firstChild.getAttribute("href") === "#" ;
  9408. }) ) {
  9409. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9410. if ( !isXML ) {
  9411. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9412. }
  9413. });
  9414. }
  9415. // Support: IE<9
  9416. // Use defaultValue in place of getAttribute("value")
  9417. if ( !support.attributes || !assert(function( el ) {
  9418. el.innerHTML = "<input/>";
  9419. el.firstChild.setAttribute( "value", "" );
  9420. return el.firstChild.getAttribute( "value" ) === "";
  9421. }) ) {
  9422. addHandle( "value", function( elem, name, isXML ) {
  9423. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9424. return elem.defaultValue;
  9425. }
  9426. });
  9427. }
  9428. // Support: IE<9
  9429. // Use getAttributeNode to fetch booleans when getAttribute lies
  9430. if ( !assert(function( el ) {
  9431. return el.getAttribute("disabled") == null;
  9432. }) ) {
  9433. addHandle( booleans, function( elem, name, isXML ) {
  9434. var val;
  9435. if ( !isXML ) {
  9436. return elem[ name ] === true ? name.toLowerCase() :
  9437. (val = elem.getAttributeNode( name )) && val.specified ?
  9438. val.value :
  9439. null;
  9440. }
  9441. });
  9442. }
  9443. return Sizzle;
  9444. })( window );
  9445. jQuery.find = Sizzle;
  9446. jQuery.expr = Sizzle.selectors;
  9447. // Deprecated
  9448. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9449. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9450. jQuery.text = Sizzle.getText;
  9451. jQuery.isXMLDoc = Sizzle.isXML;
  9452. jQuery.contains = Sizzle.contains;
  9453. jQuery.escapeSelector = Sizzle.escape;
  9454. var dir = function( elem, dir, until ) {
  9455. var matched = [],
  9456. truncate = until !== undefined;
  9457. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9458. if ( elem.nodeType === 1 ) {
  9459. if ( truncate && jQuery( elem ).is( until ) ) {
  9460. break;
  9461. }
  9462. matched.push( elem );
  9463. }
  9464. }
  9465. return matched;
  9466. };
  9467. var siblings = function( n, elem ) {
  9468. var matched = [];
  9469. for ( ; n; n = n.nextSibling ) {
  9470. if ( n.nodeType === 1 && n !== elem ) {
  9471. matched.push( n );
  9472. }
  9473. }
  9474. return matched;
  9475. };
  9476. var rneedsContext = jQuery.expr.match.needsContext;
  9477. function nodeName( elem, name ) {
  9478. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9479. };
  9480. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9481. // Implement the identical functionality for filter and not
  9482. function winnow( elements, qualifier, not ) {
  9483. if ( isFunction( qualifier ) ) {
  9484. return jQuery.grep( elements, function( elem, i ) {
  9485. return !!qualifier.call( elem, i, elem ) !== not;
  9486. } );
  9487. }
  9488. // Single element
  9489. if ( qualifier.nodeType ) {
  9490. return jQuery.grep( elements, function( elem ) {
  9491. return ( elem === qualifier ) !== not;
  9492. } );
  9493. }
  9494. // Arraylike of elements (jQuery, arguments, Array)
  9495. if ( typeof qualifier !== "string" ) {
  9496. return jQuery.grep( elements, function( elem ) {
  9497. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9498. } );
  9499. }
  9500. // Filtered directly for both simple and complex selectors
  9501. return jQuery.filter( qualifier, elements, not );
  9502. }
  9503. jQuery.filter = function( expr, elems, not ) {
  9504. var elem = elems[ 0 ];
  9505. if ( not ) {
  9506. expr = ":not(" + expr + ")";
  9507. }
  9508. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9509. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9510. }
  9511. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9512. return elem.nodeType === 1;
  9513. } ) );
  9514. };
  9515. jQuery.fn.extend( {
  9516. find: function( selector ) {
  9517. var i, ret,
  9518. len = this.length,
  9519. self = this;
  9520. if ( typeof selector !== "string" ) {
  9521. return this.pushStack( jQuery( selector ).filter( function() {
  9522. for ( i = 0; i < len; i++ ) {
  9523. if ( jQuery.contains( self[ i ], this ) ) {
  9524. return true;
  9525. }
  9526. }
  9527. } ) );
  9528. }
  9529. ret = this.pushStack( [] );
  9530. for ( i = 0; i < len; i++ ) {
  9531. jQuery.find( selector, self[ i ], ret );
  9532. }
  9533. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9534. },
  9535. filter: function( selector ) {
  9536. return this.pushStack( winnow( this, selector || [], false ) );
  9537. },
  9538. not: function( selector ) {
  9539. return this.pushStack( winnow( this, selector || [], true ) );
  9540. },
  9541. is: function( selector ) {
  9542. return !!winnow(
  9543. this,
  9544. // If this is a positional/relative selector, check membership in the returned set
  9545. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9546. typeof selector === "string" && rneedsContext.test( selector ) ?
  9547. jQuery( selector ) :
  9548. selector || [],
  9549. false
  9550. ).length;
  9551. }
  9552. } );
  9553. // Initialize a jQuery object
  9554. // A central reference to the root jQuery(document)
  9555. var rootjQuery,
  9556. // A simple way to check for HTML strings
  9557. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9558. // Strict HTML recognition (#11290: must start with <)
  9559. // Shortcut simple #id case for speed
  9560. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9561. init = jQuery.fn.init = function( selector, context, root ) {
  9562. var match, elem;
  9563. // HANDLE: $(""), $(null), $(undefined), $(false)
  9564. if ( !selector ) {
  9565. return this;
  9566. }
  9567. // Method init() accepts an alternate rootjQuery
  9568. // so migrate can support jQuery.sub (gh-2101)
  9569. root = root || rootjQuery;
  9570. // Handle HTML strings
  9571. if ( typeof selector === "string" ) {
  9572. if ( selector[ 0 ] === "<" &&
  9573. selector[ selector.length - 1 ] === ">" &&
  9574. selector.length >= 3 ) {
  9575. // Assume that strings that start and end with <> are HTML and skip the regex check
  9576. match = [ null, selector, null ];
  9577. } else {
  9578. match = rquickExpr.exec( selector );
  9579. }
  9580. // Match html or make sure no context is specified for #id
  9581. if ( match && ( match[ 1 ] || !context ) ) {
  9582. // HANDLE: $(html) -> $(array)
  9583. if ( match[ 1 ] ) {
  9584. context = context instanceof jQuery ? context[ 0 ] : context;
  9585. // Option to run scripts is true for back-compat
  9586. // Intentionally let the error be thrown if parseHTML is not present
  9587. jQuery.merge( this, jQuery.parseHTML(
  9588. match[ 1 ],
  9589. context && context.nodeType ? context.ownerDocument || context : document,
  9590. true
  9591. ) );
  9592. // HANDLE: $(html, props)
  9593. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9594. for ( match in context ) {
  9595. // Properties of context are called as methods if possible
  9596. if ( isFunction( this[ match ] ) ) {
  9597. this[ match ]( context[ match ] );
  9598. // ...and otherwise set as attributes
  9599. } else {
  9600. this.attr( match, context[ match ] );
  9601. }
  9602. }
  9603. }
  9604. return this;
  9605. // HANDLE: $(#id)
  9606. } else {
  9607. elem = document.getElementById( match[ 2 ] );
  9608. if ( elem ) {
  9609. // Inject the element directly into the jQuery object
  9610. this[ 0 ] = elem;
  9611. this.length = 1;
  9612. }
  9613. return this;
  9614. }
  9615. // HANDLE: $(expr, $(...))
  9616. } else if ( !context || context.jquery ) {
  9617. return ( context || root ).find( selector );
  9618. // HANDLE: $(expr, context)
  9619. // (which is just equivalent to: $(context).find(expr)
  9620. } else {
  9621. return this.constructor( context ).find( selector );
  9622. }
  9623. // HANDLE: $(DOMElement)
  9624. } else if ( selector.nodeType ) {
  9625. this[ 0 ] = selector;
  9626. this.length = 1;
  9627. return this;
  9628. // HANDLE: $(function)
  9629. // Shortcut for document ready
  9630. } else if ( isFunction( selector ) ) {
  9631. return root.ready !== undefined ?
  9632. root.ready( selector ) :
  9633. // Execute immediately if ready is not present
  9634. selector( jQuery );
  9635. }
  9636. return jQuery.makeArray( selector, this );
  9637. };
  9638. // Give the init function the jQuery prototype for later instantiation
  9639. init.prototype = jQuery.fn;
  9640. // Initialize central reference
  9641. rootjQuery = jQuery( document );
  9642. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9643. // Methods guaranteed to produce a unique set when starting from a unique set
  9644. guaranteedUnique = {
  9645. children: true,
  9646. contents: true,
  9647. next: true,
  9648. prev: true
  9649. };
  9650. jQuery.fn.extend( {
  9651. has: function( target ) {
  9652. var targets = jQuery( target, this ),
  9653. l = targets.length;
  9654. return this.filter( function() {
  9655. var i = 0;
  9656. for ( ; i < l; i++ ) {
  9657. if ( jQuery.contains( this, targets[ i ] ) ) {
  9658. return true;
  9659. }
  9660. }
  9661. } );
  9662. },
  9663. closest: function( selectors, context ) {
  9664. var cur,
  9665. i = 0,
  9666. l = this.length,
  9667. matched = [],
  9668. targets = typeof selectors !== "string" && jQuery( selectors );
  9669. // Positional selectors never match, since there's no _selection_ context
  9670. if ( !rneedsContext.test( selectors ) ) {
  9671. for ( ; i < l; i++ ) {
  9672. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9673. // Always skip document fragments
  9674. if ( cur.nodeType < 11 && ( targets ?
  9675. targets.index( cur ) > -1 :
  9676. // Don't pass non-elements to Sizzle
  9677. cur.nodeType === 1 &&
  9678. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9679. matched.push( cur );
  9680. break;
  9681. }
  9682. }
  9683. }
  9684. }
  9685. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9686. },
  9687. // Determine the position of an element within the set
  9688. index: function( elem ) {
  9689. // No argument, return index in parent
  9690. if ( !elem ) {
  9691. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9692. }
  9693. // Index in selector
  9694. if ( typeof elem === "string" ) {
  9695. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9696. }
  9697. // Locate the position of the desired element
  9698. return indexOf.call( this,
  9699. // If it receives a jQuery object, the first element is used
  9700. elem.jquery ? elem[ 0 ] : elem
  9701. );
  9702. },
  9703. add: function( selector, context ) {
  9704. return this.pushStack(
  9705. jQuery.uniqueSort(
  9706. jQuery.merge( this.get(), jQuery( selector, context ) )
  9707. )
  9708. );
  9709. },
  9710. addBack: function( selector ) {
  9711. return this.add( selector == null ?
  9712. this.prevObject : this.prevObject.filter( selector )
  9713. );
  9714. }
  9715. } );
  9716. function sibling( cur, dir ) {
  9717. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9718. return cur;
  9719. }
  9720. jQuery.each( {
  9721. parent: function( elem ) {
  9722. var parent = elem.parentNode;
  9723. return parent && parent.nodeType !== 11 ? parent : null;
  9724. },
  9725. parents: function( elem ) {
  9726. return dir( elem, "parentNode" );
  9727. },
  9728. parentsUntil: function( elem, i, until ) {
  9729. return dir( elem, "parentNode", until );
  9730. },
  9731. next: function( elem ) {
  9732. return sibling( elem, "nextSibling" );
  9733. },
  9734. prev: function( elem ) {
  9735. return sibling( elem, "previousSibling" );
  9736. },
  9737. nextAll: function( elem ) {
  9738. return dir( elem, "nextSibling" );
  9739. },
  9740. prevAll: function( elem ) {
  9741. return dir( elem, "previousSibling" );
  9742. },
  9743. nextUntil: function( elem, i, until ) {
  9744. return dir( elem, "nextSibling", until );
  9745. },
  9746. prevUntil: function( elem, i, until ) {
  9747. return dir( elem, "previousSibling", until );
  9748. },
  9749. siblings: function( elem ) {
  9750. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9751. },
  9752. children: function( elem ) {
  9753. return siblings( elem.firstChild );
  9754. },
  9755. contents: function( elem ) {
  9756. if ( typeof elem.contentDocument !== "undefined" ) {
  9757. return elem.contentDocument;
  9758. }
  9759. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9760. // Treat the template element as a regular one in browsers that
  9761. // don't support it.
  9762. if ( nodeName( elem, "template" ) ) {
  9763. elem = elem.content || elem;
  9764. }
  9765. return jQuery.merge( [], elem.childNodes );
  9766. }
  9767. }, function( name, fn ) {
  9768. jQuery.fn[ name ] = function( until, selector ) {
  9769. var matched = jQuery.map( this, fn, until );
  9770. if ( name.slice( -5 ) !== "Until" ) {
  9771. selector = until;
  9772. }
  9773. if ( selector && typeof selector === "string" ) {
  9774. matched = jQuery.filter( selector, matched );
  9775. }
  9776. if ( this.length > 1 ) {
  9777. // Remove duplicates
  9778. if ( !guaranteedUnique[ name ] ) {
  9779. jQuery.uniqueSort( matched );
  9780. }
  9781. // Reverse order for parents* and prev-derivatives
  9782. if ( rparentsprev.test( name ) ) {
  9783. matched.reverse();
  9784. }
  9785. }
  9786. return this.pushStack( matched );
  9787. };
  9788. } );
  9789. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9790. // Convert String-formatted options into Object-formatted ones
  9791. function createOptions( options ) {
  9792. var object = {};
  9793. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9794. object[ flag ] = true;
  9795. } );
  9796. return object;
  9797. }
  9798. /*
  9799. * Create a callback list using the following parameters:
  9800. *
  9801. * options: an optional list of space-separated options that will change how
  9802. * the callback list behaves or a more traditional option object
  9803. *
  9804. * By default a callback list will act like an event callback list and can be
  9805. * "fired" multiple times.
  9806. *
  9807. * Possible options:
  9808. *
  9809. * once: will ensure the callback list can only be fired once (like a Deferred)
  9810. *
  9811. * memory: will keep track of previous values and will call any callback added
  9812. * after the list has been fired right away with the latest "memorized"
  9813. * values (like a Deferred)
  9814. *
  9815. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9816. *
  9817. * stopOnFalse: interrupt callings when a callback returns false
  9818. *
  9819. */
  9820. jQuery.Callbacks = function( options ) {
  9821. // Convert options from String-formatted to Object-formatted if needed
  9822. // (we check in cache first)
  9823. options = typeof options === "string" ?
  9824. createOptions( options ) :
  9825. jQuery.extend( {}, options );
  9826. var // Flag to know if list is currently firing
  9827. firing,
  9828. // Last fire value for non-forgettable lists
  9829. memory,
  9830. // Flag to know if list was already fired
  9831. fired,
  9832. // Flag to prevent firing
  9833. locked,
  9834. // Actual callback list
  9835. list = [],
  9836. // Queue of execution data for repeatable lists
  9837. queue = [],
  9838. // Index of currently firing callback (modified by add/remove as needed)
  9839. firingIndex = -1,
  9840. // Fire callbacks
  9841. fire = function() {
  9842. // Enforce single-firing
  9843. locked = locked || options.once;
  9844. // Execute callbacks for all pending executions,
  9845. // respecting firingIndex overrides and runtime changes
  9846. fired = firing = true;
  9847. for ( ; queue.length; firingIndex = -1 ) {
  9848. memory = queue.shift();
  9849. while ( ++firingIndex < list.length ) {
  9850. // Run callback and check for early termination
  9851. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9852. options.stopOnFalse ) {
  9853. // Jump to end and forget the data so .add doesn't re-fire
  9854. firingIndex = list.length;
  9855. memory = false;
  9856. }
  9857. }
  9858. }
  9859. // Forget the data if we're done with it
  9860. if ( !options.memory ) {
  9861. memory = false;
  9862. }
  9863. firing = false;
  9864. // Clean up if we're done firing for good
  9865. if ( locked ) {
  9866. // Keep an empty list if we have data for future add calls
  9867. if ( memory ) {
  9868. list = [];
  9869. // Otherwise, this object is spent
  9870. } else {
  9871. list = "";
  9872. }
  9873. }
  9874. },
  9875. // Actual Callbacks object
  9876. self = {
  9877. // Add a callback or a collection of callbacks to the list
  9878. add: function() {
  9879. if ( list ) {
  9880. // If we have memory from a past run, we should fire after adding
  9881. if ( memory && !firing ) {
  9882. firingIndex = list.length - 1;
  9883. queue.push( memory );
  9884. }
  9885. ( function add( args ) {
  9886. jQuery.each( args, function( _, arg ) {
  9887. if ( isFunction( arg ) ) {
  9888. if ( !options.unique || !self.has( arg ) ) {
  9889. list.push( arg );
  9890. }
  9891. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9892. // Inspect recursively
  9893. add( arg );
  9894. }
  9895. } );
  9896. } )( arguments );
  9897. if ( memory && !firing ) {
  9898. fire();
  9899. }
  9900. }
  9901. return this;
  9902. },
  9903. // Remove a callback from the list
  9904. remove: function() {
  9905. jQuery.each( arguments, function( _, arg ) {
  9906. var index;
  9907. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9908. list.splice( index, 1 );
  9909. // Handle firing indexes
  9910. if ( index <= firingIndex ) {
  9911. firingIndex--;
  9912. }
  9913. }
  9914. } );
  9915. return this;
  9916. },
  9917. // Check if a given callback is in the list.
  9918. // If no argument is given, return whether or not list has callbacks attached.
  9919. has: function( fn ) {
  9920. return fn ?
  9921. jQuery.inArray( fn, list ) > -1 :
  9922. list.length > 0;
  9923. },
  9924. // Remove all callbacks from the list
  9925. empty: function() {
  9926. if ( list ) {
  9927. list = [];
  9928. }
  9929. return this;
  9930. },
  9931. // Disable .fire and .add
  9932. // Abort any current/pending executions
  9933. // Clear all callbacks and values
  9934. disable: function() {
  9935. locked = queue = [];
  9936. list = memory = "";
  9937. return this;
  9938. },
  9939. disabled: function() {
  9940. return !list;
  9941. },
  9942. // Disable .fire
  9943. // Also disable .add unless we have memory (since it would have no effect)
  9944. // Abort any pending executions
  9945. lock: function() {
  9946. locked = queue = [];
  9947. if ( !memory && !firing ) {
  9948. list = memory = "";
  9949. }
  9950. return this;
  9951. },
  9952. locked: function() {
  9953. return !!locked;
  9954. },
  9955. // Call all callbacks with the given context and arguments
  9956. fireWith: function( context, args ) {
  9957. if ( !locked ) {
  9958. args = args || [];
  9959. args = [ context, args.slice ? args.slice() : args ];
  9960. queue.push( args );
  9961. if ( !firing ) {
  9962. fire();
  9963. }
  9964. }
  9965. return this;
  9966. },
  9967. // Call all the callbacks with the given arguments
  9968. fire: function() {
  9969. self.fireWith( this, arguments );
  9970. return this;
  9971. },
  9972. // To know if the callbacks have already been called at least once
  9973. fired: function() {
  9974. return !!fired;
  9975. }
  9976. };
  9977. return self;
  9978. };
  9979. function Identity( v ) {
  9980. return v;
  9981. }
  9982. function Thrower( ex ) {
  9983. throw ex;
  9984. }
  9985. function adoptValue( value, resolve, reject, noValue ) {
  9986. var method;
  9987. try {
  9988. // Check for promise aspect first to privilege synchronous behavior
  9989. if ( value && isFunction( ( method = value.promise ) ) ) {
  9990. method.call( value ).done( resolve ).fail( reject );
  9991. // Other thenables
  9992. } else if ( value && isFunction( ( method = value.then ) ) ) {
  9993. method.call( value, resolve, reject );
  9994. // Other non-thenables
  9995. } else {
  9996. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  9997. // * false: [ value ].slice( 0 ) => resolve( value )
  9998. // * true: [ value ].slice( 1 ) => resolve()
  9999. resolve.apply( undefined, [ value ].slice( noValue ) );
  10000. }
  10001. // For Promises/A+, convert exceptions into rejections
  10002. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10003. // Deferred#then to conditionally suppress rejection.
  10004. } catch ( value ) {
  10005. // Support: Android 4.0 only
  10006. // Strict mode functions invoked without .call/.apply get global-object context
  10007. reject.apply( undefined, [ value ] );
  10008. }
  10009. }
  10010. jQuery.extend( {
  10011. Deferred: function( func ) {
  10012. var tuples = [
  10013. // action, add listener, callbacks,
  10014. // ... .then handlers, argument index, [final state]
  10015. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10016. jQuery.Callbacks( "memory" ), 2 ],
  10017. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10018. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10019. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10020. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10021. ],
  10022. state = "pending",
  10023. promise = {
  10024. state: function() {
  10025. return state;
  10026. },
  10027. always: function() {
  10028. deferred.done( arguments ).fail( arguments );
  10029. return this;
  10030. },
  10031. "catch": function( fn ) {
  10032. return promise.then( null, fn );
  10033. },
  10034. // Keep pipe for back-compat
  10035. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10036. var fns = arguments;
  10037. return jQuery.Deferred( function( newDefer ) {
  10038. jQuery.each( tuples, function( i, tuple ) {
  10039. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10040. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10041. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10042. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10043. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10044. deferred[ tuple[ 1 ] ]( function() {
  10045. var returned = fn && fn.apply( this, arguments );
  10046. if ( returned && isFunction( returned.promise ) ) {
  10047. returned.promise()
  10048. .progress( newDefer.notify )
  10049. .done( newDefer.resolve )
  10050. .fail( newDefer.reject );
  10051. } else {
  10052. newDefer[ tuple[ 0 ] + "With" ](
  10053. this,
  10054. fn ? [ returned ] : arguments
  10055. );
  10056. }
  10057. } );
  10058. } );
  10059. fns = null;
  10060. } ).promise();
  10061. },
  10062. then: function( onFulfilled, onRejected, onProgress ) {
  10063. var maxDepth = 0;
  10064. function resolve( depth, deferred, handler, special ) {
  10065. return function() {
  10066. var that = this,
  10067. args = arguments,
  10068. mightThrow = function() {
  10069. var returned, then;
  10070. // Support: Promises/A+ section 2.3.3.3.3
  10071. // https://promisesaplus.com/#point-59
  10072. // Ignore double-resolution attempts
  10073. if ( depth < maxDepth ) {
  10074. return;
  10075. }
  10076. returned = handler.apply( that, args );
  10077. // Support: Promises/A+ section 2.3.1
  10078. // https://promisesaplus.com/#point-48
  10079. if ( returned === deferred.promise() ) {
  10080. throw new TypeError( "Thenable self-resolution" );
  10081. }
  10082. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10083. // https://promisesaplus.com/#point-54
  10084. // https://promisesaplus.com/#point-75
  10085. // Retrieve `then` only once
  10086. then = returned &&
  10087. // Support: Promises/A+ section 2.3.4
  10088. // https://promisesaplus.com/#point-64
  10089. // Only check objects and functions for thenability
  10090. ( typeof returned === "object" ||
  10091. typeof returned === "function" ) &&
  10092. returned.then;
  10093. // Handle a returned thenable
  10094. if ( isFunction( then ) ) {
  10095. // Special processors (notify) just wait for resolution
  10096. if ( special ) {
  10097. then.call(
  10098. returned,
  10099. resolve( maxDepth, deferred, Identity, special ),
  10100. resolve( maxDepth, deferred, Thrower, special )
  10101. );
  10102. // Normal processors (resolve) also hook into progress
  10103. } else {
  10104. // ...and disregard older resolution values
  10105. maxDepth++;
  10106. then.call(
  10107. returned,
  10108. resolve( maxDepth, deferred, Identity, special ),
  10109. resolve( maxDepth, deferred, Thrower, special ),
  10110. resolve( maxDepth, deferred, Identity,
  10111. deferred.notifyWith )
  10112. );
  10113. }
  10114. // Handle all other returned values
  10115. } else {
  10116. // Only substitute handlers pass on context
  10117. // and multiple values (non-spec behavior)
  10118. if ( handler !== Identity ) {
  10119. that = undefined;
  10120. args = [ returned ];
  10121. }
  10122. // Process the value(s)
  10123. // Default process is resolve
  10124. ( special || deferred.resolveWith )( that, args );
  10125. }
  10126. },
  10127. // Only normal processors (resolve) catch and reject exceptions
  10128. process = special ?
  10129. mightThrow :
  10130. function() {
  10131. try {
  10132. mightThrow();
  10133. } catch ( e ) {
  10134. if ( jQuery.Deferred.exceptionHook ) {
  10135. jQuery.Deferred.exceptionHook( e,
  10136. process.stackTrace );
  10137. }
  10138. // Support: Promises/A+ section 2.3.3.3.4.1
  10139. // https://promisesaplus.com/#point-61
  10140. // Ignore post-resolution exceptions
  10141. if ( depth + 1 >= maxDepth ) {
  10142. // Only substitute handlers pass on context
  10143. // and multiple values (non-spec behavior)
  10144. if ( handler !== Thrower ) {
  10145. that = undefined;
  10146. args = [ e ];
  10147. }
  10148. deferred.rejectWith( that, args );
  10149. }
  10150. }
  10151. };
  10152. // Support: Promises/A+ section 2.3.3.3.1
  10153. // https://promisesaplus.com/#point-57
  10154. // Re-resolve promises immediately to dodge false rejection from
  10155. // subsequent errors
  10156. if ( depth ) {
  10157. process();
  10158. } else {
  10159. // Call an optional hook to record the stack, in case of exception
  10160. // since it's otherwise lost when execution goes async
  10161. if ( jQuery.Deferred.getStackHook ) {
  10162. process.stackTrace = jQuery.Deferred.getStackHook();
  10163. }
  10164. window.setTimeout( process );
  10165. }
  10166. };
  10167. }
  10168. return jQuery.Deferred( function( newDefer ) {
  10169. // progress_handlers.add( ... )
  10170. tuples[ 0 ][ 3 ].add(
  10171. resolve(
  10172. 0,
  10173. newDefer,
  10174. isFunction( onProgress ) ?
  10175. onProgress :
  10176. Identity,
  10177. newDefer.notifyWith
  10178. )
  10179. );
  10180. // fulfilled_handlers.add( ... )
  10181. tuples[ 1 ][ 3 ].add(
  10182. resolve(
  10183. 0,
  10184. newDefer,
  10185. isFunction( onFulfilled ) ?
  10186. onFulfilled :
  10187. Identity
  10188. )
  10189. );
  10190. // rejected_handlers.add( ... )
  10191. tuples[ 2 ][ 3 ].add(
  10192. resolve(
  10193. 0,
  10194. newDefer,
  10195. isFunction( onRejected ) ?
  10196. onRejected :
  10197. Thrower
  10198. )
  10199. );
  10200. } ).promise();
  10201. },
  10202. // Get a promise for this deferred
  10203. // If obj is provided, the promise aspect is added to the object
  10204. promise: function( obj ) {
  10205. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10206. }
  10207. },
  10208. deferred = {};
  10209. // Add list-specific methods
  10210. jQuery.each( tuples, function( i, tuple ) {
  10211. var list = tuple[ 2 ],
  10212. stateString = tuple[ 5 ];
  10213. // promise.progress = list.add
  10214. // promise.done = list.add
  10215. // promise.fail = list.add
  10216. promise[ tuple[ 1 ] ] = list.add;
  10217. // Handle state
  10218. if ( stateString ) {
  10219. list.add(
  10220. function() {
  10221. // state = "resolved" (i.e., fulfilled)
  10222. // state = "rejected"
  10223. state = stateString;
  10224. },
  10225. // rejected_callbacks.disable
  10226. // fulfilled_callbacks.disable
  10227. tuples[ 3 - i ][ 2 ].disable,
  10228. // rejected_handlers.disable
  10229. // fulfilled_handlers.disable
  10230. tuples[ 3 - i ][ 3 ].disable,
  10231. // progress_callbacks.lock
  10232. tuples[ 0 ][ 2 ].lock,
  10233. // progress_handlers.lock
  10234. tuples[ 0 ][ 3 ].lock
  10235. );
  10236. }
  10237. // progress_handlers.fire
  10238. // fulfilled_handlers.fire
  10239. // rejected_handlers.fire
  10240. list.add( tuple[ 3 ].fire );
  10241. // deferred.notify = function() { deferred.notifyWith(...) }
  10242. // deferred.resolve = function() { deferred.resolveWith(...) }
  10243. // deferred.reject = function() { deferred.rejectWith(...) }
  10244. deferred[ tuple[ 0 ] ] = function() {
  10245. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10246. return this;
  10247. };
  10248. // deferred.notifyWith = list.fireWith
  10249. // deferred.resolveWith = list.fireWith
  10250. // deferred.rejectWith = list.fireWith
  10251. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10252. } );
  10253. // Make the deferred a promise
  10254. promise.promise( deferred );
  10255. // Call given func if any
  10256. if ( func ) {
  10257. func.call( deferred, deferred );
  10258. }
  10259. // All done!
  10260. return deferred;
  10261. },
  10262. // Deferred helper
  10263. when: function( singleValue ) {
  10264. var
  10265. // count of uncompleted subordinates
  10266. remaining = arguments.length,
  10267. // count of unprocessed arguments
  10268. i = remaining,
  10269. // subordinate fulfillment data
  10270. resolveContexts = Array( i ),
  10271. resolveValues = slice.call( arguments ),
  10272. // the master Deferred
  10273. master = jQuery.Deferred(),
  10274. // subordinate callback factory
  10275. updateFunc = function( i ) {
  10276. return function( value ) {
  10277. resolveContexts[ i ] = this;
  10278. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10279. if ( !( --remaining ) ) {
  10280. master.resolveWith( resolveContexts, resolveValues );
  10281. }
  10282. };
  10283. };
  10284. // Single- and empty arguments are adopted like Promise.resolve
  10285. if ( remaining <= 1 ) {
  10286. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10287. !remaining );
  10288. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10289. if ( master.state() === "pending" ||
  10290. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10291. return master.then();
  10292. }
  10293. }
  10294. // Multiple arguments are aggregated like Promise.all array elements
  10295. while ( i-- ) {
  10296. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10297. }
  10298. return master.promise();
  10299. }
  10300. } );
  10301. // These usually indicate a programmer mistake during development,
  10302. // warn about them ASAP rather than swallowing them by default.
  10303. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10304. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10305. // Support: IE 8 - 9 only
  10306. // Console exists when dev tools are open, which can happen at any time
  10307. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10308. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10309. }
  10310. };
  10311. jQuery.readyException = function( error ) {
  10312. window.setTimeout( function() {
  10313. throw error;
  10314. } );
  10315. };
  10316. // The deferred used on DOM ready
  10317. var readyList = jQuery.Deferred();
  10318. jQuery.fn.ready = function( fn ) {
  10319. readyList
  10320. .then( fn )
  10321. // Wrap jQuery.readyException in a function so that the lookup
  10322. // happens at the time of error handling instead of callback
  10323. // registration.
  10324. .catch( function( error ) {
  10325. jQuery.readyException( error );
  10326. } );
  10327. return this;
  10328. };
  10329. jQuery.extend( {
  10330. // Is the DOM ready to be used? Set to true once it occurs.
  10331. isReady: false,
  10332. // A counter to track how many items to wait for before
  10333. // the ready event fires. See #6781
  10334. readyWait: 1,
  10335. // Handle when the DOM is ready
  10336. ready: function( wait ) {
  10337. // Abort if there are pending holds or we're already ready
  10338. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10339. return;
  10340. }
  10341. // Remember that the DOM is ready
  10342. jQuery.isReady = true;
  10343. // If a normal DOM Ready event fired, decrement, and wait if need be
  10344. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10345. return;
  10346. }
  10347. // If there are functions bound, to execute
  10348. readyList.resolveWith( document, [ jQuery ] );
  10349. }
  10350. } );
  10351. jQuery.ready.then = readyList.then;
  10352. // The ready event handler and self cleanup method
  10353. function completed() {
  10354. document.removeEventListener( "DOMContentLoaded", completed );
  10355. window.removeEventListener( "load", completed );
  10356. jQuery.ready();
  10357. }
  10358. // Catch cases where $(document).ready() is called
  10359. // after the browser event has already occurred.
  10360. // Support: IE <=9 - 10 only
  10361. // Older IE sometimes signals "interactive" too soon
  10362. if ( document.readyState === "complete" ||
  10363. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10364. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10365. window.setTimeout( jQuery.ready );
  10366. } else {
  10367. // Use the handy event callback
  10368. document.addEventListener( "DOMContentLoaded", completed );
  10369. // A fallback to window.onload, that will always work
  10370. window.addEventListener( "load", completed );
  10371. }
  10372. // Multifunctional method to get and set values of a collection
  10373. // The value/s can optionally be executed if it's a function
  10374. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10375. var i = 0,
  10376. len = elems.length,
  10377. bulk = key == null;
  10378. // Sets many values
  10379. if ( toType( key ) === "object" ) {
  10380. chainable = true;
  10381. for ( i in key ) {
  10382. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10383. }
  10384. // Sets one value
  10385. } else if ( value !== undefined ) {
  10386. chainable = true;
  10387. if ( !isFunction( value ) ) {
  10388. raw = true;
  10389. }
  10390. if ( bulk ) {
  10391. // Bulk operations run against the entire set
  10392. if ( raw ) {
  10393. fn.call( elems, value );
  10394. fn = null;
  10395. // ...except when executing function values
  10396. } else {
  10397. bulk = fn;
  10398. fn = function( elem, key, value ) {
  10399. return bulk.call( jQuery( elem ), value );
  10400. };
  10401. }
  10402. }
  10403. if ( fn ) {
  10404. for ( ; i < len; i++ ) {
  10405. fn(
  10406. elems[ i ], key, raw ?
  10407. value :
  10408. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10409. );
  10410. }
  10411. }
  10412. }
  10413. if ( chainable ) {
  10414. return elems;
  10415. }
  10416. // Gets
  10417. if ( bulk ) {
  10418. return fn.call( elems );
  10419. }
  10420. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10421. };
  10422. // Matches dashed string for camelizing
  10423. var rmsPrefix = /^-ms-/,
  10424. rdashAlpha = /-([a-z])/g;
  10425. // Used by camelCase as callback to replace()
  10426. function fcamelCase( all, letter ) {
  10427. return letter.toUpperCase();
  10428. }
  10429. // Convert dashed to camelCase; used by the css and data modules
  10430. // Support: IE <=9 - 11, Edge 12 - 15
  10431. // Microsoft forgot to hump their vendor prefix (#9572)
  10432. function camelCase( string ) {
  10433. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10434. }
  10435. var acceptData = function( owner ) {
  10436. // Accepts only:
  10437. // - Node
  10438. // - Node.ELEMENT_NODE
  10439. // - Node.DOCUMENT_NODE
  10440. // - Object
  10441. // - Any
  10442. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10443. };
  10444. function Data() {
  10445. this.expando = jQuery.expando + Data.uid++;
  10446. }
  10447. Data.uid = 1;
  10448. Data.prototype = {
  10449. cache: function( owner ) {
  10450. // Check if the owner object already has a cache
  10451. var value = owner[ this.expando ];
  10452. // If not, create one
  10453. if ( !value ) {
  10454. value = {};
  10455. // We can accept data for non-element nodes in modern browsers,
  10456. // but we should not, see #8335.
  10457. // Always return an empty object.
  10458. if ( acceptData( owner ) ) {
  10459. // If it is a node unlikely to be stringify-ed or looped over
  10460. // use plain assignment
  10461. if ( owner.nodeType ) {
  10462. owner[ this.expando ] = value;
  10463. // Otherwise secure it in a non-enumerable property
  10464. // configurable must be true to allow the property to be
  10465. // deleted when data is removed
  10466. } else {
  10467. Object.defineProperty( owner, this.expando, {
  10468. value: value,
  10469. configurable: true
  10470. } );
  10471. }
  10472. }
  10473. }
  10474. return value;
  10475. },
  10476. set: function( owner, data, value ) {
  10477. var prop,
  10478. cache = this.cache( owner );
  10479. // Handle: [ owner, key, value ] args
  10480. // Always use camelCase key (gh-2257)
  10481. if ( typeof data === "string" ) {
  10482. cache[ camelCase( data ) ] = value;
  10483. // Handle: [ owner, { properties } ] args
  10484. } else {
  10485. // Copy the properties one-by-one to the cache object
  10486. for ( prop in data ) {
  10487. cache[ camelCase( prop ) ] = data[ prop ];
  10488. }
  10489. }
  10490. return cache;
  10491. },
  10492. get: function( owner, key ) {
  10493. return key === undefined ?
  10494. this.cache( owner ) :
  10495. // Always use camelCase key (gh-2257)
  10496. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10497. },
  10498. access: function( owner, key, value ) {
  10499. // In cases where either:
  10500. //
  10501. // 1. No key was specified
  10502. // 2. A string key was specified, but no value provided
  10503. //
  10504. // Take the "read" path and allow the get method to determine
  10505. // which value to return, respectively either:
  10506. //
  10507. // 1. The entire cache object
  10508. // 2. The data stored at the key
  10509. //
  10510. if ( key === undefined ||
  10511. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10512. return this.get( owner, key );
  10513. }
  10514. // When the key is not a string, or both a key and value
  10515. // are specified, set or extend (existing objects) with either:
  10516. //
  10517. // 1. An object of properties
  10518. // 2. A key and value
  10519. //
  10520. this.set( owner, key, value );
  10521. // Since the "set" path can have two possible entry points
  10522. // return the expected data based on which path was taken[*]
  10523. return value !== undefined ? value : key;
  10524. },
  10525. remove: function( owner, key ) {
  10526. var i,
  10527. cache = owner[ this.expando ];
  10528. if ( cache === undefined ) {
  10529. return;
  10530. }
  10531. if ( key !== undefined ) {
  10532. // Support array or space separated string of keys
  10533. if ( Array.isArray( key ) ) {
  10534. // If key is an array of keys...
  10535. // We always set camelCase keys, so remove that.
  10536. key = key.map( camelCase );
  10537. } else {
  10538. key = camelCase( key );
  10539. // If a key with the spaces exists, use it.
  10540. // Otherwise, create an array by matching non-whitespace
  10541. key = key in cache ?
  10542. [ key ] :
  10543. ( key.match( rnothtmlwhite ) || [] );
  10544. }
  10545. i = key.length;
  10546. while ( i-- ) {
  10547. delete cache[ key[ i ] ];
  10548. }
  10549. }
  10550. // Remove the expando if there's no more data
  10551. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10552. // Support: Chrome <=35 - 45
  10553. // Webkit & Blink performance suffers when deleting properties
  10554. // from DOM nodes, so set to undefined instead
  10555. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10556. if ( owner.nodeType ) {
  10557. owner[ this.expando ] = undefined;
  10558. } else {
  10559. delete owner[ this.expando ];
  10560. }
  10561. }
  10562. },
  10563. hasData: function( owner ) {
  10564. var cache = owner[ this.expando ];
  10565. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10566. }
  10567. };
  10568. var dataPriv = new Data();
  10569. var dataUser = new Data();
  10570. // Implementation Summary
  10571. //
  10572. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10573. // 2. Improve the module's maintainability by reducing the storage
  10574. // paths to a single mechanism.
  10575. // 3. Use the same single mechanism to support "private" and "user" data.
  10576. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10577. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10578. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10579. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10580. rmultiDash = /[A-Z]/g;
  10581. function getData( data ) {
  10582. if ( data === "true" ) {
  10583. return true;
  10584. }
  10585. if ( data === "false" ) {
  10586. return false;
  10587. }
  10588. if ( data === "null" ) {
  10589. return null;
  10590. }
  10591. // Only convert to a number if it doesn't change the string
  10592. if ( data === +data + "" ) {
  10593. return +data;
  10594. }
  10595. if ( rbrace.test( data ) ) {
  10596. return JSON.parse( data );
  10597. }
  10598. return data;
  10599. }
  10600. function dataAttr( elem, key, data ) {
  10601. var name;
  10602. // If nothing was found internally, try to fetch any
  10603. // data from the HTML5 data-* attribute
  10604. if ( data === undefined && elem.nodeType === 1 ) {
  10605. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10606. data = elem.getAttribute( name );
  10607. if ( typeof data === "string" ) {
  10608. try {
  10609. data = getData( data );
  10610. } catch ( e ) {}
  10611. // Make sure we set the data so it isn't changed later
  10612. dataUser.set( elem, key, data );
  10613. } else {
  10614. data = undefined;
  10615. }
  10616. }
  10617. return data;
  10618. }
  10619. jQuery.extend( {
  10620. hasData: function( elem ) {
  10621. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10622. },
  10623. data: function( elem, name, data ) {
  10624. return dataUser.access( elem, name, data );
  10625. },
  10626. removeData: function( elem, name ) {
  10627. dataUser.remove( elem, name );
  10628. },
  10629. // TODO: Now that all calls to _data and _removeData have been replaced
  10630. // with direct calls to dataPriv methods, these can be deprecated.
  10631. _data: function( elem, name, data ) {
  10632. return dataPriv.access( elem, name, data );
  10633. },
  10634. _removeData: function( elem, name ) {
  10635. dataPriv.remove( elem, name );
  10636. }
  10637. } );
  10638. jQuery.fn.extend( {
  10639. data: function( key, value ) {
  10640. var i, name, data,
  10641. elem = this[ 0 ],
  10642. attrs = elem && elem.attributes;
  10643. // Gets all values
  10644. if ( key === undefined ) {
  10645. if ( this.length ) {
  10646. data = dataUser.get( elem );
  10647. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10648. i = attrs.length;
  10649. while ( i-- ) {
  10650. // Support: IE 11 only
  10651. // The attrs elements can be null (#14894)
  10652. if ( attrs[ i ] ) {
  10653. name = attrs[ i ].name;
  10654. if ( name.indexOf( "data-" ) === 0 ) {
  10655. name = camelCase( name.slice( 5 ) );
  10656. dataAttr( elem, name, data[ name ] );
  10657. }
  10658. }
  10659. }
  10660. dataPriv.set( elem, "hasDataAttrs", true );
  10661. }
  10662. }
  10663. return data;
  10664. }
  10665. // Sets multiple values
  10666. if ( typeof key === "object" ) {
  10667. return this.each( function() {
  10668. dataUser.set( this, key );
  10669. } );
  10670. }
  10671. return access( this, function( value ) {
  10672. var data;
  10673. // The calling jQuery object (element matches) is not empty
  10674. // (and therefore has an element appears at this[ 0 ]) and the
  10675. // `value` parameter was not undefined. An empty jQuery object
  10676. // will result in `undefined` for elem = this[ 0 ] which will
  10677. // throw an exception if an attempt to read a data cache is made.
  10678. if ( elem && value === undefined ) {
  10679. // Attempt to get data from the cache
  10680. // The key will always be camelCased in Data
  10681. data = dataUser.get( elem, key );
  10682. if ( data !== undefined ) {
  10683. return data;
  10684. }
  10685. // Attempt to "discover" the data in
  10686. // HTML5 custom data-* attrs
  10687. data = dataAttr( elem, key );
  10688. if ( data !== undefined ) {
  10689. return data;
  10690. }
  10691. // We tried really hard, but the data doesn't exist.
  10692. return;
  10693. }
  10694. // Set the data...
  10695. this.each( function() {
  10696. // We always store the camelCased key
  10697. dataUser.set( this, key, value );
  10698. } );
  10699. }, null, value, arguments.length > 1, null, true );
  10700. },
  10701. removeData: function( key ) {
  10702. return this.each( function() {
  10703. dataUser.remove( this, key );
  10704. } );
  10705. }
  10706. } );
  10707. jQuery.extend( {
  10708. queue: function( elem, type, data ) {
  10709. var queue;
  10710. if ( elem ) {
  10711. type = ( type || "fx" ) + "queue";
  10712. queue = dataPriv.get( elem, type );
  10713. // Speed up dequeue by getting out quickly if this is just a lookup
  10714. if ( data ) {
  10715. if ( !queue || Array.isArray( data ) ) {
  10716. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10717. } else {
  10718. queue.push( data );
  10719. }
  10720. }
  10721. return queue || [];
  10722. }
  10723. },
  10724. dequeue: function( elem, type ) {
  10725. type = type || "fx";
  10726. var queue = jQuery.queue( elem, type ),
  10727. startLength = queue.length,
  10728. fn = queue.shift(),
  10729. hooks = jQuery._queueHooks( elem, type ),
  10730. next = function() {
  10731. jQuery.dequeue( elem, type );
  10732. };
  10733. // If the fx queue is dequeued, always remove the progress sentinel
  10734. if ( fn === "inprogress" ) {
  10735. fn = queue.shift();
  10736. startLength--;
  10737. }
  10738. if ( fn ) {
  10739. // Add a progress sentinel to prevent the fx queue from being
  10740. // automatically dequeued
  10741. if ( type === "fx" ) {
  10742. queue.unshift( "inprogress" );
  10743. }
  10744. // Clear up the last queue stop function
  10745. delete hooks.stop;
  10746. fn.call( elem, next, hooks );
  10747. }
  10748. if ( !startLength && hooks ) {
  10749. hooks.empty.fire();
  10750. }
  10751. },
  10752. // Not public - generate a queueHooks object, or return the current one
  10753. _queueHooks: function( elem, type ) {
  10754. var key = type + "queueHooks";
  10755. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10756. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10757. dataPriv.remove( elem, [ type + "queue", key ] );
  10758. } )
  10759. } );
  10760. }
  10761. } );
  10762. jQuery.fn.extend( {
  10763. queue: function( type, data ) {
  10764. var setter = 2;
  10765. if ( typeof type !== "string" ) {
  10766. data = type;
  10767. type = "fx";
  10768. setter--;
  10769. }
  10770. if ( arguments.length < setter ) {
  10771. return jQuery.queue( this[ 0 ], type );
  10772. }
  10773. return data === undefined ?
  10774. this :
  10775. this.each( function() {
  10776. var queue = jQuery.queue( this, type, data );
  10777. // Ensure a hooks for this queue
  10778. jQuery._queueHooks( this, type );
  10779. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10780. jQuery.dequeue( this, type );
  10781. }
  10782. } );
  10783. },
  10784. dequeue: function( type ) {
  10785. return this.each( function() {
  10786. jQuery.dequeue( this, type );
  10787. } );
  10788. },
  10789. clearQueue: function( type ) {
  10790. return this.queue( type || "fx", [] );
  10791. },
  10792. // Get a promise resolved when queues of a certain type
  10793. // are emptied (fx is the type by default)
  10794. promise: function( type, obj ) {
  10795. var tmp,
  10796. count = 1,
  10797. defer = jQuery.Deferred(),
  10798. elements = this,
  10799. i = this.length,
  10800. resolve = function() {
  10801. if ( !( --count ) ) {
  10802. defer.resolveWith( elements, [ elements ] );
  10803. }
  10804. };
  10805. if ( typeof type !== "string" ) {
  10806. obj = type;
  10807. type = undefined;
  10808. }
  10809. type = type || "fx";
  10810. while ( i-- ) {
  10811. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10812. if ( tmp && tmp.empty ) {
  10813. count++;
  10814. tmp.empty.add( resolve );
  10815. }
  10816. }
  10817. resolve();
  10818. return defer.promise( obj );
  10819. }
  10820. } );
  10821. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10822. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10823. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10824. var documentElement = document.documentElement;
  10825. var isAttached = function( elem ) {
  10826. return jQuery.contains( elem.ownerDocument, elem );
  10827. },
  10828. composed = { composed: true };
  10829. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10830. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10831. // Support: iOS 10.0-10.2 only
  10832. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10833. // leading to errors. We need to check for `getRootNode`.
  10834. if ( documentElement.getRootNode ) {
  10835. isAttached = function( elem ) {
  10836. return jQuery.contains( elem.ownerDocument, elem ) ||
  10837. elem.getRootNode( composed ) === elem.ownerDocument;
  10838. };
  10839. }
  10840. var isHiddenWithinTree = function( elem, el ) {
  10841. // isHiddenWithinTree might be called from jQuery#filter function;
  10842. // in that case, element will be second argument
  10843. elem = el || elem;
  10844. // Inline style trumps all
  10845. return elem.style.display === "none" ||
  10846. elem.style.display === "" &&
  10847. // Otherwise, check computed style
  10848. // Support: Firefox <=43 - 45
  10849. // Disconnected elements can have computed display: none, so first confirm that elem is
  10850. // in the document.
  10851. isAttached( elem ) &&
  10852. jQuery.css( elem, "display" ) === "none";
  10853. };
  10854. var swap = function( elem, options, callback, args ) {
  10855. var ret, name,
  10856. old = {};
  10857. // Remember the old values, and insert the new ones
  10858. for ( name in options ) {
  10859. old[ name ] = elem.style[ name ];
  10860. elem.style[ name ] = options[ name ];
  10861. }
  10862. ret = callback.apply( elem, args || [] );
  10863. // Revert the old values
  10864. for ( name in options ) {
  10865. elem.style[ name ] = old[ name ];
  10866. }
  10867. return ret;
  10868. };
  10869. function adjustCSS( elem, prop, valueParts, tween ) {
  10870. var adjusted, scale,
  10871. maxIterations = 20,
  10872. currentValue = tween ?
  10873. function() {
  10874. return tween.cur();
  10875. } :
  10876. function() {
  10877. return jQuery.css( elem, prop, "" );
  10878. },
  10879. initial = currentValue(),
  10880. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10881. // Starting value computation is required for potential unit mismatches
  10882. initialInUnit = elem.nodeType &&
  10883. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10884. rcssNum.exec( jQuery.css( elem, prop ) );
  10885. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10886. // Support: Firefox <=54
  10887. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10888. initial = initial / 2;
  10889. // Trust units reported by jQuery.css
  10890. unit = unit || initialInUnit[ 3 ];
  10891. // Iteratively approximate from a nonzero starting point
  10892. initialInUnit = +initial || 1;
  10893. while ( maxIterations-- ) {
  10894. // Evaluate and update our best guess (doubling guesses that zero out).
  10895. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10896. jQuery.style( elem, prop, initialInUnit + unit );
  10897. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10898. maxIterations = 0;
  10899. }
  10900. initialInUnit = initialInUnit / scale;
  10901. }
  10902. initialInUnit = initialInUnit * 2;
  10903. jQuery.style( elem, prop, initialInUnit + unit );
  10904. // Make sure we update the tween properties later on
  10905. valueParts = valueParts || [];
  10906. }
  10907. if ( valueParts ) {
  10908. initialInUnit = +initialInUnit || +initial || 0;
  10909. // Apply relative offset (+=/-=) if specified
  10910. adjusted = valueParts[ 1 ] ?
  10911. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10912. +valueParts[ 2 ];
  10913. if ( tween ) {
  10914. tween.unit = unit;
  10915. tween.start = initialInUnit;
  10916. tween.end = adjusted;
  10917. }
  10918. }
  10919. return adjusted;
  10920. }
  10921. var defaultDisplayMap = {};
  10922. function getDefaultDisplay( elem ) {
  10923. var temp,
  10924. doc = elem.ownerDocument,
  10925. nodeName = elem.nodeName,
  10926. display = defaultDisplayMap[ nodeName ];
  10927. if ( display ) {
  10928. return display;
  10929. }
  10930. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10931. display = jQuery.css( temp, "display" );
  10932. temp.parentNode.removeChild( temp );
  10933. if ( display === "none" ) {
  10934. display = "block";
  10935. }
  10936. defaultDisplayMap[ nodeName ] = display;
  10937. return display;
  10938. }
  10939. function showHide( elements, show ) {
  10940. var display, elem,
  10941. values = [],
  10942. index = 0,
  10943. length = elements.length;
  10944. // Determine new display value for elements that need to change
  10945. for ( ; index < length; index++ ) {
  10946. elem = elements[ index ];
  10947. if ( !elem.style ) {
  10948. continue;
  10949. }
  10950. display = elem.style.display;
  10951. if ( show ) {
  10952. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10953. // check is required in this first loop unless we have a nonempty display value (either
  10954. // inline or about-to-be-restored)
  10955. if ( display === "none" ) {
  10956. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10957. if ( !values[ index ] ) {
  10958. elem.style.display = "";
  10959. }
  10960. }
  10961. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10962. values[ index ] = getDefaultDisplay( elem );
  10963. }
  10964. } else {
  10965. if ( display !== "none" ) {
  10966. values[ index ] = "none";
  10967. // Remember what we're overwriting
  10968. dataPriv.set( elem, "display", display );
  10969. }
  10970. }
  10971. }
  10972. // Set the display of the elements in a second loop to avoid constant reflow
  10973. for ( index = 0; index < length; index++ ) {
  10974. if ( values[ index ] != null ) {
  10975. elements[ index ].style.display = values[ index ];
  10976. }
  10977. }
  10978. return elements;
  10979. }
  10980. jQuery.fn.extend( {
  10981. show: function() {
  10982. return showHide( this, true );
  10983. },
  10984. hide: function() {
  10985. return showHide( this );
  10986. },
  10987. toggle: function( state ) {
  10988. if ( typeof state === "boolean" ) {
  10989. return state ? this.show() : this.hide();
  10990. }
  10991. return this.each( function() {
  10992. if ( isHiddenWithinTree( this ) ) {
  10993. jQuery( this ).show();
  10994. } else {
  10995. jQuery( this ).hide();
  10996. }
  10997. } );
  10998. }
  10999. } );
  11000. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11001. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11002. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11003. // We have to close these tags to support XHTML (#13200)
  11004. var wrapMap = {
  11005. // Support: IE <=9 only
  11006. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11007. // XHTML parsers do not magically insert elements in the
  11008. // same way that tag soup parsers do. So we cannot shorten
  11009. // this by omitting <tbody> or other required elements.
  11010. thead: [ 1, "<table>", "</table>" ],
  11011. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11012. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11013. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11014. _default: [ 0, "", "" ]
  11015. };
  11016. // Support: IE <=9 only
  11017. wrapMap.optgroup = wrapMap.option;
  11018. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11019. wrapMap.th = wrapMap.td;
  11020. function getAll( context, tag ) {
  11021. // Support: IE <=9 - 11 only
  11022. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11023. var ret;
  11024. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11025. ret = context.getElementsByTagName( tag || "*" );
  11026. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11027. ret = context.querySelectorAll( tag || "*" );
  11028. } else {
  11029. ret = [];
  11030. }
  11031. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11032. return jQuery.merge( [ context ], ret );
  11033. }
  11034. return ret;
  11035. }
  11036. // Mark scripts as having already been evaluated
  11037. function setGlobalEval( elems, refElements ) {
  11038. var i = 0,
  11039. l = elems.length;
  11040. for ( ; i < l; i++ ) {
  11041. dataPriv.set(
  11042. elems[ i ],
  11043. "globalEval",
  11044. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11045. );
  11046. }
  11047. }
  11048. var rhtml = /<|&#?\w+;/;
  11049. function buildFragment( elems, context, scripts, selection, ignored ) {
  11050. var elem, tmp, tag, wrap, attached, j,
  11051. fragment = context.createDocumentFragment(),
  11052. nodes = [],
  11053. i = 0,
  11054. l = elems.length;
  11055. for ( ; i < l; i++ ) {
  11056. elem = elems[ i ];
  11057. if ( elem || elem === 0 ) {
  11058. // Add nodes directly
  11059. if ( toType( elem ) === "object" ) {
  11060. // Support: Android <=4.0 only, PhantomJS 1 only
  11061. // push.apply(_, arraylike) throws on ancient WebKit
  11062. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11063. // Convert non-html into a text node
  11064. } else if ( !rhtml.test( elem ) ) {
  11065. nodes.push( context.createTextNode( elem ) );
  11066. // Convert html into DOM nodes
  11067. } else {
  11068. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11069. // Deserialize a standard representation
  11070. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11071. wrap = wrapMap[ tag ] || wrapMap._default;
  11072. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11073. // Descend through wrappers to the right content
  11074. j = wrap[ 0 ];
  11075. while ( j-- ) {
  11076. tmp = tmp.lastChild;
  11077. }
  11078. // Support: Android <=4.0 only, PhantomJS 1 only
  11079. // push.apply(_, arraylike) throws on ancient WebKit
  11080. jQuery.merge( nodes, tmp.childNodes );
  11081. // Remember the top-level container
  11082. tmp = fragment.firstChild;
  11083. // Ensure the created nodes are orphaned (#12392)
  11084. tmp.textContent = "";
  11085. }
  11086. }
  11087. }
  11088. // Remove wrapper from fragment
  11089. fragment.textContent = "";
  11090. i = 0;
  11091. while ( ( elem = nodes[ i++ ] ) ) {
  11092. // Skip elements already in the context collection (trac-4087)
  11093. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11094. if ( ignored ) {
  11095. ignored.push( elem );
  11096. }
  11097. continue;
  11098. }
  11099. attached = isAttached( elem );
  11100. // Append to fragment
  11101. tmp = getAll( fragment.appendChild( elem ), "script" );
  11102. // Preserve script evaluation history
  11103. if ( attached ) {
  11104. setGlobalEval( tmp );
  11105. }
  11106. // Capture executables
  11107. if ( scripts ) {
  11108. j = 0;
  11109. while ( ( elem = tmp[ j++ ] ) ) {
  11110. if ( rscriptType.test( elem.type || "" ) ) {
  11111. scripts.push( elem );
  11112. }
  11113. }
  11114. }
  11115. }
  11116. return fragment;
  11117. }
  11118. ( function() {
  11119. var fragment = document.createDocumentFragment(),
  11120. div = fragment.appendChild( document.createElement( "div" ) ),
  11121. input = document.createElement( "input" );
  11122. // Support: Android 4.0 - 4.3 only
  11123. // Check state lost if the name is set (#11217)
  11124. // Support: Windows Web Apps (WWA)
  11125. // `name` and `type` must use .setAttribute for WWA (#14901)
  11126. input.setAttribute( "type", "radio" );
  11127. input.setAttribute( "checked", "checked" );
  11128. input.setAttribute( "name", "t" );
  11129. div.appendChild( input );
  11130. // Support: Android <=4.1 only
  11131. // Older WebKit doesn't clone checked state correctly in fragments
  11132. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11133. // Support: IE <=11 only
  11134. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11135. div.innerHTML = "<textarea>x</textarea>";
  11136. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11137. } )();
  11138. var
  11139. rkeyEvent = /^key/,
  11140. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11141. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11142. function returnTrue() {
  11143. return true;
  11144. }
  11145. function returnFalse() {
  11146. return false;
  11147. }
  11148. // Support: IE <=9 - 11+
  11149. // focus() and blur() are asynchronous, except when they are no-op.
  11150. // So expect focus to be synchronous when the element is already active,
  11151. // and blur to be synchronous when the element is not already active.
  11152. // (focus and blur are always synchronous in other supported browsers,
  11153. // this just defines when we can count on it).
  11154. function expectSync( elem, type ) {
  11155. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11156. }
  11157. // Support: IE <=9 only
  11158. // Accessing document.activeElement can throw unexpectedly
  11159. // https://bugs.jquery.com/ticket/13393
  11160. function safeActiveElement() {
  11161. try {
  11162. return document.activeElement;
  11163. } catch ( err ) { }
  11164. }
  11165. function on( elem, types, selector, data, fn, one ) {
  11166. var origFn, type;
  11167. // Types can be a map of types/handlers
  11168. if ( typeof types === "object" ) {
  11169. // ( types-Object, selector, data )
  11170. if ( typeof selector !== "string" ) {
  11171. // ( types-Object, data )
  11172. data = data || selector;
  11173. selector = undefined;
  11174. }
  11175. for ( type in types ) {
  11176. on( elem, type, selector, data, types[ type ], one );
  11177. }
  11178. return elem;
  11179. }
  11180. if ( data == null && fn == null ) {
  11181. // ( types, fn )
  11182. fn = selector;
  11183. data = selector = undefined;
  11184. } else if ( fn == null ) {
  11185. if ( typeof selector === "string" ) {
  11186. // ( types, selector, fn )
  11187. fn = data;
  11188. data = undefined;
  11189. } else {
  11190. // ( types, data, fn )
  11191. fn = data;
  11192. data = selector;
  11193. selector = undefined;
  11194. }
  11195. }
  11196. if ( fn === false ) {
  11197. fn = returnFalse;
  11198. } else if ( !fn ) {
  11199. return elem;
  11200. }
  11201. if ( one === 1 ) {
  11202. origFn = fn;
  11203. fn = function( event ) {
  11204. // Can use an empty set, since event contains the info
  11205. jQuery().off( event );
  11206. return origFn.apply( this, arguments );
  11207. };
  11208. // Use same guid so caller can remove using origFn
  11209. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11210. }
  11211. return elem.each( function() {
  11212. jQuery.event.add( this, types, fn, data, selector );
  11213. } );
  11214. }
  11215. /*
  11216. * Helper functions for managing events -- not part of the public interface.
  11217. * Props to Dean Edwards' addEvent library for many of the ideas.
  11218. */
  11219. jQuery.event = {
  11220. global: {},
  11221. add: function( elem, types, handler, data, selector ) {
  11222. var handleObjIn, eventHandle, tmp,
  11223. events, t, handleObj,
  11224. special, handlers, type, namespaces, origType,
  11225. elemData = dataPriv.get( elem );
  11226. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11227. if ( !elemData ) {
  11228. return;
  11229. }
  11230. // Caller can pass in an object of custom data in lieu of the handler
  11231. if ( handler.handler ) {
  11232. handleObjIn = handler;
  11233. handler = handleObjIn.handler;
  11234. selector = handleObjIn.selector;
  11235. }
  11236. // Ensure that invalid selectors throw exceptions at attach time
  11237. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11238. if ( selector ) {
  11239. jQuery.find.matchesSelector( documentElement, selector );
  11240. }
  11241. // Make sure that the handler has a unique ID, used to find/remove it later
  11242. if ( !handler.guid ) {
  11243. handler.guid = jQuery.guid++;
  11244. }
  11245. // Init the element's event structure and main handler, if this is the first
  11246. if ( !( events = elemData.events ) ) {
  11247. events = elemData.events = {};
  11248. }
  11249. if ( !( eventHandle = elemData.handle ) ) {
  11250. eventHandle = elemData.handle = function( e ) {
  11251. // Discard the second event of a jQuery.event.trigger() and
  11252. // when an event is called after a page has unloaded
  11253. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11254. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11255. };
  11256. }
  11257. // Handle multiple events separated by a space
  11258. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11259. t = types.length;
  11260. while ( t-- ) {
  11261. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11262. type = origType = tmp[ 1 ];
  11263. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11264. // There *must* be a type, no attaching namespace-only handlers
  11265. if ( !type ) {
  11266. continue;
  11267. }
  11268. // If event changes its type, use the special event handlers for the changed type
  11269. special = jQuery.event.special[ type ] || {};
  11270. // If selector defined, determine special event api type, otherwise given type
  11271. type = ( selector ? special.delegateType : special.bindType ) || type;
  11272. // Update special based on newly reset type
  11273. special = jQuery.event.special[ type ] || {};
  11274. // handleObj is passed to all event handlers
  11275. handleObj = jQuery.extend( {
  11276. type: type,
  11277. origType: origType,
  11278. data: data,
  11279. handler: handler,
  11280. guid: handler.guid,
  11281. selector: selector,
  11282. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11283. namespace: namespaces.join( "." )
  11284. }, handleObjIn );
  11285. // Init the event handler queue if we're the first
  11286. if ( !( handlers = events[ type ] ) ) {
  11287. handlers = events[ type ] = [];
  11288. handlers.delegateCount = 0;
  11289. // Only use addEventListener if the special events handler returns false
  11290. if ( !special.setup ||
  11291. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11292. if ( elem.addEventListener ) {
  11293. elem.addEventListener( type, eventHandle );
  11294. }
  11295. }
  11296. }
  11297. if ( special.add ) {
  11298. special.add.call( elem, handleObj );
  11299. if ( !handleObj.handler.guid ) {
  11300. handleObj.handler.guid = handler.guid;
  11301. }
  11302. }
  11303. // Add to the element's handler list, delegates in front
  11304. if ( selector ) {
  11305. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11306. } else {
  11307. handlers.push( handleObj );
  11308. }
  11309. // Keep track of which events have ever been used, for event optimization
  11310. jQuery.event.global[ type ] = true;
  11311. }
  11312. },
  11313. // Detach an event or set of events from an element
  11314. remove: function( elem, types, handler, selector, mappedTypes ) {
  11315. var j, origCount, tmp,
  11316. events, t, handleObj,
  11317. special, handlers, type, namespaces, origType,
  11318. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11319. if ( !elemData || !( events = elemData.events ) ) {
  11320. return;
  11321. }
  11322. // Once for each type.namespace in types; type may be omitted
  11323. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11324. t = types.length;
  11325. while ( t-- ) {
  11326. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11327. type = origType = tmp[ 1 ];
  11328. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11329. // Unbind all events (on this namespace, if provided) for the element
  11330. if ( !type ) {
  11331. for ( type in events ) {
  11332. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11333. }
  11334. continue;
  11335. }
  11336. special = jQuery.event.special[ type ] || {};
  11337. type = ( selector ? special.delegateType : special.bindType ) || type;
  11338. handlers = events[ type ] || [];
  11339. tmp = tmp[ 2 ] &&
  11340. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11341. // Remove matching events
  11342. origCount = j = handlers.length;
  11343. while ( j-- ) {
  11344. handleObj = handlers[ j ];
  11345. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11346. ( !handler || handler.guid === handleObj.guid ) &&
  11347. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11348. ( !selector || selector === handleObj.selector ||
  11349. selector === "**" && handleObj.selector ) ) {
  11350. handlers.splice( j, 1 );
  11351. if ( handleObj.selector ) {
  11352. handlers.delegateCount--;
  11353. }
  11354. if ( special.remove ) {
  11355. special.remove.call( elem, handleObj );
  11356. }
  11357. }
  11358. }
  11359. // Remove generic event handler if we removed something and no more handlers exist
  11360. // (avoids potential for endless recursion during removal of special event handlers)
  11361. if ( origCount && !handlers.length ) {
  11362. if ( !special.teardown ||
  11363. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11364. jQuery.removeEvent( elem, type, elemData.handle );
  11365. }
  11366. delete events[ type ];
  11367. }
  11368. }
  11369. // Remove data and the expando if it's no longer used
  11370. if ( jQuery.isEmptyObject( events ) ) {
  11371. dataPriv.remove( elem, "handle events" );
  11372. }
  11373. },
  11374. dispatch: function( nativeEvent ) {
  11375. // Make a writable jQuery.Event from the native event object
  11376. var event = jQuery.event.fix( nativeEvent );
  11377. var i, j, ret, matched, handleObj, handlerQueue,
  11378. args = new Array( arguments.length ),
  11379. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11380. special = jQuery.event.special[ event.type ] || {};
  11381. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11382. args[ 0 ] = event;
  11383. for ( i = 1; i < arguments.length; i++ ) {
  11384. args[ i ] = arguments[ i ];
  11385. }
  11386. event.delegateTarget = this;
  11387. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11388. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11389. return;
  11390. }
  11391. // Determine handlers
  11392. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11393. // Run delegates first; they may want to stop propagation beneath us
  11394. i = 0;
  11395. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11396. event.currentTarget = matched.elem;
  11397. j = 0;
  11398. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11399. !event.isImmediatePropagationStopped() ) {
  11400. // If the event is namespaced, then each handler is only invoked if it is
  11401. // specially universal or its namespaces are a superset of the event's.
  11402. if ( !event.rnamespace || handleObj.namespace === false ||
  11403. event.rnamespace.test( handleObj.namespace ) ) {
  11404. event.handleObj = handleObj;
  11405. event.data = handleObj.data;
  11406. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11407. handleObj.handler ).apply( matched.elem, args );
  11408. if ( ret !== undefined ) {
  11409. if ( ( event.result = ret ) === false ) {
  11410. event.preventDefault();
  11411. event.stopPropagation();
  11412. }
  11413. }
  11414. }
  11415. }
  11416. }
  11417. // Call the postDispatch hook for the mapped type
  11418. if ( special.postDispatch ) {
  11419. special.postDispatch.call( this, event );
  11420. }
  11421. return event.result;
  11422. },
  11423. handlers: function( event, handlers ) {
  11424. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11425. handlerQueue = [],
  11426. delegateCount = handlers.delegateCount,
  11427. cur = event.target;
  11428. // Find delegate handlers
  11429. if ( delegateCount &&
  11430. // Support: IE <=9
  11431. // Black-hole SVG <use> instance trees (trac-13180)
  11432. cur.nodeType &&
  11433. // Support: Firefox <=42
  11434. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11435. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11436. // Support: IE 11 only
  11437. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11438. !( event.type === "click" && event.button >= 1 ) ) {
  11439. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11440. // Don't check non-elements (#13208)
  11441. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11442. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11443. matchedHandlers = [];
  11444. matchedSelectors = {};
  11445. for ( i = 0; i < delegateCount; i++ ) {
  11446. handleObj = handlers[ i ];
  11447. // Don't conflict with Object.prototype properties (#13203)
  11448. sel = handleObj.selector + " ";
  11449. if ( matchedSelectors[ sel ] === undefined ) {
  11450. matchedSelectors[ sel ] = handleObj.needsContext ?
  11451. jQuery( sel, this ).index( cur ) > -1 :
  11452. jQuery.find( sel, this, null, [ cur ] ).length;
  11453. }
  11454. if ( matchedSelectors[ sel ] ) {
  11455. matchedHandlers.push( handleObj );
  11456. }
  11457. }
  11458. if ( matchedHandlers.length ) {
  11459. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11460. }
  11461. }
  11462. }
  11463. }
  11464. // Add the remaining (directly-bound) handlers
  11465. cur = this;
  11466. if ( delegateCount < handlers.length ) {
  11467. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11468. }
  11469. return handlerQueue;
  11470. },
  11471. addProp: function( name, hook ) {
  11472. Object.defineProperty( jQuery.Event.prototype, name, {
  11473. enumerable: true,
  11474. configurable: true,
  11475. get: isFunction( hook ) ?
  11476. function() {
  11477. if ( this.originalEvent ) {
  11478. return hook( this.originalEvent );
  11479. }
  11480. } :
  11481. function() {
  11482. if ( this.originalEvent ) {
  11483. return this.originalEvent[ name ];
  11484. }
  11485. },
  11486. set: function( value ) {
  11487. Object.defineProperty( this, name, {
  11488. enumerable: true,
  11489. configurable: true,
  11490. writable: true,
  11491. value: value
  11492. } );
  11493. }
  11494. } );
  11495. },
  11496. fix: function( originalEvent ) {
  11497. return originalEvent[ jQuery.expando ] ?
  11498. originalEvent :
  11499. new jQuery.Event( originalEvent );
  11500. },
  11501. special: {
  11502. load: {
  11503. // Prevent triggered image.load events from bubbling to window.load
  11504. noBubble: true
  11505. },
  11506. click: {
  11507. // Utilize native event to ensure correct state for checkable inputs
  11508. setup: function( data ) {
  11509. // For mutual compressibility with _default, replace `this` access with a local var.
  11510. // `|| data` is dead code meant only to preserve the variable through minification.
  11511. var el = this || data;
  11512. // Claim the first handler
  11513. if ( rcheckableType.test( el.type ) &&
  11514. el.click && nodeName( el, "input" ) ) {
  11515. // dataPriv.set( el, "click", ... )
  11516. leverageNative( el, "click", returnTrue );
  11517. }
  11518. // Return false to allow normal processing in the caller
  11519. return false;
  11520. },
  11521. trigger: function( data ) {
  11522. // For mutual compressibility with _default, replace `this` access with a local var.
  11523. // `|| data` is dead code meant only to preserve the variable through minification.
  11524. var el = this || data;
  11525. // Force setup before triggering a click
  11526. if ( rcheckableType.test( el.type ) &&
  11527. el.click && nodeName( el, "input" ) ) {
  11528. leverageNative( el, "click" );
  11529. }
  11530. // Return non-false to allow normal event-path propagation
  11531. return true;
  11532. },
  11533. // For cross-browser consistency, suppress native .click() on links
  11534. // Also prevent it if we're currently inside a leveraged native-event stack
  11535. _default: function( event ) {
  11536. var target = event.target;
  11537. return rcheckableType.test( target.type ) &&
  11538. target.click && nodeName( target, "input" ) &&
  11539. dataPriv.get( target, "click" ) ||
  11540. nodeName( target, "a" );
  11541. }
  11542. },
  11543. beforeunload: {
  11544. postDispatch: function( event ) {
  11545. // Support: Firefox 20+
  11546. // Firefox doesn't alert if the returnValue field is not set.
  11547. if ( event.result !== undefined && event.originalEvent ) {
  11548. event.originalEvent.returnValue = event.result;
  11549. }
  11550. }
  11551. }
  11552. }
  11553. };
  11554. // Ensure the presence of an event listener that handles manually-triggered
  11555. // synthetic events by interrupting progress until reinvoked in response to
  11556. // *native* events that it fires directly, ensuring that state changes have
  11557. // already occurred before other listeners are invoked.
  11558. function leverageNative( el, type, expectSync ) {
  11559. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11560. if ( !expectSync ) {
  11561. if ( dataPriv.get( el, type ) === undefined ) {
  11562. jQuery.event.add( el, type, returnTrue );
  11563. }
  11564. return;
  11565. }
  11566. // Register the controller as a special universal handler for all event namespaces
  11567. dataPriv.set( el, type, false );
  11568. jQuery.event.add( el, type, {
  11569. namespace: false,
  11570. handler: function( event ) {
  11571. var notAsync, result,
  11572. saved = dataPriv.get( this, type );
  11573. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11574. // Interrupt processing of the outer synthetic .trigger()ed event
  11575. // Saved data should be false in such cases, but might be a leftover capture object
  11576. // from an async native handler (gh-4350)
  11577. if ( !saved.length ) {
  11578. // Store arguments for use when handling the inner native event
  11579. // There will always be at least one argument (an event object), so this array
  11580. // will not be confused with a leftover capture object.
  11581. saved = slice.call( arguments );
  11582. dataPriv.set( this, type, saved );
  11583. // Trigger the native event and capture its result
  11584. // Support: IE <=9 - 11+
  11585. // focus() and blur() are asynchronous
  11586. notAsync = expectSync( this, type );
  11587. this[ type ]();
  11588. result = dataPriv.get( this, type );
  11589. if ( saved !== result || notAsync ) {
  11590. dataPriv.set( this, type, false );
  11591. } else {
  11592. result = {};
  11593. }
  11594. if ( saved !== result ) {
  11595. // Cancel the outer synthetic event
  11596. event.stopImmediatePropagation();
  11597. event.preventDefault();
  11598. return result.value;
  11599. }
  11600. // If this is an inner synthetic event for an event with a bubbling surrogate
  11601. // (focus or blur), assume that the surrogate already propagated from triggering the
  11602. // native event and prevent that from happening again here.
  11603. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11604. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11605. // less bad than duplication.
  11606. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11607. event.stopPropagation();
  11608. }
  11609. // If this is a native event triggered above, everything is now in order
  11610. // Fire an inner synthetic event with the original arguments
  11611. } else if ( saved.length ) {
  11612. // ...and capture the result
  11613. dataPriv.set( this, type, {
  11614. value: jQuery.event.trigger(
  11615. // Support: IE <=9 - 11+
  11616. // Extend with the prototype to reset the above stopImmediatePropagation()
  11617. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11618. saved.slice( 1 ),
  11619. this
  11620. )
  11621. } );
  11622. // Abort handling of the native event
  11623. event.stopImmediatePropagation();
  11624. }
  11625. }
  11626. } );
  11627. }
  11628. jQuery.removeEvent = function( elem, type, handle ) {
  11629. // This "if" is needed for plain objects
  11630. if ( elem.removeEventListener ) {
  11631. elem.removeEventListener( type, handle );
  11632. }
  11633. };
  11634. jQuery.Event = function( src, props ) {
  11635. // Allow instantiation without the 'new' keyword
  11636. if ( !( this instanceof jQuery.Event ) ) {
  11637. return new jQuery.Event( src, props );
  11638. }
  11639. // Event object
  11640. if ( src && src.type ) {
  11641. this.originalEvent = src;
  11642. this.type = src.type;
  11643. // Events bubbling up the document may have been marked as prevented
  11644. // by a handler lower down the tree; reflect the correct value.
  11645. this.isDefaultPrevented = src.defaultPrevented ||
  11646. src.defaultPrevented === undefined &&
  11647. // Support: Android <=2.3 only
  11648. src.returnValue === false ?
  11649. returnTrue :
  11650. returnFalse;
  11651. // Create target properties
  11652. // Support: Safari <=6 - 7 only
  11653. // Target should not be a text node (#504, #13143)
  11654. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11655. src.target.parentNode :
  11656. src.target;
  11657. this.currentTarget = src.currentTarget;
  11658. this.relatedTarget = src.relatedTarget;
  11659. // Event type
  11660. } else {
  11661. this.type = src;
  11662. }
  11663. // Put explicitly provided properties onto the event object
  11664. if ( props ) {
  11665. jQuery.extend( this, props );
  11666. }
  11667. // Create a timestamp if incoming event doesn't have one
  11668. this.timeStamp = src && src.timeStamp || Date.now();
  11669. // Mark it as fixed
  11670. this[ jQuery.expando ] = true;
  11671. };
  11672. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11673. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11674. jQuery.Event.prototype = {
  11675. constructor: jQuery.Event,
  11676. isDefaultPrevented: returnFalse,
  11677. isPropagationStopped: returnFalse,
  11678. isImmediatePropagationStopped: returnFalse,
  11679. isSimulated: false,
  11680. preventDefault: function() {
  11681. var e = this.originalEvent;
  11682. this.isDefaultPrevented = returnTrue;
  11683. if ( e && !this.isSimulated ) {
  11684. e.preventDefault();
  11685. }
  11686. },
  11687. stopPropagation: function() {
  11688. var e = this.originalEvent;
  11689. this.isPropagationStopped = returnTrue;
  11690. if ( e && !this.isSimulated ) {
  11691. e.stopPropagation();
  11692. }
  11693. },
  11694. stopImmediatePropagation: function() {
  11695. var e = this.originalEvent;
  11696. this.isImmediatePropagationStopped = returnTrue;
  11697. if ( e && !this.isSimulated ) {
  11698. e.stopImmediatePropagation();
  11699. }
  11700. this.stopPropagation();
  11701. }
  11702. };
  11703. // Includes all common event props including KeyEvent and MouseEvent specific props
  11704. jQuery.each( {
  11705. altKey: true,
  11706. bubbles: true,
  11707. cancelable: true,
  11708. changedTouches: true,
  11709. ctrlKey: true,
  11710. detail: true,
  11711. eventPhase: true,
  11712. metaKey: true,
  11713. pageX: true,
  11714. pageY: true,
  11715. shiftKey: true,
  11716. view: true,
  11717. "char": true,
  11718. code: true,
  11719. charCode: true,
  11720. key: true,
  11721. keyCode: true,
  11722. button: true,
  11723. buttons: true,
  11724. clientX: true,
  11725. clientY: true,
  11726. offsetX: true,
  11727. offsetY: true,
  11728. pointerId: true,
  11729. pointerType: true,
  11730. screenX: true,
  11731. screenY: true,
  11732. targetTouches: true,
  11733. toElement: true,
  11734. touches: true,
  11735. which: function( event ) {
  11736. var button = event.button;
  11737. // Add which for key events
  11738. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11739. return event.charCode != null ? event.charCode : event.keyCode;
  11740. }
  11741. // Add which for click: 1 === left; 2 === middle; 3 === right
  11742. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11743. if ( button & 1 ) {
  11744. return 1;
  11745. }
  11746. if ( button & 2 ) {
  11747. return 3;
  11748. }
  11749. if ( button & 4 ) {
  11750. return 2;
  11751. }
  11752. return 0;
  11753. }
  11754. return event.which;
  11755. }
  11756. }, jQuery.event.addProp );
  11757. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11758. jQuery.event.special[ type ] = {
  11759. // Utilize native event if possible so blur/focus sequence is correct
  11760. setup: function() {
  11761. // Claim the first handler
  11762. // dataPriv.set( this, "focus", ... )
  11763. // dataPriv.set( this, "blur", ... )
  11764. leverageNative( this, type, expectSync );
  11765. // Return false to allow normal processing in the caller
  11766. return false;
  11767. },
  11768. trigger: function() {
  11769. // Force setup before trigger
  11770. leverageNative( this, type );
  11771. // Return non-false to allow normal event-path propagation
  11772. return true;
  11773. },
  11774. delegateType: delegateType
  11775. };
  11776. } );
  11777. // Create mouseenter/leave events using mouseover/out and event-time checks
  11778. // so that event delegation works in jQuery.
  11779. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11780. //
  11781. // Support: Safari 7 only
  11782. // Safari sends mouseenter too often; see:
  11783. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11784. // for the description of the bug (it existed in older Chrome versions as well).
  11785. jQuery.each( {
  11786. mouseenter: "mouseover",
  11787. mouseleave: "mouseout",
  11788. pointerenter: "pointerover",
  11789. pointerleave: "pointerout"
  11790. }, function( orig, fix ) {
  11791. jQuery.event.special[ orig ] = {
  11792. delegateType: fix,
  11793. bindType: fix,
  11794. handle: function( event ) {
  11795. var ret,
  11796. target = this,
  11797. related = event.relatedTarget,
  11798. handleObj = event.handleObj;
  11799. // For mouseenter/leave call the handler if related is outside the target.
  11800. // NB: No relatedTarget if the mouse left/entered the browser window
  11801. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11802. event.type = handleObj.origType;
  11803. ret = handleObj.handler.apply( this, arguments );
  11804. event.type = fix;
  11805. }
  11806. return ret;
  11807. }
  11808. };
  11809. } );
  11810. jQuery.fn.extend( {
  11811. on: function( types, selector, data, fn ) {
  11812. return on( this, types, selector, data, fn );
  11813. },
  11814. one: function( types, selector, data, fn ) {
  11815. return on( this, types, selector, data, fn, 1 );
  11816. },
  11817. off: function( types, selector, fn ) {
  11818. var handleObj, type;
  11819. if ( types && types.preventDefault && types.handleObj ) {
  11820. // ( event ) dispatched jQuery.Event
  11821. handleObj = types.handleObj;
  11822. jQuery( types.delegateTarget ).off(
  11823. handleObj.namespace ?
  11824. handleObj.origType + "." + handleObj.namespace :
  11825. handleObj.origType,
  11826. handleObj.selector,
  11827. handleObj.handler
  11828. );
  11829. return this;
  11830. }
  11831. if ( typeof types === "object" ) {
  11832. // ( types-object [, selector] )
  11833. for ( type in types ) {
  11834. this.off( type, selector, types[ type ] );
  11835. }
  11836. return this;
  11837. }
  11838. if ( selector === false || typeof selector === "function" ) {
  11839. // ( types [, fn] )
  11840. fn = selector;
  11841. selector = undefined;
  11842. }
  11843. if ( fn === false ) {
  11844. fn = returnFalse;
  11845. }
  11846. return this.each( function() {
  11847. jQuery.event.remove( this, types, fn, selector );
  11848. } );
  11849. }
  11850. } );
  11851. var
  11852. /* eslint-disable max-len */
  11853. // See https://github.com/eslint/eslint/issues/3229
  11854. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11855. /* eslint-enable */
  11856. // Support: IE <=10 - 11, Edge 12 - 13 only
  11857. // In IE/Edge using regex groups here causes severe slowdowns.
  11858. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11859. rnoInnerhtml = /<script|<style|<link/i,
  11860. // checked="checked" or checked
  11861. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11862. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11863. // Prefer a tbody over its parent table for containing new rows
  11864. function manipulationTarget( elem, content ) {
  11865. if ( nodeName( elem, "table" ) &&
  11866. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11867. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11868. }
  11869. return elem;
  11870. }
  11871. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11872. function disableScript( elem ) {
  11873. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11874. return elem;
  11875. }
  11876. function restoreScript( elem ) {
  11877. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11878. elem.type = elem.type.slice( 5 );
  11879. } else {
  11880. elem.removeAttribute( "type" );
  11881. }
  11882. return elem;
  11883. }
  11884. function cloneCopyEvent( src, dest ) {
  11885. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11886. if ( dest.nodeType !== 1 ) {
  11887. return;
  11888. }
  11889. // 1. Copy private data: events, handlers, etc.
  11890. if ( dataPriv.hasData( src ) ) {
  11891. pdataOld = dataPriv.access( src );
  11892. pdataCur = dataPriv.set( dest, pdataOld );
  11893. events = pdataOld.events;
  11894. if ( events ) {
  11895. delete pdataCur.handle;
  11896. pdataCur.events = {};
  11897. for ( type in events ) {
  11898. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11899. jQuery.event.add( dest, type, events[ type ][ i ] );
  11900. }
  11901. }
  11902. }
  11903. }
  11904. // 2. Copy user data
  11905. if ( dataUser.hasData( src ) ) {
  11906. udataOld = dataUser.access( src );
  11907. udataCur = jQuery.extend( {}, udataOld );
  11908. dataUser.set( dest, udataCur );
  11909. }
  11910. }
  11911. // Fix IE bugs, see support tests
  11912. function fixInput( src, dest ) {
  11913. var nodeName = dest.nodeName.toLowerCase();
  11914. // Fails to persist the checked state of a cloned checkbox or radio button.
  11915. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11916. dest.checked = src.checked;
  11917. // Fails to return the selected option to the default selected state when cloning options
  11918. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11919. dest.defaultValue = src.defaultValue;
  11920. }
  11921. }
  11922. function domManip( collection, args, callback, ignored ) {
  11923. // Flatten any nested arrays
  11924. args = concat.apply( [], args );
  11925. var fragment, first, scripts, hasScripts, node, doc,
  11926. i = 0,
  11927. l = collection.length,
  11928. iNoClone = l - 1,
  11929. value = args[ 0 ],
  11930. valueIsFunction = isFunction( value );
  11931. // We can't cloneNode fragments that contain checked, in WebKit
  11932. if ( valueIsFunction ||
  11933. ( l > 1 && typeof value === "string" &&
  11934. !support.checkClone && rchecked.test( value ) ) ) {
  11935. return collection.each( function( index ) {
  11936. var self = collection.eq( index );
  11937. if ( valueIsFunction ) {
  11938. args[ 0 ] = value.call( this, index, self.html() );
  11939. }
  11940. domManip( self, args, callback, ignored );
  11941. } );
  11942. }
  11943. if ( l ) {
  11944. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11945. first = fragment.firstChild;
  11946. if ( fragment.childNodes.length === 1 ) {
  11947. fragment = first;
  11948. }
  11949. // Require either new content or an interest in ignored elements to invoke the callback
  11950. if ( first || ignored ) {
  11951. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11952. hasScripts = scripts.length;
  11953. // Use the original fragment for the last item
  11954. // instead of the first because it can end up
  11955. // being emptied incorrectly in certain situations (#8070).
  11956. for ( ; i < l; i++ ) {
  11957. node = fragment;
  11958. if ( i !== iNoClone ) {
  11959. node = jQuery.clone( node, true, true );
  11960. // Keep references to cloned scripts for later restoration
  11961. if ( hasScripts ) {
  11962. // Support: Android <=4.0 only, PhantomJS 1 only
  11963. // push.apply(_, arraylike) throws on ancient WebKit
  11964. jQuery.merge( scripts, getAll( node, "script" ) );
  11965. }
  11966. }
  11967. callback.call( collection[ i ], node, i );
  11968. }
  11969. if ( hasScripts ) {
  11970. doc = scripts[ scripts.length - 1 ].ownerDocument;
  11971. // Reenable scripts
  11972. jQuery.map( scripts, restoreScript );
  11973. // Evaluate executable scripts on first document insertion
  11974. for ( i = 0; i < hasScripts; i++ ) {
  11975. node = scripts[ i ];
  11976. if ( rscriptType.test( node.type || "" ) &&
  11977. !dataPriv.access( node, "globalEval" ) &&
  11978. jQuery.contains( doc, node ) ) {
  11979. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  11980. // Optional AJAX dependency, but won't run scripts if not present
  11981. if ( jQuery._evalUrl && !node.noModule ) {
  11982. jQuery._evalUrl( node.src, {
  11983. nonce: node.nonce || node.getAttribute( "nonce" )
  11984. } );
  11985. }
  11986. } else {
  11987. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  11988. }
  11989. }
  11990. }
  11991. }
  11992. }
  11993. }
  11994. return collection;
  11995. }
  11996. function remove( elem, selector, keepData ) {
  11997. var node,
  11998. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  11999. i = 0;
  12000. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12001. if ( !keepData && node.nodeType === 1 ) {
  12002. jQuery.cleanData( getAll( node ) );
  12003. }
  12004. if ( node.parentNode ) {
  12005. if ( keepData && isAttached( node ) ) {
  12006. setGlobalEval( getAll( node, "script" ) );
  12007. }
  12008. node.parentNode.removeChild( node );
  12009. }
  12010. }
  12011. return elem;
  12012. }
  12013. jQuery.extend( {
  12014. htmlPrefilter: function( html ) {
  12015. return html.replace( rxhtmlTag, "<$1></$2>" );
  12016. },
  12017. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12018. var i, l, srcElements, destElements,
  12019. clone = elem.cloneNode( true ),
  12020. inPage = isAttached( elem );
  12021. // Fix IE cloning issues
  12022. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12023. !jQuery.isXMLDoc( elem ) ) {
  12024. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12025. destElements = getAll( clone );
  12026. srcElements = getAll( elem );
  12027. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12028. fixInput( srcElements[ i ], destElements[ i ] );
  12029. }
  12030. }
  12031. // Copy the events from the original to the clone
  12032. if ( dataAndEvents ) {
  12033. if ( deepDataAndEvents ) {
  12034. srcElements = srcElements || getAll( elem );
  12035. destElements = destElements || getAll( clone );
  12036. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12037. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12038. }
  12039. } else {
  12040. cloneCopyEvent( elem, clone );
  12041. }
  12042. }
  12043. // Preserve script evaluation history
  12044. destElements = getAll( clone, "script" );
  12045. if ( destElements.length > 0 ) {
  12046. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12047. }
  12048. // Return the cloned set
  12049. return clone;
  12050. },
  12051. cleanData: function( elems ) {
  12052. var data, elem, type,
  12053. special = jQuery.event.special,
  12054. i = 0;
  12055. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12056. if ( acceptData( elem ) ) {
  12057. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12058. if ( data.events ) {
  12059. for ( type in data.events ) {
  12060. if ( special[ type ] ) {
  12061. jQuery.event.remove( elem, type );
  12062. // This is a shortcut to avoid jQuery.event.remove's overhead
  12063. } else {
  12064. jQuery.removeEvent( elem, type, data.handle );
  12065. }
  12066. }
  12067. }
  12068. // Support: Chrome <=35 - 45+
  12069. // Assign undefined instead of using delete, see Data#remove
  12070. elem[ dataPriv.expando ] = undefined;
  12071. }
  12072. if ( elem[ dataUser.expando ] ) {
  12073. // Support: Chrome <=35 - 45+
  12074. // Assign undefined instead of using delete, see Data#remove
  12075. elem[ dataUser.expando ] = undefined;
  12076. }
  12077. }
  12078. }
  12079. }
  12080. } );
  12081. jQuery.fn.extend( {
  12082. detach: function( selector ) {
  12083. return remove( this, selector, true );
  12084. },
  12085. remove: function( selector ) {
  12086. return remove( this, selector );
  12087. },
  12088. text: function( value ) {
  12089. return access( this, function( value ) {
  12090. return value === undefined ?
  12091. jQuery.text( this ) :
  12092. this.empty().each( function() {
  12093. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12094. this.textContent = value;
  12095. }
  12096. } );
  12097. }, null, value, arguments.length );
  12098. },
  12099. append: function() {
  12100. return domManip( this, arguments, function( elem ) {
  12101. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12102. var target = manipulationTarget( this, elem );
  12103. target.appendChild( elem );
  12104. }
  12105. } );
  12106. },
  12107. prepend: function() {
  12108. return domManip( this, arguments, function( elem ) {
  12109. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12110. var target = manipulationTarget( this, elem );
  12111. target.insertBefore( elem, target.firstChild );
  12112. }
  12113. } );
  12114. },
  12115. before: function() {
  12116. return domManip( this, arguments, function( elem ) {
  12117. if ( this.parentNode ) {
  12118. this.parentNode.insertBefore( elem, this );
  12119. }
  12120. } );
  12121. },
  12122. after: function() {
  12123. return domManip( this, arguments, function( elem ) {
  12124. if ( this.parentNode ) {
  12125. this.parentNode.insertBefore( elem, this.nextSibling );
  12126. }
  12127. } );
  12128. },
  12129. empty: function() {
  12130. var elem,
  12131. i = 0;
  12132. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12133. if ( elem.nodeType === 1 ) {
  12134. // Prevent memory leaks
  12135. jQuery.cleanData( getAll( elem, false ) );
  12136. // Remove any remaining nodes
  12137. elem.textContent = "";
  12138. }
  12139. }
  12140. return this;
  12141. },
  12142. clone: function( dataAndEvents, deepDataAndEvents ) {
  12143. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12144. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12145. return this.map( function() {
  12146. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12147. } );
  12148. },
  12149. html: function( value ) {
  12150. return access( this, function( value ) {
  12151. var elem = this[ 0 ] || {},
  12152. i = 0,
  12153. l = this.length;
  12154. if ( value === undefined && elem.nodeType === 1 ) {
  12155. return elem.innerHTML;
  12156. }
  12157. // See if we can take a shortcut and just use innerHTML
  12158. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12159. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12160. value = jQuery.htmlPrefilter( value );
  12161. try {
  12162. for ( ; i < l; i++ ) {
  12163. elem = this[ i ] || {};
  12164. // Remove element nodes and prevent memory leaks
  12165. if ( elem.nodeType === 1 ) {
  12166. jQuery.cleanData( getAll( elem, false ) );
  12167. elem.innerHTML = value;
  12168. }
  12169. }
  12170. elem = 0;
  12171. // If using innerHTML throws an exception, use the fallback method
  12172. } catch ( e ) {}
  12173. }
  12174. if ( elem ) {
  12175. this.empty().append( value );
  12176. }
  12177. }, null, value, arguments.length );
  12178. },
  12179. replaceWith: function() {
  12180. var ignored = [];
  12181. // Make the changes, replacing each non-ignored context element with the new content
  12182. return domManip( this, arguments, function( elem ) {
  12183. var parent = this.parentNode;
  12184. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12185. jQuery.cleanData( getAll( this ) );
  12186. if ( parent ) {
  12187. parent.replaceChild( elem, this );
  12188. }
  12189. }
  12190. // Force callback invocation
  12191. }, ignored );
  12192. }
  12193. } );
  12194. jQuery.each( {
  12195. appendTo: "append",
  12196. prependTo: "prepend",
  12197. insertBefore: "before",
  12198. insertAfter: "after",
  12199. replaceAll: "replaceWith"
  12200. }, function( name, original ) {
  12201. jQuery.fn[ name ] = function( selector ) {
  12202. var elems,
  12203. ret = [],
  12204. insert = jQuery( selector ),
  12205. last = insert.length - 1,
  12206. i = 0;
  12207. for ( ; i <= last; i++ ) {
  12208. elems = i === last ? this : this.clone( true );
  12209. jQuery( insert[ i ] )[ original ]( elems );
  12210. // Support: Android <=4.0 only, PhantomJS 1 only
  12211. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12212. push.apply( ret, elems.get() );
  12213. }
  12214. return this.pushStack( ret );
  12215. };
  12216. } );
  12217. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12218. var getStyles = function( elem ) {
  12219. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12220. // IE throws on elements created in popups
  12221. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12222. var view = elem.ownerDocument.defaultView;
  12223. if ( !view || !view.opener ) {
  12224. view = window;
  12225. }
  12226. return view.getComputedStyle( elem );
  12227. };
  12228. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12229. ( function() {
  12230. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12231. // so they're executed at the same time to save the second computation.
  12232. function computeStyleTests() {
  12233. // This is a singleton, we need to execute it only once
  12234. if ( !div ) {
  12235. return;
  12236. }
  12237. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12238. "margin-top:1px;padding:0;border:0";
  12239. div.style.cssText =
  12240. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12241. "margin:auto;border:1px;padding:1px;" +
  12242. "width:60%;top:1%";
  12243. documentElement.appendChild( container ).appendChild( div );
  12244. var divStyle = window.getComputedStyle( div );
  12245. pixelPositionVal = divStyle.top !== "1%";
  12246. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12247. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12248. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12249. // Some styles come back with percentage values, even though they shouldn't
  12250. div.style.right = "60%";
  12251. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12252. // Support: IE 9 - 11 only
  12253. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12254. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12255. // Support: IE 9 only
  12256. // Detect overflow:scroll screwiness (gh-3699)
  12257. // Support: Chrome <=64
  12258. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12259. div.style.position = "absolute";
  12260. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12261. documentElement.removeChild( container );
  12262. // Nullify the div so it wouldn't be stored in the memory and
  12263. // it will also be a sign that checks already performed
  12264. div = null;
  12265. }
  12266. function roundPixelMeasures( measure ) {
  12267. return Math.round( parseFloat( measure ) );
  12268. }
  12269. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12270. reliableMarginLeftVal,
  12271. container = document.createElement( "div" ),
  12272. div = document.createElement( "div" );
  12273. // Finish early in limited (non-browser) environments
  12274. if ( !div.style ) {
  12275. return;
  12276. }
  12277. // Support: IE <=9 - 11 only
  12278. // Style of cloned element affects source element cloned (#8908)
  12279. div.style.backgroundClip = "content-box";
  12280. div.cloneNode( true ).style.backgroundClip = "";
  12281. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12282. jQuery.extend( support, {
  12283. boxSizingReliable: function() {
  12284. computeStyleTests();
  12285. return boxSizingReliableVal;
  12286. },
  12287. pixelBoxStyles: function() {
  12288. computeStyleTests();
  12289. return pixelBoxStylesVal;
  12290. },
  12291. pixelPosition: function() {
  12292. computeStyleTests();
  12293. return pixelPositionVal;
  12294. },
  12295. reliableMarginLeft: function() {
  12296. computeStyleTests();
  12297. return reliableMarginLeftVal;
  12298. },
  12299. scrollboxSize: function() {
  12300. computeStyleTests();
  12301. return scrollboxSizeVal;
  12302. }
  12303. } );
  12304. } )();
  12305. function curCSS( elem, name, computed ) {
  12306. var width, minWidth, maxWidth, ret,
  12307. // Support: Firefox 51+
  12308. // Retrieving style before computed somehow
  12309. // fixes an issue with getting wrong values
  12310. // on detached elements
  12311. style = elem.style;
  12312. computed = computed || getStyles( elem );
  12313. // getPropertyValue is needed for:
  12314. // .css('filter') (IE 9 only, #12537)
  12315. // .css('--customProperty) (#3144)
  12316. if ( computed ) {
  12317. ret = computed.getPropertyValue( name ) || computed[ name ];
  12318. if ( ret === "" && !isAttached( elem ) ) {
  12319. ret = jQuery.style( elem, name );
  12320. }
  12321. // A tribute to the "awesome hack by Dean Edwards"
  12322. // Android Browser returns percentage for some values,
  12323. // but width seems to be reliably pixels.
  12324. // This is against the CSSOM draft spec:
  12325. // https://drafts.csswg.org/cssom/#resolved-values
  12326. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12327. // Remember the original values
  12328. width = style.width;
  12329. minWidth = style.minWidth;
  12330. maxWidth = style.maxWidth;
  12331. // Put in the new values to get a computed value out
  12332. style.minWidth = style.maxWidth = style.width = ret;
  12333. ret = computed.width;
  12334. // Revert the changed values
  12335. style.width = width;
  12336. style.minWidth = minWidth;
  12337. style.maxWidth = maxWidth;
  12338. }
  12339. }
  12340. return ret !== undefined ?
  12341. // Support: IE <=9 - 11 only
  12342. // IE returns zIndex value as an integer.
  12343. ret + "" :
  12344. ret;
  12345. }
  12346. function addGetHookIf( conditionFn, hookFn ) {
  12347. // Define the hook, we'll check on the first run if it's really needed.
  12348. return {
  12349. get: function() {
  12350. if ( conditionFn() ) {
  12351. // Hook not needed (or it's not possible to use it due
  12352. // to missing dependency), remove it.
  12353. delete this.get;
  12354. return;
  12355. }
  12356. // Hook needed; redefine it so that the support test is not executed again.
  12357. return ( this.get = hookFn ).apply( this, arguments );
  12358. }
  12359. };
  12360. }
  12361. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12362. emptyStyle = document.createElement( "div" ).style,
  12363. vendorProps = {};
  12364. // Return a vendor-prefixed property or undefined
  12365. function vendorPropName( name ) {
  12366. // Check for vendor prefixed names
  12367. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12368. i = cssPrefixes.length;
  12369. while ( i-- ) {
  12370. name = cssPrefixes[ i ] + capName;
  12371. if ( name in emptyStyle ) {
  12372. return name;
  12373. }
  12374. }
  12375. }
  12376. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12377. function finalPropName( name ) {
  12378. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12379. if ( final ) {
  12380. return final;
  12381. }
  12382. if ( name in emptyStyle ) {
  12383. return name;
  12384. }
  12385. return vendorProps[ name ] = vendorPropName( name ) || name;
  12386. }
  12387. var
  12388. // Swappable if display is none or starts with table
  12389. // except "table", "table-cell", or "table-caption"
  12390. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12391. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12392. rcustomProp = /^--/,
  12393. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12394. cssNormalTransform = {
  12395. letterSpacing: "0",
  12396. fontWeight: "400"
  12397. };
  12398. function setPositiveNumber( elem, value, subtract ) {
  12399. // Any relative (+/-) values have already been
  12400. // normalized at this point
  12401. var matches = rcssNum.exec( value );
  12402. return matches ?
  12403. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12404. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12405. value;
  12406. }
  12407. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12408. var i = dimension === "width" ? 1 : 0,
  12409. extra = 0,
  12410. delta = 0;
  12411. // Adjustment may not be necessary
  12412. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12413. return 0;
  12414. }
  12415. for ( ; i < 4; i += 2 ) {
  12416. // Both box models exclude margin
  12417. if ( box === "margin" ) {
  12418. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12419. }
  12420. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12421. if ( !isBorderBox ) {
  12422. // Add padding
  12423. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12424. // For "border" or "margin", add border
  12425. if ( box !== "padding" ) {
  12426. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12427. // But still keep track of it otherwise
  12428. } else {
  12429. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12430. }
  12431. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12432. // "padding" or "margin"
  12433. } else {
  12434. // For "content", subtract padding
  12435. if ( box === "content" ) {
  12436. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12437. }
  12438. // For "content" or "padding", subtract border
  12439. if ( box !== "margin" ) {
  12440. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12441. }
  12442. }
  12443. }
  12444. // Account for positive content-box scroll gutter when requested by providing computedVal
  12445. if ( !isBorderBox && computedVal >= 0 ) {
  12446. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12447. // Assuming integer scroll gutter, subtract the rest and round down
  12448. delta += Math.max( 0, Math.ceil(
  12449. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12450. computedVal -
  12451. delta -
  12452. extra -
  12453. 0.5
  12454. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12455. // Use an explicit zero to avoid NaN (gh-3964)
  12456. ) ) || 0;
  12457. }
  12458. return delta;
  12459. }
  12460. function getWidthOrHeight( elem, dimension, extra ) {
  12461. // Start with computed style
  12462. var styles = getStyles( elem ),
  12463. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12464. // Fake content-box until we know it's needed to know the true value.
  12465. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12466. isBorderBox = boxSizingNeeded &&
  12467. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12468. valueIsBorderBox = isBorderBox,
  12469. val = curCSS( elem, dimension, styles ),
  12470. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12471. // Support: Firefox <=54
  12472. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12473. if ( rnumnonpx.test( val ) ) {
  12474. if ( !extra ) {
  12475. return val;
  12476. }
  12477. val = "auto";
  12478. }
  12479. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12480. // This happens for inline elements with no explicit setting (gh-3571)
  12481. // Support: Android <=4.1 - 4.3 only
  12482. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12483. // Support: IE 9-11 only
  12484. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12485. // We use getClientRects() to check for hidden/disconnected.
  12486. // In those cases, the computed value can be trusted to be border-box
  12487. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12488. val === "auto" ||
  12489. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12490. elem.getClientRects().length ) {
  12491. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12492. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12493. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12494. // retrieved value as a content box dimension.
  12495. valueIsBorderBox = offsetProp in elem;
  12496. if ( valueIsBorderBox ) {
  12497. val = elem[ offsetProp ];
  12498. }
  12499. }
  12500. // Normalize "" and auto
  12501. val = parseFloat( val ) || 0;
  12502. // Adjust for the element's box model
  12503. return ( val +
  12504. boxModelAdjustment(
  12505. elem,
  12506. dimension,
  12507. extra || ( isBorderBox ? "border" : "content" ),
  12508. valueIsBorderBox,
  12509. styles,
  12510. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12511. val
  12512. )
  12513. ) + "px";
  12514. }
  12515. jQuery.extend( {
  12516. // Add in style property hooks for overriding the default
  12517. // behavior of getting and setting a style property
  12518. cssHooks: {
  12519. opacity: {
  12520. get: function( elem, computed ) {
  12521. if ( computed ) {
  12522. // We should always get a number back from opacity
  12523. var ret = curCSS( elem, "opacity" );
  12524. return ret === "" ? "1" : ret;
  12525. }
  12526. }
  12527. }
  12528. },
  12529. // Don't automatically add "px" to these possibly-unitless properties
  12530. cssNumber: {
  12531. "animationIterationCount": true,
  12532. "columnCount": true,
  12533. "fillOpacity": true,
  12534. "flexGrow": true,
  12535. "flexShrink": true,
  12536. "fontWeight": true,
  12537. "gridArea": true,
  12538. "gridColumn": true,
  12539. "gridColumnEnd": true,
  12540. "gridColumnStart": true,
  12541. "gridRow": true,
  12542. "gridRowEnd": true,
  12543. "gridRowStart": true,
  12544. "lineHeight": true,
  12545. "opacity": true,
  12546. "order": true,
  12547. "orphans": true,
  12548. "widows": true,
  12549. "zIndex": true,
  12550. "zoom": true
  12551. },
  12552. // Add in properties whose names you wish to fix before
  12553. // setting or getting the value
  12554. cssProps: {},
  12555. // Get and set the style property on a DOM Node
  12556. style: function( elem, name, value, extra ) {
  12557. // Don't set styles on text and comment nodes
  12558. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12559. return;
  12560. }
  12561. // Make sure that we're working with the right name
  12562. var ret, type, hooks,
  12563. origName = camelCase( name ),
  12564. isCustomProp = rcustomProp.test( name ),
  12565. style = elem.style;
  12566. // Make sure that we're working with the right name. We don't
  12567. // want to query the value if it is a CSS custom property
  12568. // since they are user-defined.
  12569. if ( !isCustomProp ) {
  12570. name = finalPropName( origName );
  12571. }
  12572. // Gets hook for the prefixed version, then unprefixed version
  12573. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12574. // Check if we're setting a value
  12575. if ( value !== undefined ) {
  12576. type = typeof value;
  12577. // Convert "+=" or "-=" to relative numbers (#7345)
  12578. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12579. value = adjustCSS( elem, name, ret );
  12580. // Fixes bug #9237
  12581. type = "number";
  12582. }
  12583. // Make sure that null and NaN values aren't set (#7116)
  12584. if ( value == null || value !== value ) {
  12585. return;
  12586. }
  12587. // If a number was passed in, add the unit (except for certain CSS properties)
  12588. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12589. // "px" to a few hardcoded values.
  12590. if ( type === "number" && !isCustomProp ) {
  12591. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12592. }
  12593. // background-* props affect original clone's values
  12594. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12595. style[ name ] = "inherit";
  12596. }
  12597. // If a hook was provided, use that value, otherwise just set the specified value
  12598. if ( !hooks || !( "set" in hooks ) ||
  12599. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12600. if ( isCustomProp ) {
  12601. style.setProperty( name, value );
  12602. } else {
  12603. style[ name ] = value;
  12604. }
  12605. }
  12606. } else {
  12607. // If a hook was provided get the non-computed value from there
  12608. if ( hooks && "get" in hooks &&
  12609. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12610. return ret;
  12611. }
  12612. // Otherwise just get the value from the style object
  12613. return style[ name ];
  12614. }
  12615. },
  12616. css: function( elem, name, extra, styles ) {
  12617. var val, num, hooks,
  12618. origName = camelCase( name ),
  12619. isCustomProp = rcustomProp.test( name );
  12620. // Make sure that we're working with the right name. We don't
  12621. // want to modify the value if it is a CSS custom property
  12622. // since they are user-defined.
  12623. if ( !isCustomProp ) {
  12624. name = finalPropName( origName );
  12625. }
  12626. // Try prefixed name followed by the unprefixed name
  12627. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12628. // If a hook was provided get the computed value from there
  12629. if ( hooks && "get" in hooks ) {
  12630. val = hooks.get( elem, true, extra );
  12631. }
  12632. // Otherwise, if a way to get the computed value exists, use that
  12633. if ( val === undefined ) {
  12634. val = curCSS( elem, name, styles );
  12635. }
  12636. // Convert "normal" to computed value
  12637. if ( val === "normal" && name in cssNormalTransform ) {
  12638. val = cssNormalTransform[ name ];
  12639. }
  12640. // Make numeric if forced or a qualifier was provided and val looks numeric
  12641. if ( extra === "" || extra ) {
  12642. num = parseFloat( val );
  12643. return extra === true || isFinite( num ) ? num || 0 : val;
  12644. }
  12645. return val;
  12646. }
  12647. } );
  12648. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12649. jQuery.cssHooks[ dimension ] = {
  12650. get: function( elem, computed, extra ) {
  12651. if ( computed ) {
  12652. // Certain elements can have dimension info if we invisibly show them
  12653. // but it must have a current display style that would benefit
  12654. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12655. // Support: Safari 8+
  12656. // Table columns in Safari have non-zero offsetWidth & zero
  12657. // getBoundingClientRect().width unless display is changed.
  12658. // Support: IE <=11 only
  12659. // Running getBoundingClientRect on a disconnected node
  12660. // in IE throws an error.
  12661. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12662. swap( elem, cssShow, function() {
  12663. return getWidthOrHeight( elem, dimension, extra );
  12664. } ) :
  12665. getWidthOrHeight( elem, dimension, extra );
  12666. }
  12667. },
  12668. set: function( elem, value, extra ) {
  12669. var matches,
  12670. styles = getStyles( elem ),
  12671. // Only read styles.position if the test has a chance to fail
  12672. // to avoid forcing a reflow.
  12673. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12674. styles.position === "absolute",
  12675. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12676. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12677. isBorderBox = boxSizingNeeded &&
  12678. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12679. subtract = extra ?
  12680. boxModelAdjustment(
  12681. elem,
  12682. dimension,
  12683. extra,
  12684. isBorderBox,
  12685. styles
  12686. ) :
  12687. 0;
  12688. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12689. // faking a content-box to get border and padding (gh-3699)
  12690. if ( isBorderBox && scrollboxSizeBuggy ) {
  12691. subtract -= Math.ceil(
  12692. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12693. parseFloat( styles[ dimension ] ) -
  12694. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12695. 0.5
  12696. );
  12697. }
  12698. // Convert to pixels if value adjustment is needed
  12699. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12700. ( matches[ 3 ] || "px" ) !== "px" ) {
  12701. elem.style[ dimension ] = value;
  12702. value = jQuery.css( elem, dimension );
  12703. }
  12704. return setPositiveNumber( elem, value, subtract );
  12705. }
  12706. };
  12707. } );
  12708. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12709. function( elem, computed ) {
  12710. if ( computed ) {
  12711. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12712. elem.getBoundingClientRect().left -
  12713. swap( elem, { marginLeft: 0 }, function() {
  12714. return elem.getBoundingClientRect().left;
  12715. } )
  12716. ) + "px";
  12717. }
  12718. }
  12719. );
  12720. // These hooks are used by animate to expand properties
  12721. jQuery.each( {
  12722. margin: "",
  12723. padding: "",
  12724. border: "Width"
  12725. }, function( prefix, suffix ) {
  12726. jQuery.cssHooks[ prefix + suffix ] = {
  12727. expand: function( value ) {
  12728. var i = 0,
  12729. expanded = {},
  12730. // Assumes a single number if not a string
  12731. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12732. for ( ; i < 4; i++ ) {
  12733. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12734. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12735. }
  12736. return expanded;
  12737. }
  12738. };
  12739. if ( prefix !== "margin" ) {
  12740. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12741. }
  12742. } );
  12743. jQuery.fn.extend( {
  12744. css: function( name, value ) {
  12745. return access( this, function( elem, name, value ) {
  12746. var styles, len,
  12747. map = {},
  12748. i = 0;
  12749. if ( Array.isArray( name ) ) {
  12750. styles = getStyles( elem );
  12751. len = name.length;
  12752. for ( ; i < len; i++ ) {
  12753. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12754. }
  12755. return map;
  12756. }
  12757. return value !== undefined ?
  12758. jQuery.style( elem, name, value ) :
  12759. jQuery.css( elem, name );
  12760. }, name, value, arguments.length > 1 );
  12761. }
  12762. } );
  12763. function Tween( elem, options, prop, end, easing ) {
  12764. return new Tween.prototype.init( elem, options, prop, end, easing );
  12765. }
  12766. jQuery.Tween = Tween;
  12767. Tween.prototype = {
  12768. constructor: Tween,
  12769. init: function( elem, options, prop, end, easing, unit ) {
  12770. this.elem = elem;
  12771. this.prop = prop;
  12772. this.easing = easing || jQuery.easing._default;
  12773. this.options = options;
  12774. this.start = this.now = this.cur();
  12775. this.end = end;
  12776. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12777. },
  12778. cur: function() {
  12779. var hooks = Tween.propHooks[ this.prop ];
  12780. return hooks && hooks.get ?
  12781. hooks.get( this ) :
  12782. Tween.propHooks._default.get( this );
  12783. },
  12784. run: function( percent ) {
  12785. var eased,
  12786. hooks = Tween.propHooks[ this.prop ];
  12787. if ( this.options.duration ) {
  12788. this.pos = eased = jQuery.easing[ this.easing ](
  12789. percent, this.options.duration * percent, 0, 1, this.options.duration
  12790. );
  12791. } else {
  12792. this.pos = eased = percent;
  12793. }
  12794. this.now = ( this.end - this.start ) * eased + this.start;
  12795. if ( this.options.step ) {
  12796. this.options.step.call( this.elem, this.now, this );
  12797. }
  12798. if ( hooks && hooks.set ) {
  12799. hooks.set( this );
  12800. } else {
  12801. Tween.propHooks._default.set( this );
  12802. }
  12803. return this;
  12804. }
  12805. };
  12806. Tween.prototype.init.prototype = Tween.prototype;
  12807. Tween.propHooks = {
  12808. _default: {
  12809. get: function( tween ) {
  12810. var result;
  12811. // Use a property on the element directly when it is not a DOM element,
  12812. // or when there is no matching style property that exists.
  12813. if ( tween.elem.nodeType !== 1 ||
  12814. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12815. return tween.elem[ tween.prop ];
  12816. }
  12817. // Passing an empty string as a 3rd parameter to .css will automatically
  12818. // attempt a parseFloat and fallback to a string if the parse fails.
  12819. // Simple values such as "10px" are parsed to Float;
  12820. // complex values such as "rotate(1rad)" are returned as-is.
  12821. result = jQuery.css( tween.elem, tween.prop, "" );
  12822. // Empty strings, null, undefined and "auto" are converted to 0.
  12823. return !result || result === "auto" ? 0 : result;
  12824. },
  12825. set: function( tween ) {
  12826. // Use step hook for back compat.
  12827. // Use cssHook if its there.
  12828. // Use .style if available and use plain properties where available.
  12829. if ( jQuery.fx.step[ tween.prop ] ) {
  12830. jQuery.fx.step[ tween.prop ]( tween );
  12831. } else if ( tween.elem.nodeType === 1 && (
  12832. jQuery.cssHooks[ tween.prop ] ||
  12833. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12834. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12835. } else {
  12836. tween.elem[ tween.prop ] = tween.now;
  12837. }
  12838. }
  12839. }
  12840. };
  12841. // Support: IE <=9 only
  12842. // Panic based approach to setting things on disconnected nodes
  12843. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12844. set: function( tween ) {
  12845. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12846. tween.elem[ tween.prop ] = tween.now;
  12847. }
  12848. }
  12849. };
  12850. jQuery.easing = {
  12851. linear: function( p ) {
  12852. return p;
  12853. },
  12854. swing: function( p ) {
  12855. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12856. },
  12857. _default: "swing"
  12858. };
  12859. jQuery.fx = Tween.prototype.init;
  12860. // Back compat <1.8 extension point
  12861. jQuery.fx.step = {};
  12862. var
  12863. fxNow, inProgress,
  12864. rfxtypes = /^(?:toggle|show|hide)$/,
  12865. rrun = /queueHooks$/;
  12866. function schedule() {
  12867. if ( inProgress ) {
  12868. if ( document.hidden === false && window.requestAnimationFrame ) {
  12869. window.requestAnimationFrame( schedule );
  12870. } else {
  12871. window.setTimeout( schedule, jQuery.fx.interval );
  12872. }
  12873. jQuery.fx.tick();
  12874. }
  12875. }
  12876. // Animations created synchronously will run synchronously
  12877. function createFxNow() {
  12878. window.setTimeout( function() {
  12879. fxNow = undefined;
  12880. } );
  12881. return ( fxNow = Date.now() );
  12882. }
  12883. // Generate parameters to create a standard animation
  12884. function genFx( type, includeWidth ) {
  12885. var which,
  12886. i = 0,
  12887. attrs = { height: type };
  12888. // If we include width, step value is 1 to do all cssExpand values,
  12889. // otherwise step value is 2 to skip over Left and Right
  12890. includeWidth = includeWidth ? 1 : 0;
  12891. for ( ; i < 4; i += 2 - includeWidth ) {
  12892. which = cssExpand[ i ];
  12893. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12894. }
  12895. if ( includeWidth ) {
  12896. attrs.opacity = attrs.width = type;
  12897. }
  12898. return attrs;
  12899. }
  12900. function createTween( value, prop, animation ) {
  12901. var tween,
  12902. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12903. index = 0,
  12904. length = collection.length;
  12905. for ( ; index < length; index++ ) {
  12906. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12907. // We're done with this property
  12908. return tween;
  12909. }
  12910. }
  12911. }
  12912. function defaultPrefilter( elem, props, opts ) {
  12913. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12914. isBox = "width" in props || "height" in props,
  12915. anim = this,
  12916. orig = {},
  12917. style = elem.style,
  12918. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12919. dataShow = dataPriv.get( elem, "fxshow" );
  12920. // Queue-skipping animations hijack the fx hooks
  12921. if ( !opts.queue ) {
  12922. hooks = jQuery._queueHooks( elem, "fx" );
  12923. if ( hooks.unqueued == null ) {
  12924. hooks.unqueued = 0;
  12925. oldfire = hooks.empty.fire;
  12926. hooks.empty.fire = function() {
  12927. if ( !hooks.unqueued ) {
  12928. oldfire();
  12929. }
  12930. };
  12931. }
  12932. hooks.unqueued++;
  12933. anim.always( function() {
  12934. // Ensure the complete handler is called before this completes
  12935. anim.always( function() {
  12936. hooks.unqueued--;
  12937. if ( !jQuery.queue( elem, "fx" ).length ) {
  12938. hooks.empty.fire();
  12939. }
  12940. } );
  12941. } );
  12942. }
  12943. // Detect show/hide animations
  12944. for ( prop in props ) {
  12945. value = props[ prop ];
  12946. if ( rfxtypes.test( value ) ) {
  12947. delete props[ prop ];
  12948. toggle = toggle || value === "toggle";
  12949. if ( value === ( hidden ? "hide" : "show" ) ) {
  12950. // Pretend to be hidden if this is a "show" and
  12951. // there is still data from a stopped show/hide
  12952. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12953. hidden = true;
  12954. // Ignore all other no-op show/hide data
  12955. } else {
  12956. continue;
  12957. }
  12958. }
  12959. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12960. }
  12961. }
  12962. // Bail out if this is a no-op like .hide().hide()
  12963. propTween = !jQuery.isEmptyObject( props );
  12964. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12965. return;
  12966. }
  12967. // Restrict "overflow" and "display" styles during box animations
  12968. if ( isBox && elem.nodeType === 1 ) {
  12969. // Support: IE <=9 - 11, Edge 12 - 15
  12970. // Record all 3 overflow attributes because IE does not infer the shorthand
  12971. // from identically-valued overflowX and overflowY and Edge just mirrors
  12972. // the overflowX value there.
  12973. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  12974. // Identify a display type, preferring old show/hide data over the CSS cascade
  12975. restoreDisplay = dataShow && dataShow.display;
  12976. if ( restoreDisplay == null ) {
  12977. restoreDisplay = dataPriv.get( elem, "display" );
  12978. }
  12979. display = jQuery.css( elem, "display" );
  12980. if ( display === "none" ) {
  12981. if ( restoreDisplay ) {
  12982. display = restoreDisplay;
  12983. } else {
  12984. // Get nonempty value(s) by temporarily forcing visibility
  12985. showHide( [ elem ], true );
  12986. restoreDisplay = elem.style.display || restoreDisplay;
  12987. display = jQuery.css( elem, "display" );
  12988. showHide( [ elem ] );
  12989. }
  12990. }
  12991. // Animate inline elements as inline-block
  12992. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  12993. if ( jQuery.css( elem, "float" ) === "none" ) {
  12994. // Restore the original display value at the end of pure show/hide animations
  12995. if ( !propTween ) {
  12996. anim.done( function() {
  12997. style.display = restoreDisplay;
  12998. } );
  12999. if ( restoreDisplay == null ) {
  13000. display = style.display;
  13001. restoreDisplay = display === "none" ? "" : display;
  13002. }
  13003. }
  13004. style.display = "inline-block";
  13005. }
  13006. }
  13007. }
  13008. if ( opts.overflow ) {
  13009. style.overflow = "hidden";
  13010. anim.always( function() {
  13011. style.overflow = opts.overflow[ 0 ];
  13012. style.overflowX = opts.overflow[ 1 ];
  13013. style.overflowY = opts.overflow[ 2 ];
  13014. } );
  13015. }
  13016. // Implement show/hide animations
  13017. propTween = false;
  13018. for ( prop in orig ) {
  13019. // General show/hide setup for this element animation
  13020. if ( !propTween ) {
  13021. if ( dataShow ) {
  13022. if ( "hidden" in dataShow ) {
  13023. hidden = dataShow.hidden;
  13024. }
  13025. } else {
  13026. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13027. }
  13028. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13029. if ( toggle ) {
  13030. dataShow.hidden = !hidden;
  13031. }
  13032. // Show elements before animating them
  13033. if ( hidden ) {
  13034. showHide( [ elem ], true );
  13035. }
  13036. /* eslint-disable no-loop-func */
  13037. anim.done( function() {
  13038. /* eslint-enable no-loop-func */
  13039. // The final step of a "hide" animation is actually hiding the element
  13040. if ( !hidden ) {
  13041. showHide( [ elem ] );
  13042. }
  13043. dataPriv.remove( elem, "fxshow" );
  13044. for ( prop in orig ) {
  13045. jQuery.style( elem, prop, orig[ prop ] );
  13046. }
  13047. } );
  13048. }
  13049. // Per-property setup
  13050. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13051. if ( !( prop in dataShow ) ) {
  13052. dataShow[ prop ] = propTween.start;
  13053. if ( hidden ) {
  13054. propTween.end = propTween.start;
  13055. propTween.start = 0;
  13056. }
  13057. }
  13058. }
  13059. }
  13060. function propFilter( props, specialEasing ) {
  13061. var index, name, easing, value, hooks;
  13062. // camelCase, specialEasing and expand cssHook pass
  13063. for ( index in props ) {
  13064. name = camelCase( index );
  13065. easing = specialEasing[ name ];
  13066. value = props[ index ];
  13067. if ( Array.isArray( value ) ) {
  13068. easing = value[ 1 ];
  13069. value = props[ index ] = value[ 0 ];
  13070. }
  13071. if ( index !== name ) {
  13072. props[ name ] = value;
  13073. delete props[ index ];
  13074. }
  13075. hooks = jQuery.cssHooks[ name ];
  13076. if ( hooks && "expand" in hooks ) {
  13077. value = hooks.expand( value );
  13078. delete props[ name ];
  13079. // Not quite $.extend, this won't overwrite existing keys.
  13080. // Reusing 'index' because we have the correct "name"
  13081. for ( index in value ) {
  13082. if ( !( index in props ) ) {
  13083. props[ index ] = value[ index ];
  13084. specialEasing[ index ] = easing;
  13085. }
  13086. }
  13087. } else {
  13088. specialEasing[ name ] = easing;
  13089. }
  13090. }
  13091. }
  13092. function Animation( elem, properties, options ) {
  13093. var result,
  13094. stopped,
  13095. index = 0,
  13096. length = Animation.prefilters.length,
  13097. deferred = jQuery.Deferred().always( function() {
  13098. // Don't match elem in the :animated selector
  13099. delete tick.elem;
  13100. } ),
  13101. tick = function() {
  13102. if ( stopped ) {
  13103. return false;
  13104. }
  13105. var currentTime = fxNow || createFxNow(),
  13106. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13107. // Support: Android 2.3 only
  13108. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13109. temp = remaining / animation.duration || 0,
  13110. percent = 1 - temp,
  13111. index = 0,
  13112. length = animation.tweens.length;
  13113. for ( ; index < length; index++ ) {
  13114. animation.tweens[ index ].run( percent );
  13115. }
  13116. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13117. // If there's more to do, yield
  13118. if ( percent < 1 && length ) {
  13119. return remaining;
  13120. }
  13121. // If this was an empty animation, synthesize a final progress notification
  13122. if ( !length ) {
  13123. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13124. }
  13125. // Resolve the animation and report its conclusion
  13126. deferred.resolveWith( elem, [ animation ] );
  13127. return false;
  13128. },
  13129. animation = deferred.promise( {
  13130. elem: elem,
  13131. props: jQuery.extend( {}, properties ),
  13132. opts: jQuery.extend( true, {
  13133. specialEasing: {},
  13134. easing: jQuery.easing._default
  13135. }, options ),
  13136. originalProperties: properties,
  13137. originalOptions: options,
  13138. startTime: fxNow || createFxNow(),
  13139. duration: options.duration,
  13140. tweens: [],
  13141. createTween: function( prop, end ) {
  13142. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13143. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13144. animation.tweens.push( tween );
  13145. return tween;
  13146. },
  13147. stop: function( gotoEnd ) {
  13148. var index = 0,
  13149. // If we are going to the end, we want to run all the tweens
  13150. // otherwise we skip this part
  13151. length = gotoEnd ? animation.tweens.length : 0;
  13152. if ( stopped ) {
  13153. return this;
  13154. }
  13155. stopped = true;
  13156. for ( ; index < length; index++ ) {
  13157. animation.tweens[ index ].run( 1 );
  13158. }
  13159. // Resolve when we played the last frame; otherwise, reject
  13160. if ( gotoEnd ) {
  13161. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13162. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13163. } else {
  13164. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13165. }
  13166. return this;
  13167. }
  13168. } ),
  13169. props = animation.props;
  13170. propFilter( props, animation.opts.specialEasing );
  13171. for ( ; index < length; index++ ) {
  13172. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13173. if ( result ) {
  13174. if ( isFunction( result.stop ) ) {
  13175. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13176. result.stop.bind( result );
  13177. }
  13178. return result;
  13179. }
  13180. }
  13181. jQuery.map( props, createTween, animation );
  13182. if ( isFunction( animation.opts.start ) ) {
  13183. animation.opts.start.call( elem, animation );
  13184. }
  13185. // Attach callbacks from options
  13186. animation
  13187. .progress( animation.opts.progress )
  13188. .done( animation.opts.done, animation.opts.complete )
  13189. .fail( animation.opts.fail )
  13190. .always( animation.opts.always );
  13191. jQuery.fx.timer(
  13192. jQuery.extend( tick, {
  13193. elem: elem,
  13194. anim: animation,
  13195. queue: animation.opts.queue
  13196. } )
  13197. );
  13198. return animation;
  13199. }
  13200. jQuery.Animation = jQuery.extend( Animation, {
  13201. tweeners: {
  13202. "*": [ function( prop, value ) {
  13203. var tween = this.createTween( prop, value );
  13204. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13205. return tween;
  13206. } ]
  13207. },
  13208. tweener: function( props, callback ) {
  13209. if ( isFunction( props ) ) {
  13210. callback = props;
  13211. props = [ "*" ];
  13212. } else {
  13213. props = props.match( rnothtmlwhite );
  13214. }
  13215. var prop,
  13216. index = 0,
  13217. length = props.length;
  13218. for ( ; index < length; index++ ) {
  13219. prop = props[ index ];
  13220. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13221. Animation.tweeners[ prop ].unshift( callback );
  13222. }
  13223. },
  13224. prefilters: [ defaultPrefilter ],
  13225. prefilter: function( callback, prepend ) {
  13226. if ( prepend ) {
  13227. Animation.prefilters.unshift( callback );
  13228. } else {
  13229. Animation.prefilters.push( callback );
  13230. }
  13231. }
  13232. } );
  13233. jQuery.speed = function( speed, easing, fn ) {
  13234. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13235. complete: fn || !fn && easing ||
  13236. isFunction( speed ) && speed,
  13237. duration: speed,
  13238. easing: fn && easing || easing && !isFunction( easing ) && easing
  13239. };
  13240. // Go to the end state if fx are off
  13241. if ( jQuery.fx.off ) {
  13242. opt.duration = 0;
  13243. } else {
  13244. if ( typeof opt.duration !== "number" ) {
  13245. if ( opt.duration in jQuery.fx.speeds ) {
  13246. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13247. } else {
  13248. opt.duration = jQuery.fx.speeds._default;
  13249. }
  13250. }
  13251. }
  13252. // Normalize opt.queue - true/undefined/null -> "fx"
  13253. if ( opt.queue == null || opt.queue === true ) {
  13254. opt.queue = "fx";
  13255. }
  13256. // Queueing
  13257. opt.old = opt.complete;
  13258. opt.complete = function() {
  13259. if ( isFunction( opt.old ) ) {
  13260. opt.old.call( this );
  13261. }
  13262. if ( opt.queue ) {
  13263. jQuery.dequeue( this, opt.queue );
  13264. }
  13265. };
  13266. return opt;
  13267. };
  13268. jQuery.fn.extend( {
  13269. fadeTo: function( speed, to, easing, callback ) {
  13270. // Show any hidden elements after setting opacity to 0
  13271. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13272. // Animate to the value specified
  13273. .end().animate( { opacity: to }, speed, easing, callback );
  13274. },
  13275. animate: function( prop, speed, easing, callback ) {
  13276. var empty = jQuery.isEmptyObject( prop ),
  13277. optall = jQuery.speed( speed, easing, callback ),
  13278. doAnimation = function() {
  13279. // Operate on a copy of prop so per-property easing won't be lost
  13280. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13281. // Empty animations, or finishing resolves immediately
  13282. if ( empty || dataPriv.get( this, "finish" ) ) {
  13283. anim.stop( true );
  13284. }
  13285. };
  13286. doAnimation.finish = doAnimation;
  13287. return empty || optall.queue === false ?
  13288. this.each( doAnimation ) :
  13289. this.queue( optall.queue, doAnimation );
  13290. },
  13291. stop: function( type, clearQueue, gotoEnd ) {
  13292. var stopQueue = function( hooks ) {
  13293. var stop = hooks.stop;
  13294. delete hooks.stop;
  13295. stop( gotoEnd );
  13296. };
  13297. if ( typeof type !== "string" ) {
  13298. gotoEnd = clearQueue;
  13299. clearQueue = type;
  13300. type = undefined;
  13301. }
  13302. if ( clearQueue && type !== false ) {
  13303. this.queue( type || "fx", [] );
  13304. }
  13305. return this.each( function() {
  13306. var dequeue = true,
  13307. index = type != null && type + "queueHooks",
  13308. timers = jQuery.timers,
  13309. data = dataPriv.get( this );
  13310. if ( index ) {
  13311. if ( data[ index ] && data[ index ].stop ) {
  13312. stopQueue( data[ index ] );
  13313. }
  13314. } else {
  13315. for ( index in data ) {
  13316. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13317. stopQueue( data[ index ] );
  13318. }
  13319. }
  13320. }
  13321. for ( index = timers.length; index--; ) {
  13322. if ( timers[ index ].elem === this &&
  13323. ( type == null || timers[ index ].queue === type ) ) {
  13324. timers[ index ].anim.stop( gotoEnd );
  13325. dequeue = false;
  13326. timers.splice( index, 1 );
  13327. }
  13328. }
  13329. // Start the next in the queue if the last step wasn't forced.
  13330. // Timers currently will call their complete callbacks, which
  13331. // will dequeue but only if they were gotoEnd.
  13332. if ( dequeue || !gotoEnd ) {
  13333. jQuery.dequeue( this, type );
  13334. }
  13335. } );
  13336. },
  13337. finish: function( type ) {
  13338. if ( type !== false ) {
  13339. type = type || "fx";
  13340. }
  13341. return this.each( function() {
  13342. var index,
  13343. data = dataPriv.get( this ),
  13344. queue = data[ type + "queue" ],
  13345. hooks = data[ type + "queueHooks" ],
  13346. timers = jQuery.timers,
  13347. length = queue ? queue.length : 0;
  13348. // Enable finishing flag on private data
  13349. data.finish = true;
  13350. // Empty the queue first
  13351. jQuery.queue( this, type, [] );
  13352. if ( hooks && hooks.stop ) {
  13353. hooks.stop.call( this, true );
  13354. }
  13355. // Look for any active animations, and finish them
  13356. for ( index = timers.length; index--; ) {
  13357. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13358. timers[ index ].anim.stop( true );
  13359. timers.splice( index, 1 );
  13360. }
  13361. }
  13362. // Look for any animations in the old queue and finish them
  13363. for ( index = 0; index < length; index++ ) {
  13364. if ( queue[ index ] && queue[ index ].finish ) {
  13365. queue[ index ].finish.call( this );
  13366. }
  13367. }
  13368. // Turn off finishing flag
  13369. delete data.finish;
  13370. } );
  13371. }
  13372. } );
  13373. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13374. var cssFn = jQuery.fn[ name ];
  13375. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13376. return speed == null || typeof speed === "boolean" ?
  13377. cssFn.apply( this, arguments ) :
  13378. this.animate( genFx( name, true ), speed, easing, callback );
  13379. };
  13380. } );
  13381. // Generate shortcuts for custom animations
  13382. jQuery.each( {
  13383. slideDown: genFx( "show" ),
  13384. slideUp: genFx( "hide" ),
  13385. slideToggle: genFx( "toggle" ),
  13386. fadeIn: { opacity: "show" },
  13387. fadeOut: { opacity: "hide" },
  13388. fadeToggle: { opacity: "toggle" }
  13389. }, function( name, props ) {
  13390. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13391. return this.animate( props, speed, easing, callback );
  13392. };
  13393. } );
  13394. jQuery.timers = [];
  13395. jQuery.fx.tick = function() {
  13396. var timer,
  13397. i = 0,
  13398. timers = jQuery.timers;
  13399. fxNow = Date.now();
  13400. for ( ; i < timers.length; i++ ) {
  13401. timer = timers[ i ];
  13402. // Run the timer and safely remove it when done (allowing for external removal)
  13403. if ( !timer() && timers[ i ] === timer ) {
  13404. timers.splice( i--, 1 );
  13405. }
  13406. }
  13407. if ( !timers.length ) {
  13408. jQuery.fx.stop();
  13409. }
  13410. fxNow = undefined;
  13411. };
  13412. jQuery.fx.timer = function( timer ) {
  13413. jQuery.timers.push( timer );
  13414. jQuery.fx.start();
  13415. };
  13416. jQuery.fx.interval = 13;
  13417. jQuery.fx.start = function() {
  13418. if ( inProgress ) {
  13419. return;
  13420. }
  13421. inProgress = true;
  13422. schedule();
  13423. };
  13424. jQuery.fx.stop = function() {
  13425. inProgress = null;
  13426. };
  13427. jQuery.fx.speeds = {
  13428. slow: 600,
  13429. fast: 200,
  13430. // Default speed
  13431. _default: 400
  13432. };
  13433. // Based off of the plugin by Clint Helfers, with permission.
  13434. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13435. jQuery.fn.delay = function( time, type ) {
  13436. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13437. type = type || "fx";
  13438. return this.queue( type, function( next, hooks ) {
  13439. var timeout = window.setTimeout( next, time );
  13440. hooks.stop = function() {
  13441. window.clearTimeout( timeout );
  13442. };
  13443. } );
  13444. };
  13445. ( function() {
  13446. var input = document.createElement( "input" ),
  13447. select = document.createElement( "select" ),
  13448. opt = select.appendChild( document.createElement( "option" ) );
  13449. input.type = "checkbox";
  13450. // Support: Android <=4.3 only
  13451. // Default value for a checkbox should be "on"
  13452. support.checkOn = input.value !== "";
  13453. // Support: IE <=11 only
  13454. // Must access selectedIndex to make default options select
  13455. support.optSelected = opt.selected;
  13456. // Support: IE <=11 only
  13457. // An input loses its value after becoming a radio
  13458. input = document.createElement( "input" );
  13459. input.value = "t";
  13460. input.type = "radio";
  13461. support.radioValue = input.value === "t";
  13462. } )();
  13463. var boolHook,
  13464. attrHandle = jQuery.expr.attrHandle;
  13465. jQuery.fn.extend( {
  13466. attr: function( name, value ) {
  13467. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13468. },
  13469. removeAttr: function( name ) {
  13470. return this.each( function() {
  13471. jQuery.removeAttr( this, name );
  13472. } );
  13473. }
  13474. } );
  13475. jQuery.extend( {
  13476. attr: function( elem, name, value ) {
  13477. var ret, hooks,
  13478. nType = elem.nodeType;
  13479. // Don't get/set attributes on text, comment and attribute nodes
  13480. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13481. return;
  13482. }
  13483. // Fallback to prop when attributes are not supported
  13484. if ( typeof elem.getAttribute === "undefined" ) {
  13485. return jQuery.prop( elem, name, value );
  13486. }
  13487. // Attribute hooks are determined by the lowercase version
  13488. // Grab necessary hook if one is defined
  13489. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13490. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13491. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13492. }
  13493. if ( value !== undefined ) {
  13494. if ( value === null ) {
  13495. jQuery.removeAttr( elem, name );
  13496. return;
  13497. }
  13498. if ( hooks && "set" in hooks &&
  13499. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13500. return ret;
  13501. }
  13502. elem.setAttribute( name, value + "" );
  13503. return value;
  13504. }
  13505. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13506. return ret;
  13507. }
  13508. ret = jQuery.find.attr( elem, name );
  13509. // Non-existent attributes return null, we normalize to undefined
  13510. return ret == null ? undefined : ret;
  13511. },
  13512. attrHooks: {
  13513. type: {
  13514. set: function( elem, value ) {
  13515. if ( !support.radioValue && value === "radio" &&
  13516. nodeName( elem, "input" ) ) {
  13517. var val = elem.value;
  13518. elem.setAttribute( "type", value );
  13519. if ( val ) {
  13520. elem.value = val;
  13521. }
  13522. return value;
  13523. }
  13524. }
  13525. }
  13526. },
  13527. removeAttr: function( elem, value ) {
  13528. var name,
  13529. i = 0,
  13530. // Attribute names can contain non-HTML whitespace characters
  13531. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13532. attrNames = value && value.match( rnothtmlwhite );
  13533. if ( attrNames && elem.nodeType === 1 ) {
  13534. while ( ( name = attrNames[ i++ ] ) ) {
  13535. elem.removeAttribute( name );
  13536. }
  13537. }
  13538. }
  13539. } );
  13540. // Hooks for boolean attributes
  13541. boolHook = {
  13542. set: function( elem, value, name ) {
  13543. if ( value === false ) {
  13544. // Remove boolean attributes when set to false
  13545. jQuery.removeAttr( elem, name );
  13546. } else {
  13547. elem.setAttribute( name, name );
  13548. }
  13549. return name;
  13550. }
  13551. };
  13552. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13553. var getter = attrHandle[ name ] || jQuery.find.attr;
  13554. attrHandle[ name ] = function( elem, name, isXML ) {
  13555. var ret, handle,
  13556. lowercaseName = name.toLowerCase();
  13557. if ( !isXML ) {
  13558. // Avoid an infinite loop by temporarily removing this function from the getter
  13559. handle = attrHandle[ lowercaseName ];
  13560. attrHandle[ lowercaseName ] = ret;
  13561. ret = getter( elem, name, isXML ) != null ?
  13562. lowercaseName :
  13563. null;
  13564. attrHandle[ lowercaseName ] = handle;
  13565. }
  13566. return ret;
  13567. };
  13568. } );
  13569. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13570. rclickable = /^(?:a|area)$/i;
  13571. jQuery.fn.extend( {
  13572. prop: function( name, value ) {
  13573. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13574. },
  13575. removeProp: function( name ) {
  13576. return this.each( function() {
  13577. delete this[ jQuery.propFix[ name ] || name ];
  13578. } );
  13579. }
  13580. } );
  13581. jQuery.extend( {
  13582. prop: function( elem, name, value ) {
  13583. var ret, hooks,
  13584. nType = elem.nodeType;
  13585. // Don't get/set properties on text, comment and attribute nodes
  13586. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13587. return;
  13588. }
  13589. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13590. // Fix name and attach hooks
  13591. name = jQuery.propFix[ name ] || name;
  13592. hooks = jQuery.propHooks[ name ];
  13593. }
  13594. if ( value !== undefined ) {
  13595. if ( hooks && "set" in hooks &&
  13596. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13597. return ret;
  13598. }
  13599. return ( elem[ name ] = value );
  13600. }
  13601. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13602. return ret;
  13603. }
  13604. return elem[ name ];
  13605. },
  13606. propHooks: {
  13607. tabIndex: {
  13608. get: function( elem ) {
  13609. // Support: IE <=9 - 11 only
  13610. // elem.tabIndex doesn't always return the
  13611. // correct value when it hasn't been explicitly set
  13612. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13613. // Use proper attribute retrieval(#12072)
  13614. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13615. if ( tabindex ) {
  13616. return parseInt( tabindex, 10 );
  13617. }
  13618. if (
  13619. rfocusable.test( elem.nodeName ) ||
  13620. rclickable.test( elem.nodeName ) &&
  13621. elem.href
  13622. ) {
  13623. return 0;
  13624. }
  13625. return -1;
  13626. }
  13627. }
  13628. },
  13629. propFix: {
  13630. "for": "htmlFor",
  13631. "class": "className"
  13632. }
  13633. } );
  13634. // Support: IE <=11 only
  13635. // Accessing the selectedIndex property
  13636. // forces the browser to respect setting selected
  13637. // on the option
  13638. // The getter ensures a default option is selected
  13639. // when in an optgroup
  13640. // eslint rule "no-unused-expressions" is disabled for this code
  13641. // since it considers such accessions noop
  13642. if ( !support.optSelected ) {
  13643. jQuery.propHooks.selected = {
  13644. get: function( elem ) {
  13645. /* eslint no-unused-expressions: "off" */
  13646. var parent = elem.parentNode;
  13647. if ( parent && parent.parentNode ) {
  13648. parent.parentNode.selectedIndex;
  13649. }
  13650. return null;
  13651. },
  13652. set: function( elem ) {
  13653. /* eslint no-unused-expressions: "off" */
  13654. var parent = elem.parentNode;
  13655. if ( parent ) {
  13656. parent.selectedIndex;
  13657. if ( parent.parentNode ) {
  13658. parent.parentNode.selectedIndex;
  13659. }
  13660. }
  13661. }
  13662. };
  13663. }
  13664. jQuery.each( [
  13665. "tabIndex",
  13666. "readOnly",
  13667. "maxLength",
  13668. "cellSpacing",
  13669. "cellPadding",
  13670. "rowSpan",
  13671. "colSpan",
  13672. "useMap",
  13673. "frameBorder",
  13674. "contentEditable"
  13675. ], function() {
  13676. jQuery.propFix[ this.toLowerCase() ] = this;
  13677. } );
  13678. // Strip and collapse whitespace according to HTML spec
  13679. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13680. function stripAndCollapse( value ) {
  13681. var tokens = value.match( rnothtmlwhite ) || [];
  13682. return tokens.join( " " );
  13683. }
  13684. function getClass( elem ) {
  13685. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13686. }
  13687. function classesToArray( value ) {
  13688. if ( Array.isArray( value ) ) {
  13689. return value;
  13690. }
  13691. if ( typeof value === "string" ) {
  13692. return value.match( rnothtmlwhite ) || [];
  13693. }
  13694. return [];
  13695. }
  13696. jQuery.fn.extend( {
  13697. addClass: function( value ) {
  13698. var classes, elem, cur, curValue, clazz, j, finalValue,
  13699. i = 0;
  13700. if ( isFunction( value ) ) {
  13701. return this.each( function( j ) {
  13702. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13703. } );
  13704. }
  13705. classes = classesToArray( value );
  13706. if ( classes.length ) {
  13707. while ( ( elem = this[ i++ ] ) ) {
  13708. curValue = getClass( elem );
  13709. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13710. if ( cur ) {
  13711. j = 0;
  13712. while ( ( clazz = classes[ j++ ] ) ) {
  13713. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13714. cur += clazz + " ";
  13715. }
  13716. }
  13717. // Only assign if different to avoid unneeded rendering.
  13718. finalValue = stripAndCollapse( cur );
  13719. if ( curValue !== finalValue ) {
  13720. elem.setAttribute( "class", finalValue );
  13721. }
  13722. }
  13723. }
  13724. }
  13725. return this;
  13726. },
  13727. removeClass: function( value ) {
  13728. var classes, elem, cur, curValue, clazz, j, finalValue,
  13729. i = 0;
  13730. if ( isFunction( value ) ) {
  13731. return this.each( function( j ) {
  13732. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13733. } );
  13734. }
  13735. if ( !arguments.length ) {
  13736. return this.attr( "class", "" );
  13737. }
  13738. classes = classesToArray( value );
  13739. if ( classes.length ) {
  13740. while ( ( elem = this[ i++ ] ) ) {
  13741. curValue = getClass( elem );
  13742. // This expression is here for better compressibility (see addClass)
  13743. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13744. if ( cur ) {
  13745. j = 0;
  13746. while ( ( clazz = classes[ j++ ] ) ) {
  13747. // Remove *all* instances
  13748. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13749. cur = cur.replace( " " + clazz + " ", " " );
  13750. }
  13751. }
  13752. // Only assign if different to avoid unneeded rendering.
  13753. finalValue = stripAndCollapse( cur );
  13754. if ( curValue !== finalValue ) {
  13755. elem.setAttribute( "class", finalValue );
  13756. }
  13757. }
  13758. }
  13759. }
  13760. return this;
  13761. },
  13762. toggleClass: function( value, stateVal ) {
  13763. var type = typeof value,
  13764. isValidValue = type === "string" || Array.isArray( value );
  13765. if ( typeof stateVal === "boolean" && isValidValue ) {
  13766. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13767. }
  13768. if ( isFunction( value ) ) {
  13769. return this.each( function( i ) {
  13770. jQuery( this ).toggleClass(
  13771. value.call( this, i, getClass( this ), stateVal ),
  13772. stateVal
  13773. );
  13774. } );
  13775. }
  13776. return this.each( function() {
  13777. var className, i, self, classNames;
  13778. if ( isValidValue ) {
  13779. // Toggle individual class names
  13780. i = 0;
  13781. self = jQuery( this );
  13782. classNames = classesToArray( value );
  13783. while ( ( className = classNames[ i++ ] ) ) {
  13784. // Check each className given, space separated list
  13785. if ( self.hasClass( className ) ) {
  13786. self.removeClass( className );
  13787. } else {
  13788. self.addClass( className );
  13789. }
  13790. }
  13791. // Toggle whole class name
  13792. } else if ( value === undefined || type === "boolean" ) {
  13793. className = getClass( this );
  13794. if ( className ) {
  13795. // Store className if set
  13796. dataPriv.set( this, "__className__", className );
  13797. }
  13798. // If the element has a class name or if we're passed `false`,
  13799. // then remove the whole classname (if there was one, the above saved it).
  13800. // Otherwise bring back whatever was previously saved (if anything),
  13801. // falling back to the empty string if nothing was stored.
  13802. if ( this.setAttribute ) {
  13803. this.setAttribute( "class",
  13804. className || value === false ?
  13805. "" :
  13806. dataPriv.get( this, "__className__" ) || ""
  13807. );
  13808. }
  13809. }
  13810. } );
  13811. },
  13812. hasClass: function( selector ) {
  13813. var className, elem,
  13814. i = 0;
  13815. className = " " + selector + " ";
  13816. while ( ( elem = this[ i++ ] ) ) {
  13817. if ( elem.nodeType === 1 &&
  13818. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13819. return true;
  13820. }
  13821. }
  13822. return false;
  13823. }
  13824. } );
  13825. var rreturn = /\r/g;
  13826. jQuery.fn.extend( {
  13827. val: function( value ) {
  13828. var hooks, ret, valueIsFunction,
  13829. elem = this[ 0 ];
  13830. if ( !arguments.length ) {
  13831. if ( elem ) {
  13832. hooks = jQuery.valHooks[ elem.type ] ||
  13833. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13834. if ( hooks &&
  13835. "get" in hooks &&
  13836. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13837. ) {
  13838. return ret;
  13839. }
  13840. ret = elem.value;
  13841. // Handle most common string cases
  13842. if ( typeof ret === "string" ) {
  13843. return ret.replace( rreturn, "" );
  13844. }
  13845. // Handle cases where value is null/undef or number
  13846. return ret == null ? "" : ret;
  13847. }
  13848. return;
  13849. }
  13850. valueIsFunction = isFunction( value );
  13851. return this.each( function( i ) {
  13852. var val;
  13853. if ( this.nodeType !== 1 ) {
  13854. return;
  13855. }
  13856. if ( valueIsFunction ) {
  13857. val = value.call( this, i, jQuery( this ).val() );
  13858. } else {
  13859. val = value;
  13860. }
  13861. // Treat null/undefined as ""; convert numbers to string
  13862. if ( val == null ) {
  13863. val = "";
  13864. } else if ( typeof val === "number" ) {
  13865. val += "";
  13866. } else if ( Array.isArray( val ) ) {
  13867. val = jQuery.map( val, function( value ) {
  13868. return value == null ? "" : value + "";
  13869. } );
  13870. }
  13871. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13872. // If set returns undefined, fall back to normal setting
  13873. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13874. this.value = val;
  13875. }
  13876. } );
  13877. }
  13878. } );
  13879. jQuery.extend( {
  13880. valHooks: {
  13881. option: {
  13882. get: function( elem ) {
  13883. var val = jQuery.find.attr( elem, "value" );
  13884. return val != null ?
  13885. val :
  13886. // Support: IE <=10 - 11 only
  13887. // option.text throws exceptions (#14686, #14858)
  13888. // Strip and collapse whitespace
  13889. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13890. stripAndCollapse( jQuery.text( elem ) );
  13891. }
  13892. },
  13893. select: {
  13894. get: function( elem ) {
  13895. var value, option, i,
  13896. options = elem.options,
  13897. index = elem.selectedIndex,
  13898. one = elem.type === "select-one",
  13899. values = one ? null : [],
  13900. max = one ? index + 1 : options.length;
  13901. if ( index < 0 ) {
  13902. i = max;
  13903. } else {
  13904. i = one ? index : 0;
  13905. }
  13906. // Loop through all the selected options
  13907. for ( ; i < max; i++ ) {
  13908. option = options[ i ];
  13909. // Support: IE <=9 only
  13910. // IE8-9 doesn't update selected after form reset (#2551)
  13911. if ( ( option.selected || i === index ) &&
  13912. // Don't return options that are disabled or in a disabled optgroup
  13913. !option.disabled &&
  13914. ( !option.parentNode.disabled ||
  13915. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13916. // Get the specific value for the option
  13917. value = jQuery( option ).val();
  13918. // We don't need an array for one selects
  13919. if ( one ) {
  13920. return value;
  13921. }
  13922. // Multi-Selects return an array
  13923. values.push( value );
  13924. }
  13925. }
  13926. return values;
  13927. },
  13928. set: function( elem, value ) {
  13929. var optionSet, option,
  13930. options = elem.options,
  13931. values = jQuery.makeArray( value ),
  13932. i = options.length;
  13933. while ( i-- ) {
  13934. option = options[ i ];
  13935. /* eslint-disable no-cond-assign */
  13936. if ( option.selected =
  13937. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13938. ) {
  13939. optionSet = true;
  13940. }
  13941. /* eslint-enable no-cond-assign */
  13942. }
  13943. // Force browsers to behave consistently when non-matching value is set
  13944. if ( !optionSet ) {
  13945. elem.selectedIndex = -1;
  13946. }
  13947. return values;
  13948. }
  13949. }
  13950. }
  13951. } );
  13952. // Radios and checkboxes getter/setter
  13953. jQuery.each( [ "radio", "checkbox" ], function() {
  13954. jQuery.valHooks[ this ] = {
  13955. set: function( elem, value ) {
  13956. if ( Array.isArray( value ) ) {
  13957. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13958. }
  13959. }
  13960. };
  13961. if ( !support.checkOn ) {
  13962. jQuery.valHooks[ this ].get = function( elem ) {
  13963. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13964. };
  13965. }
  13966. } );
  13967. // Return jQuery for attributes-only inclusion
  13968. support.focusin = "onfocusin" in window;
  13969. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  13970. stopPropagationCallback = function( e ) {
  13971. e.stopPropagation();
  13972. };
  13973. jQuery.extend( jQuery.event, {
  13974. trigger: function( event, data, elem, onlyHandlers ) {
  13975. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  13976. eventPath = [ elem || document ],
  13977. type = hasOwn.call( event, "type" ) ? event.type : event,
  13978. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  13979. cur = lastElement = tmp = elem = elem || document;
  13980. // Don't do events on text and comment nodes
  13981. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  13982. return;
  13983. }
  13984. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  13985. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  13986. return;
  13987. }
  13988. if ( type.indexOf( "." ) > -1 ) {
  13989. // Namespaced trigger; create a regexp to match event type in handle()
  13990. namespaces = type.split( "." );
  13991. type = namespaces.shift();
  13992. namespaces.sort();
  13993. }
  13994. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  13995. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  13996. event = event[ jQuery.expando ] ?
  13997. event :
  13998. new jQuery.Event( type, typeof event === "object" && event );
  13999. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14000. event.isTrigger = onlyHandlers ? 2 : 3;
  14001. event.namespace = namespaces.join( "." );
  14002. event.rnamespace = event.namespace ?
  14003. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14004. null;
  14005. // Clean up the event in case it is being reused
  14006. event.result = undefined;
  14007. if ( !event.target ) {
  14008. event.target = elem;
  14009. }
  14010. // Clone any incoming data and prepend the event, creating the handler arg list
  14011. data = data == null ?
  14012. [ event ] :
  14013. jQuery.makeArray( data, [ event ] );
  14014. // Allow special events to draw outside the lines
  14015. special = jQuery.event.special[ type ] || {};
  14016. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14017. return;
  14018. }
  14019. // Determine event propagation path in advance, per W3C events spec (#9951)
  14020. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14021. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14022. bubbleType = special.delegateType || type;
  14023. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14024. cur = cur.parentNode;
  14025. }
  14026. for ( ; cur; cur = cur.parentNode ) {
  14027. eventPath.push( cur );
  14028. tmp = cur;
  14029. }
  14030. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14031. if ( tmp === ( elem.ownerDocument || document ) ) {
  14032. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14033. }
  14034. }
  14035. // Fire handlers on the event path
  14036. i = 0;
  14037. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14038. lastElement = cur;
  14039. event.type = i > 1 ?
  14040. bubbleType :
  14041. special.bindType || type;
  14042. // jQuery handler
  14043. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14044. dataPriv.get( cur, "handle" );
  14045. if ( handle ) {
  14046. handle.apply( cur, data );
  14047. }
  14048. // Native handler
  14049. handle = ontype && cur[ ontype ];
  14050. if ( handle && handle.apply && acceptData( cur ) ) {
  14051. event.result = handle.apply( cur, data );
  14052. if ( event.result === false ) {
  14053. event.preventDefault();
  14054. }
  14055. }
  14056. }
  14057. event.type = type;
  14058. // If nobody prevented the default action, do it now
  14059. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14060. if ( ( !special._default ||
  14061. special._default.apply( eventPath.pop(), data ) === false ) &&
  14062. acceptData( elem ) ) {
  14063. // Call a native DOM method on the target with the same name as the event.
  14064. // Don't do default actions on window, that's where global variables be (#6170)
  14065. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14066. // Don't re-trigger an onFOO event when we call its FOO() method
  14067. tmp = elem[ ontype ];
  14068. if ( tmp ) {
  14069. elem[ ontype ] = null;
  14070. }
  14071. // Prevent re-triggering of the same event, since we already bubbled it above
  14072. jQuery.event.triggered = type;
  14073. if ( event.isPropagationStopped() ) {
  14074. lastElement.addEventListener( type, stopPropagationCallback );
  14075. }
  14076. elem[ type ]();
  14077. if ( event.isPropagationStopped() ) {
  14078. lastElement.removeEventListener( type, stopPropagationCallback );
  14079. }
  14080. jQuery.event.triggered = undefined;
  14081. if ( tmp ) {
  14082. elem[ ontype ] = tmp;
  14083. }
  14084. }
  14085. }
  14086. }
  14087. return event.result;
  14088. },
  14089. // Piggyback on a donor event to simulate a different one
  14090. // Used only for `focus(in | out)` events
  14091. simulate: function( type, elem, event ) {
  14092. var e = jQuery.extend(
  14093. new jQuery.Event(),
  14094. event,
  14095. {
  14096. type: type,
  14097. isSimulated: true
  14098. }
  14099. );
  14100. jQuery.event.trigger( e, null, elem );
  14101. }
  14102. } );
  14103. jQuery.fn.extend( {
  14104. trigger: function( type, data ) {
  14105. return this.each( function() {
  14106. jQuery.event.trigger( type, data, this );
  14107. } );
  14108. },
  14109. triggerHandler: function( type, data ) {
  14110. var elem = this[ 0 ];
  14111. if ( elem ) {
  14112. return jQuery.event.trigger( type, data, elem, true );
  14113. }
  14114. }
  14115. } );
  14116. // Support: Firefox <=44
  14117. // Firefox doesn't have focus(in | out) events
  14118. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14119. //
  14120. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14121. // focus(in | out) events fire after focus & blur events,
  14122. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14123. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14124. if ( !support.focusin ) {
  14125. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14126. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14127. var handler = function( event ) {
  14128. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14129. };
  14130. jQuery.event.special[ fix ] = {
  14131. setup: function() {
  14132. var doc = this.ownerDocument || this,
  14133. attaches = dataPriv.access( doc, fix );
  14134. if ( !attaches ) {
  14135. doc.addEventListener( orig, handler, true );
  14136. }
  14137. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14138. },
  14139. teardown: function() {
  14140. var doc = this.ownerDocument || this,
  14141. attaches = dataPriv.access( doc, fix ) - 1;
  14142. if ( !attaches ) {
  14143. doc.removeEventListener( orig, handler, true );
  14144. dataPriv.remove( doc, fix );
  14145. } else {
  14146. dataPriv.access( doc, fix, attaches );
  14147. }
  14148. }
  14149. };
  14150. } );
  14151. }
  14152. var location = window.location;
  14153. var nonce = Date.now();
  14154. var rquery = ( /\?/ );
  14155. // Cross-browser xml parsing
  14156. jQuery.parseXML = function( data ) {
  14157. var xml;
  14158. if ( !data || typeof data !== "string" ) {
  14159. return null;
  14160. }
  14161. // Support: IE 9 - 11 only
  14162. // IE throws on parseFromString with invalid input.
  14163. try {
  14164. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14165. } catch ( e ) {
  14166. xml = undefined;
  14167. }
  14168. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14169. jQuery.error( "Invalid XML: " + data );
  14170. }
  14171. return xml;
  14172. };
  14173. var
  14174. rbracket = /\[\]$/,
  14175. rCRLF = /\r?\n/g,
  14176. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14177. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14178. function buildParams( prefix, obj, traditional, add ) {
  14179. var name;
  14180. if ( Array.isArray( obj ) ) {
  14181. // Serialize array item.
  14182. jQuery.each( obj, function( i, v ) {
  14183. if ( traditional || rbracket.test( prefix ) ) {
  14184. // Treat each array item as a scalar.
  14185. add( prefix, v );
  14186. } else {
  14187. // Item is non-scalar (array or object), encode its numeric index.
  14188. buildParams(
  14189. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14190. v,
  14191. traditional,
  14192. add
  14193. );
  14194. }
  14195. } );
  14196. } else if ( !traditional && toType( obj ) === "object" ) {
  14197. // Serialize object item.
  14198. for ( name in obj ) {
  14199. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14200. }
  14201. } else {
  14202. // Serialize scalar item.
  14203. add( prefix, obj );
  14204. }
  14205. }
  14206. // Serialize an array of form elements or a set of
  14207. // key/values into a query string
  14208. jQuery.param = function( a, traditional ) {
  14209. var prefix,
  14210. s = [],
  14211. add = function( key, valueOrFunction ) {
  14212. // If value is a function, invoke it and use its return value
  14213. var value = isFunction( valueOrFunction ) ?
  14214. valueOrFunction() :
  14215. valueOrFunction;
  14216. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14217. encodeURIComponent( value == null ? "" : value );
  14218. };
  14219. if ( a == null ) {
  14220. return "";
  14221. }
  14222. // If an array was passed in, assume that it is an array of form elements.
  14223. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14224. // Serialize the form elements
  14225. jQuery.each( a, function() {
  14226. add( this.name, this.value );
  14227. } );
  14228. } else {
  14229. // If traditional, encode the "old" way (the way 1.3.2 or older
  14230. // did it), otherwise encode params recursively.
  14231. for ( prefix in a ) {
  14232. buildParams( prefix, a[ prefix ], traditional, add );
  14233. }
  14234. }
  14235. // Return the resulting serialization
  14236. return s.join( "&" );
  14237. };
  14238. jQuery.fn.extend( {
  14239. serialize: function() {
  14240. return jQuery.param( this.serializeArray() );
  14241. },
  14242. serializeArray: function() {
  14243. return this.map( function() {
  14244. // Can add propHook for "elements" to filter or add form elements
  14245. var elements = jQuery.prop( this, "elements" );
  14246. return elements ? jQuery.makeArray( elements ) : this;
  14247. } )
  14248. .filter( function() {
  14249. var type = this.type;
  14250. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14251. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14252. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14253. ( this.checked || !rcheckableType.test( type ) );
  14254. } )
  14255. .map( function( i, elem ) {
  14256. var val = jQuery( this ).val();
  14257. if ( val == null ) {
  14258. return null;
  14259. }
  14260. if ( Array.isArray( val ) ) {
  14261. return jQuery.map( val, function( val ) {
  14262. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14263. } );
  14264. }
  14265. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14266. } ).get();
  14267. }
  14268. } );
  14269. var
  14270. r20 = /%20/g,
  14271. rhash = /#.*$/,
  14272. rantiCache = /([?&])_=[^&]*/,
  14273. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14274. // #7653, #8125, #8152: local protocol detection
  14275. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14276. rnoContent = /^(?:GET|HEAD)$/,
  14277. rprotocol = /^\/\//,
  14278. /* Prefilters
  14279. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14280. * 2) These are called:
  14281. * - BEFORE asking for a transport
  14282. * - AFTER param serialization (s.data is a string if s.processData is true)
  14283. * 3) key is the dataType
  14284. * 4) the catchall symbol "*" can be used
  14285. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14286. */
  14287. prefilters = {},
  14288. /* Transports bindings
  14289. * 1) key is the dataType
  14290. * 2) the catchall symbol "*" can be used
  14291. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14292. */
  14293. transports = {},
  14294. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14295. allTypes = "*/".concat( "*" ),
  14296. // Anchor tag for parsing the document origin
  14297. originAnchor = document.createElement( "a" );
  14298. originAnchor.href = location.href;
  14299. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14300. function addToPrefiltersOrTransports( structure ) {
  14301. // dataTypeExpression is optional and defaults to "*"
  14302. return function( dataTypeExpression, func ) {
  14303. if ( typeof dataTypeExpression !== "string" ) {
  14304. func = dataTypeExpression;
  14305. dataTypeExpression = "*";
  14306. }
  14307. var dataType,
  14308. i = 0,
  14309. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14310. if ( isFunction( func ) ) {
  14311. // For each dataType in the dataTypeExpression
  14312. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14313. // Prepend if requested
  14314. if ( dataType[ 0 ] === "+" ) {
  14315. dataType = dataType.slice( 1 ) || "*";
  14316. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14317. // Otherwise append
  14318. } else {
  14319. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14320. }
  14321. }
  14322. }
  14323. };
  14324. }
  14325. // Base inspection function for prefilters and transports
  14326. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14327. var inspected = {},
  14328. seekingTransport = ( structure === transports );
  14329. function inspect( dataType ) {
  14330. var selected;
  14331. inspected[ dataType ] = true;
  14332. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14333. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14334. if ( typeof dataTypeOrTransport === "string" &&
  14335. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14336. options.dataTypes.unshift( dataTypeOrTransport );
  14337. inspect( dataTypeOrTransport );
  14338. return false;
  14339. } else if ( seekingTransport ) {
  14340. return !( selected = dataTypeOrTransport );
  14341. }
  14342. } );
  14343. return selected;
  14344. }
  14345. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14346. }
  14347. // A special extend for ajax options
  14348. // that takes "flat" options (not to be deep extended)
  14349. // Fixes #9887
  14350. function ajaxExtend( target, src ) {
  14351. var key, deep,
  14352. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14353. for ( key in src ) {
  14354. if ( src[ key ] !== undefined ) {
  14355. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14356. }
  14357. }
  14358. if ( deep ) {
  14359. jQuery.extend( true, target, deep );
  14360. }
  14361. return target;
  14362. }
  14363. /* Handles responses to an ajax request:
  14364. * - finds the right dataType (mediates between content-type and expected dataType)
  14365. * - returns the corresponding response
  14366. */
  14367. function ajaxHandleResponses( s, jqXHR, responses ) {
  14368. var ct, type, finalDataType, firstDataType,
  14369. contents = s.contents,
  14370. dataTypes = s.dataTypes;
  14371. // Remove auto dataType and get content-type in the process
  14372. while ( dataTypes[ 0 ] === "*" ) {
  14373. dataTypes.shift();
  14374. if ( ct === undefined ) {
  14375. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14376. }
  14377. }
  14378. // Check if we're dealing with a known content-type
  14379. if ( ct ) {
  14380. for ( type in contents ) {
  14381. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14382. dataTypes.unshift( type );
  14383. break;
  14384. }
  14385. }
  14386. }
  14387. // Check to see if we have a response for the expected dataType
  14388. if ( dataTypes[ 0 ] in responses ) {
  14389. finalDataType = dataTypes[ 0 ];
  14390. } else {
  14391. // Try convertible dataTypes
  14392. for ( type in responses ) {
  14393. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14394. finalDataType = type;
  14395. break;
  14396. }
  14397. if ( !firstDataType ) {
  14398. firstDataType = type;
  14399. }
  14400. }
  14401. // Or just use first one
  14402. finalDataType = finalDataType || firstDataType;
  14403. }
  14404. // If we found a dataType
  14405. // We add the dataType to the list if needed
  14406. // and return the corresponding response
  14407. if ( finalDataType ) {
  14408. if ( finalDataType !== dataTypes[ 0 ] ) {
  14409. dataTypes.unshift( finalDataType );
  14410. }
  14411. return responses[ finalDataType ];
  14412. }
  14413. }
  14414. /* Chain conversions given the request and the original response
  14415. * Also sets the responseXXX fields on the jqXHR instance
  14416. */
  14417. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14418. var conv2, current, conv, tmp, prev,
  14419. converters = {},
  14420. // Work with a copy of dataTypes in case we need to modify it for conversion
  14421. dataTypes = s.dataTypes.slice();
  14422. // Create converters map with lowercased keys
  14423. if ( dataTypes[ 1 ] ) {
  14424. for ( conv in s.converters ) {
  14425. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14426. }
  14427. }
  14428. current = dataTypes.shift();
  14429. // Convert to each sequential dataType
  14430. while ( current ) {
  14431. if ( s.responseFields[ current ] ) {
  14432. jqXHR[ s.responseFields[ current ] ] = response;
  14433. }
  14434. // Apply the dataFilter if provided
  14435. if ( !prev && isSuccess && s.dataFilter ) {
  14436. response = s.dataFilter( response, s.dataType );
  14437. }
  14438. prev = current;
  14439. current = dataTypes.shift();
  14440. if ( current ) {
  14441. // There's only work to do if current dataType is non-auto
  14442. if ( current === "*" ) {
  14443. current = prev;
  14444. // Convert response if prev dataType is non-auto and differs from current
  14445. } else if ( prev !== "*" && prev !== current ) {
  14446. // Seek a direct converter
  14447. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14448. // If none found, seek a pair
  14449. if ( !conv ) {
  14450. for ( conv2 in converters ) {
  14451. // If conv2 outputs current
  14452. tmp = conv2.split( " " );
  14453. if ( tmp[ 1 ] === current ) {
  14454. // If prev can be converted to accepted input
  14455. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14456. converters[ "* " + tmp[ 0 ] ];
  14457. if ( conv ) {
  14458. // Condense equivalence converters
  14459. if ( conv === true ) {
  14460. conv = converters[ conv2 ];
  14461. // Otherwise, insert the intermediate dataType
  14462. } else if ( converters[ conv2 ] !== true ) {
  14463. current = tmp[ 0 ];
  14464. dataTypes.unshift( tmp[ 1 ] );
  14465. }
  14466. break;
  14467. }
  14468. }
  14469. }
  14470. }
  14471. // Apply converter (if not an equivalence)
  14472. if ( conv !== true ) {
  14473. // Unless errors are allowed to bubble, catch and return them
  14474. if ( conv && s.throws ) {
  14475. response = conv( response );
  14476. } else {
  14477. try {
  14478. response = conv( response );
  14479. } catch ( e ) {
  14480. return {
  14481. state: "parsererror",
  14482. error: conv ? e : "No conversion from " + prev + " to " + current
  14483. };
  14484. }
  14485. }
  14486. }
  14487. }
  14488. }
  14489. }
  14490. return { state: "success", data: response };
  14491. }
  14492. jQuery.extend( {
  14493. // Counter for holding the number of active queries
  14494. active: 0,
  14495. // Last-Modified header cache for next request
  14496. lastModified: {},
  14497. etag: {},
  14498. ajaxSettings: {
  14499. url: location.href,
  14500. type: "GET",
  14501. isLocal: rlocalProtocol.test( location.protocol ),
  14502. global: true,
  14503. processData: true,
  14504. async: true,
  14505. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14506. /*
  14507. timeout: 0,
  14508. data: null,
  14509. dataType: null,
  14510. username: null,
  14511. password: null,
  14512. cache: null,
  14513. throws: false,
  14514. traditional: false,
  14515. headers: {},
  14516. */
  14517. accepts: {
  14518. "*": allTypes,
  14519. text: "text/plain",
  14520. html: "text/html",
  14521. xml: "application/xml, text/xml",
  14522. json: "application/json, text/javascript"
  14523. },
  14524. contents: {
  14525. xml: /\bxml\b/,
  14526. html: /\bhtml/,
  14527. json: /\bjson\b/
  14528. },
  14529. responseFields: {
  14530. xml: "responseXML",
  14531. text: "responseText",
  14532. json: "responseJSON"
  14533. },
  14534. // Data converters
  14535. // Keys separate source (or catchall "*") and destination types with a single space
  14536. converters: {
  14537. // Convert anything to text
  14538. "* text": String,
  14539. // Text to html (true = no transformation)
  14540. "text html": true,
  14541. // Evaluate text as a json expression
  14542. "text json": JSON.parse,
  14543. // Parse text as xml
  14544. "text xml": jQuery.parseXML
  14545. },
  14546. // For options that shouldn't be deep extended:
  14547. // you can add your own custom options here if
  14548. // and when you create one that shouldn't be
  14549. // deep extended (see ajaxExtend)
  14550. flatOptions: {
  14551. url: true,
  14552. context: true
  14553. }
  14554. },
  14555. // Creates a full fledged settings object into target
  14556. // with both ajaxSettings and settings fields.
  14557. // If target is omitted, writes into ajaxSettings.
  14558. ajaxSetup: function( target, settings ) {
  14559. return settings ?
  14560. // Building a settings object
  14561. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14562. // Extending ajaxSettings
  14563. ajaxExtend( jQuery.ajaxSettings, target );
  14564. },
  14565. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14566. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14567. // Main method
  14568. ajax: function( url, options ) {
  14569. // If url is an object, simulate pre-1.5 signature
  14570. if ( typeof url === "object" ) {
  14571. options = url;
  14572. url = undefined;
  14573. }
  14574. // Force options to be an object
  14575. options = options || {};
  14576. var transport,
  14577. // URL without anti-cache param
  14578. cacheURL,
  14579. // Response headers
  14580. responseHeadersString,
  14581. responseHeaders,
  14582. // timeout handle
  14583. timeoutTimer,
  14584. // Url cleanup var
  14585. urlAnchor,
  14586. // Request state (becomes false upon send and true upon completion)
  14587. completed,
  14588. // To know if global events are to be dispatched
  14589. fireGlobals,
  14590. // Loop variable
  14591. i,
  14592. // uncached part of the url
  14593. uncached,
  14594. // Create the final options object
  14595. s = jQuery.ajaxSetup( {}, options ),
  14596. // Callbacks context
  14597. callbackContext = s.context || s,
  14598. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14599. globalEventContext = s.context &&
  14600. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14601. jQuery( callbackContext ) :
  14602. jQuery.event,
  14603. // Deferreds
  14604. deferred = jQuery.Deferred(),
  14605. completeDeferred = jQuery.Callbacks( "once memory" ),
  14606. // Status-dependent callbacks
  14607. statusCode = s.statusCode || {},
  14608. // Headers (they are sent all at once)
  14609. requestHeaders = {},
  14610. requestHeadersNames = {},
  14611. // Default abort message
  14612. strAbort = "canceled",
  14613. // Fake xhr
  14614. jqXHR = {
  14615. readyState: 0,
  14616. // Builds headers hashtable if needed
  14617. getResponseHeader: function( key ) {
  14618. var match;
  14619. if ( completed ) {
  14620. if ( !responseHeaders ) {
  14621. responseHeaders = {};
  14622. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14623. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14624. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14625. .concat( match[ 2 ] );
  14626. }
  14627. }
  14628. match = responseHeaders[ key.toLowerCase() + " " ];
  14629. }
  14630. return match == null ? null : match.join( ", " );
  14631. },
  14632. // Raw string
  14633. getAllResponseHeaders: function() {
  14634. return completed ? responseHeadersString : null;
  14635. },
  14636. // Caches the header
  14637. setRequestHeader: function( name, value ) {
  14638. if ( completed == null ) {
  14639. name = requestHeadersNames[ name.toLowerCase() ] =
  14640. requestHeadersNames[ name.toLowerCase() ] || name;
  14641. requestHeaders[ name ] = value;
  14642. }
  14643. return this;
  14644. },
  14645. // Overrides response content-type header
  14646. overrideMimeType: function( type ) {
  14647. if ( completed == null ) {
  14648. s.mimeType = type;
  14649. }
  14650. return this;
  14651. },
  14652. // Status-dependent callbacks
  14653. statusCode: function( map ) {
  14654. var code;
  14655. if ( map ) {
  14656. if ( completed ) {
  14657. // Execute the appropriate callbacks
  14658. jqXHR.always( map[ jqXHR.status ] );
  14659. } else {
  14660. // Lazy-add the new callbacks in a way that preserves old ones
  14661. for ( code in map ) {
  14662. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14663. }
  14664. }
  14665. }
  14666. return this;
  14667. },
  14668. // Cancel the request
  14669. abort: function( statusText ) {
  14670. var finalText = statusText || strAbort;
  14671. if ( transport ) {
  14672. transport.abort( finalText );
  14673. }
  14674. done( 0, finalText );
  14675. return this;
  14676. }
  14677. };
  14678. // Attach deferreds
  14679. deferred.promise( jqXHR );
  14680. // Add protocol if not provided (prefilters might expect it)
  14681. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14682. // We also use the url parameter if available
  14683. s.url = ( ( url || s.url || location.href ) + "" )
  14684. .replace( rprotocol, location.protocol + "//" );
  14685. // Alias method option to type as per ticket #12004
  14686. s.type = options.method || options.type || s.method || s.type;
  14687. // Extract dataTypes list
  14688. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14689. // A cross-domain request is in order when the origin doesn't match the current origin.
  14690. if ( s.crossDomain == null ) {
  14691. urlAnchor = document.createElement( "a" );
  14692. // Support: IE <=8 - 11, Edge 12 - 15
  14693. // IE throws exception on accessing the href property if url is malformed,
  14694. // e.g. http://example.com:80x/
  14695. try {
  14696. urlAnchor.href = s.url;
  14697. // Support: IE <=8 - 11 only
  14698. // Anchor's host property isn't correctly set when s.url is relative
  14699. urlAnchor.href = urlAnchor.href;
  14700. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14701. urlAnchor.protocol + "//" + urlAnchor.host;
  14702. } catch ( e ) {
  14703. // If there is an error parsing the URL, assume it is crossDomain,
  14704. // it can be rejected by the transport if it is invalid
  14705. s.crossDomain = true;
  14706. }
  14707. }
  14708. // Convert data if not already a string
  14709. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14710. s.data = jQuery.param( s.data, s.traditional );
  14711. }
  14712. // Apply prefilters
  14713. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14714. // If request was aborted inside a prefilter, stop there
  14715. if ( completed ) {
  14716. return jqXHR;
  14717. }
  14718. // We can fire global events as of now if asked to
  14719. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14720. fireGlobals = jQuery.event && s.global;
  14721. // Watch for a new set of requests
  14722. if ( fireGlobals && jQuery.active++ === 0 ) {
  14723. jQuery.event.trigger( "ajaxStart" );
  14724. }
  14725. // Uppercase the type
  14726. s.type = s.type.toUpperCase();
  14727. // Determine if request has content
  14728. s.hasContent = !rnoContent.test( s.type );
  14729. // Save the URL in case we're toying with the If-Modified-Since
  14730. // and/or If-None-Match header later on
  14731. // Remove hash to simplify url manipulation
  14732. cacheURL = s.url.replace( rhash, "" );
  14733. // More options handling for requests with no content
  14734. if ( !s.hasContent ) {
  14735. // Remember the hash so we can put it back
  14736. uncached = s.url.slice( cacheURL.length );
  14737. // If data is available and should be processed, append data to url
  14738. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14739. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14740. // #9682: remove data so that it's not used in an eventual retry
  14741. delete s.data;
  14742. }
  14743. // Add or update anti-cache param if needed
  14744. if ( s.cache === false ) {
  14745. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14746. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14747. }
  14748. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14749. s.url = cacheURL + uncached;
  14750. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14751. } else if ( s.data && s.processData &&
  14752. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14753. s.data = s.data.replace( r20, "+" );
  14754. }
  14755. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14756. if ( s.ifModified ) {
  14757. if ( jQuery.lastModified[ cacheURL ] ) {
  14758. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14759. }
  14760. if ( jQuery.etag[ cacheURL ] ) {
  14761. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14762. }
  14763. }
  14764. // Set the correct header, if data is being sent
  14765. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14766. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14767. }
  14768. // Set the Accepts header for the server, depending on the dataType
  14769. jqXHR.setRequestHeader(
  14770. "Accept",
  14771. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14772. s.accepts[ s.dataTypes[ 0 ] ] +
  14773. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14774. s.accepts[ "*" ]
  14775. );
  14776. // Check for headers option
  14777. for ( i in s.headers ) {
  14778. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14779. }
  14780. // Allow custom headers/mimetypes and early abort
  14781. if ( s.beforeSend &&
  14782. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14783. // Abort if not done already and return
  14784. return jqXHR.abort();
  14785. }
  14786. // Aborting is no longer a cancellation
  14787. strAbort = "abort";
  14788. // Install callbacks on deferreds
  14789. completeDeferred.add( s.complete );
  14790. jqXHR.done( s.success );
  14791. jqXHR.fail( s.error );
  14792. // Get transport
  14793. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14794. // If no transport, we auto-abort
  14795. if ( !transport ) {
  14796. done( -1, "No Transport" );
  14797. } else {
  14798. jqXHR.readyState = 1;
  14799. // Send global event
  14800. if ( fireGlobals ) {
  14801. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14802. }
  14803. // If request was aborted inside ajaxSend, stop there
  14804. if ( completed ) {
  14805. return jqXHR;
  14806. }
  14807. // Timeout
  14808. if ( s.async && s.timeout > 0 ) {
  14809. timeoutTimer = window.setTimeout( function() {
  14810. jqXHR.abort( "timeout" );
  14811. }, s.timeout );
  14812. }
  14813. try {
  14814. completed = false;
  14815. transport.send( requestHeaders, done );
  14816. } catch ( e ) {
  14817. // Rethrow post-completion exceptions
  14818. if ( completed ) {
  14819. throw e;
  14820. }
  14821. // Propagate others as results
  14822. done( -1, e );
  14823. }
  14824. }
  14825. // Callback for when everything is done
  14826. function done( status, nativeStatusText, responses, headers ) {
  14827. var isSuccess, success, error, response, modified,
  14828. statusText = nativeStatusText;
  14829. // Ignore repeat invocations
  14830. if ( completed ) {
  14831. return;
  14832. }
  14833. completed = true;
  14834. // Clear timeout if it exists
  14835. if ( timeoutTimer ) {
  14836. window.clearTimeout( timeoutTimer );
  14837. }
  14838. // Dereference transport for early garbage collection
  14839. // (no matter how long the jqXHR object will be used)
  14840. transport = undefined;
  14841. // Cache response headers
  14842. responseHeadersString = headers || "";
  14843. // Set readyState
  14844. jqXHR.readyState = status > 0 ? 4 : 0;
  14845. // Determine if successful
  14846. isSuccess = status >= 200 && status < 300 || status === 304;
  14847. // Get response data
  14848. if ( responses ) {
  14849. response = ajaxHandleResponses( s, jqXHR, responses );
  14850. }
  14851. // Convert no matter what (that way responseXXX fields are always set)
  14852. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14853. // If successful, handle type chaining
  14854. if ( isSuccess ) {
  14855. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14856. if ( s.ifModified ) {
  14857. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14858. if ( modified ) {
  14859. jQuery.lastModified[ cacheURL ] = modified;
  14860. }
  14861. modified = jqXHR.getResponseHeader( "etag" );
  14862. if ( modified ) {
  14863. jQuery.etag[ cacheURL ] = modified;
  14864. }
  14865. }
  14866. // if no content
  14867. if ( status === 204 || s.type === "HEAD" ) {
  14868. statusText = "nocontent";
  14869. // if not modified
  14870. } else if ( status === 304 ) {
  14871. statusText = "notmodified";
  14872. // If we have data, let's convert it
  14873. } else {
  14874. statusText = response.state;
  14875. success = response.data;
  14876. error = response.error;
  14877. isSuccess = !error;
  14878. }
  14879. } else {
  14880. // Extract error from statusText and normalize for non-aborts
  14881. error = statusText;
  14882. if ( status || !statusText ) {
  14883. statusText = "error";
  14884. if ( status < 0 ) {
  14885. status = 0;
  14886. }
  14887. }
  14888. }
  14889. // Set data for the fake xhr object
  14890. jqXHR.status = status;
  14891. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14892. // Success/Error
  14893. if ( isSuccess ) {
  14894. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14895. } else {
  14896. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14897. }
  14898. // Status-dependent callbacks
  14899. jqXHR.statusCode( statusCode );
  14900. statusCode = undefined;
  14901. if ( fireGlobals ) {
  14902. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14903. [ jqXHR, s, isSuccess ? success : error ] );
  14904. }
  14905. // Complete
  14906. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14907. if ( fireGlobals ) {
  14908. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14909. // Handle the global AJAX counter
  14910. if ( !( --jQuery.active ) ) {
  14911. jQuery.event.trigger( "ajaxStop" );
  14912. }
  14913. }
  14914. }
  14915. return jqXHR;
  14916. },
  14917. getJSON: function( url, data, callback ) {
  14918. return jQuery.get( url, data, callback, "json" );
  14919. },
  14920. getScript: function( url, callback ) {
  14921. return jQuery.get( url, undefined, callback, "script" );
  14922. }
  14923. } );
  14924. jQuery.each( [ "get", "post" ], function( i, method ) {
  14925. jQuery[ method ] = function( url, data, callback, type ) {
  14926. // Shift arguments if data argument was omitted
  14927. if ( isFunction( data ) ) {
  14928. type = type || callback;
  14929. callback = data;
  14930. data = undefined;
  14931. }
  14932. // The url can be an options object (which then must have .url)
  14933. return jQuery.ajax( jQuery.extend( {
  14934. url: url,
  14935. type: method,
  14936. dataType: type,
  14937. data: data,
  14938. success: callback
  14939. }, jQuery.isPlainObject( url ) && url ) );
  14940. };
  14941. } );
  14942. jQuery._evalUrl = function( url, options ) {
  14943. return jQuery.ajax( {
  14944. url: url,
  14945. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14946. type: "GET",
  14947. dataType: "script",
  14948. cache: true,
  14949. async: false,
  14950. global: false,
  14951. // Only evaluate the response if it is successful (gh-4126)
  14952. // dataFilter is not invoked for failure responses, so using it instead
  14953. // of the default converter is kludgy but it works.
  14954. converters: {
  14955. "text script": function() {}
  14956. },
  14957. dataFilter: function( response ) {
  14958. jQuery.globalEval( response, options );
  14959. }
  14960. } );
  14961. };
  14962. jQuery.fn.extend( {
  14963. wrapAll: function( html ) {
  14964. var wrap;
  14965. if ( this[ 0 ] ) {
  14966. if ( isFunction( html ) ) {
  14967. html = html.call( this[ 0 ] );
  14968. }
  14969. // The elements to wrap the target around
  14970. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  14971. if ( this[ 0 ].parentNode ) {
  14972. wrap.insertBefore( this[ 0 ] );
  14973. }
  14974. wrap.map( function() {
  14975. var elem = this;
  14976. while ( elem.firstElementChild ) {
  14977. elem = elem.firstElementChild;
  14978. }
  14979. return elem;
  14980. } ).append( this );
  14981. }
  14982. return this;
  14983. },
  14984. wrapInner: function( html ) {
  14985. if ( isFunction( html ) ) {
  14986. return this.each( function( i ) {
  14987. jQuery( this ).wrapInner( html.call( this, i ) );
  14988. } );
  14989. }
  14990. return this.each( function() {
  14991. var self = jQuery( this ),
  14992. contents = self.contents();
  14993. if ( contents.length ) {
  14994. contents.wrapAll( html );
  14995. } else {
  14996. self.append( html );
  14997. }
  14998. } );
  14999. },
  15000. wrap: function( html ) {
  15001. var htmlIsFunction = isFunction( html );
  15002. return this.each( function( i ) {
  15003. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15004. } );
  15005. },
  15006. unwrap: function( selector ) {
  15007. this.parent( selector ).not( "body" ).each( function() {
  15008. jQuery( this ).replaceWith( this.childNodes );
  15009. } );
  15010. return this;
  15011. }
  15012. } );
  15013. jQuery.expr.pseudos.hidden = function( elem ) {
  15014. return !jQuery.expr.pseudos.visible( elem );
  15015. };
  15016. jQuery.expr.pseudos.visible = function( elem ) {
  15017. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15018. };
  15019. jQuery.ajaxSettings.xhr = function() {
  15020. try {
  15021. return new window.XMLHttpRequest();
  15022. } catch ( e ) {}
  15023. };
  15024. var xhrSuccessStatus = {
  15025. // File protocol always yields status code 0, assume 200
  15026. 0: 200,
  15027. // Support: IE <=9 only
  15028. // #1450: sometimes IE returns 1223 when it should be 204
  15029. 1223: 204
  15030. },
  15031. xhrSupported = jQuery.ajaxSettings.xhr();
  15032. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15033. support.ajax = xhrSupported = !!xhrSupported;
  15034. jQuery.ajaxTransport( function( options ) {
  15035. var callback, errorCallback;
  15036. // Cross domain only allowed if supported through XMLHttpRequest
  15037. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15038. return {
  15039. send: function( headers, complete ) {
  15040. var i,
  15041. xhr = options.xhr();
  15042. xhr.open(
  15043. options.type,
  15044. options.url,
  15045. options.async,
  15046. options.username,
  15047. options.password
  15048. );
  15049. // Apply custom fields if provided
  15050. if ( options.xhrFields ) {
  15051. for ( i in options.xhrFields ) {
  15052. xhr[ i ] = options.xhrFields[ i ];
  15053. }
  15054. }
  15055. // Override mime type if needed
  15056. if ( options.mimeType && xhr.overrideMimeType ) {
  15057. xhr.overrideMimeType( options.mimeType );
  15058. }
  15059. // X-Requested-With header
  15060. // For cross-domain requests, seeing as conditions for a preflight are
  15061. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15062. // (it can always be set on a per-request basis or even using ajaxSetup)
  15063. // For same-domain requests, won't change header if already provided.
  15064. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15065. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15066. }
  15067. // Set headers
  15068. for ( i in headers ) {
  15069. xhr.setRequestHeader( i, headers[ i ] );
  15070. }
  15071. // Callback
  15072. callback = function( type ) {
  15073. return function() {
  15074. if ( callback ) {
  15075. callback = errorCallback = xhr.onload =
  15076. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15077. xhr.onreadystatechange = null;
  15078. if ( type === "abort" ) {
  15079. xhr.abort();
  15080. } else if ( type === "error" ) {
  15081. // Support: IE <=9 only
  15082. // On a manual native abort, IE9 throws
  15083. // errors on any property access that is not readyState
  15084. if ( typeof xhr.status !== "number" ) {
  15085. complete( 0, "error" );
  15086. } else {
  15087. complete(
  15088. // File: protocol always yields status 0; see #8605, #14207
  15089. xhr.status,
  15090. xhr.statusText
  15091. );
  15092. }
  15093. } else {
  15094. complete(
  15095. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15096. xhr.statusText,
  15097. // Support: IE <=9 only
  15098. // IE9 has no XHR2 but throws on binary (trac-11426)
  15099. // For XHR2 non-text, let the caller handle it (gh-2498)
  15100. ( xhr.responseType || "text" ) !== "text" ||
  15101. typeof xhr.responseText !== "string" ?
  15102. { binary: xhr.response } :
  15103. { text: xhr.responseText },
  15104. xhr.getAllResponseHeaders()
  15105. );
  15106. }
  15107. }
  15108. };
  15109. };
  15110. // Listen to events
  15111. xhr.onload = callback();
  15112. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15113. // Support: IE 9 only
  15114. // Use onreadystatechange to replace onabort
  15115. // to handle uncaught aborts
  15116. if ( xhr.onabort !== undefined ) {
  15117. xhr.onabort = errorCallback;
  15118. } else {
  15119. xhr.onreadystatechange = function() {
  15120. // Check readyState before timeout as it changes
  15121. if ( xhr.readyState === 4 ) {
  15122. // Allow onerror to be called first,
  15123. // but that will not handle a native abort
  15124. // Also, save errorCallback to a variable
  15125. // as xhr.onerror cannot be accessed
  15126. window.setTimeout( function() {
  15127. if ( callback ) {
  15128. errorCallback();
  15129. }
  15130. } );
  15131. }
  15132. };
  15133. }
  15134. // Create the abort callback
  15135. callback = callback( "abort" );
  15136. try {
  15137. // Do send the request (this may raise an exception)
  15138. xhr.send( options.hasContent && options.data || null );
  15139. } catch ( e ) {
  15140. // #14683: Only rethrow if this hasn't been notified as an error yet
  15141. if ( callback ) {
  15142. throw e;
  15143. }
  15144. }
  15145. },
  15146. abort: function() {
  15147. if ( callback ) {
  15148. callback();
  15149. }
  15150. }
  15151. };
  15152. }
  15153. } );
  15154. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15155. jQuery.ajaxPrefilter( function( s ) {
  15156. if ( s.crossDomain ) {
  15157. s.contents.script = false;
  15158. }
  15159. } );
  15160. // Install script dataType
  15161. jQuery.ajaxSetup( {
  15162. accepts: {
  15163. script: "text/javascript, application/javascript, " +
  15164. "application/ecmascript, application/x-ecmascript"
  15165. },
  15166. contents: {
  15167. script: /\b(?:java|ecma)script\b/
  15168. },
  15169. converters: {
  15170. "text script": function( text ) {
  15171. jQuery.globalEval( text );
  15172. return text;
  15173. }
  15174. }
  15175. } );
  15176. // Handle cache's special case and crossDomain
  15177. jQuery.ajaxPrefilter( "script", function( s ) {
  15178. if ( s.cache === undefined ) {
  15179. s.cache = false;
  15180. }
  15181. if ( s.crossDomain ) {
  15182. s.type = "GET";
  15183. }
  15184. } );
  15185. // Bind script tag hack transport
  15186. jQuery.ajaxTransport( "script", function( s ) {
  15187. // This transport only deals with cross domain or forced-by-attrs requests
  15188. if ( s.crossDomain || s.scriptAttrs ) {
  15189. var script, callback;
  15190. return {
  15191. send: function( _, complete ) {
  15192. script = jQuery( "<script>" )
  15193. .attr( s.scriptAttrs || {} )
  15194. .prop( { charset: s.scriptCharset, src: s.url } )
  15195. .on( "load error", callback = function( evt ) {
  15196. script.remove();
  15197. callback = null;
  15198. if ( evt ) {
  15199. complete( evt.type === "error" ? 404 : 200, evt.type );
  15200. }
  15201. } );
  15202. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15203. document.head.appendChild( script[ 0 ] );
  15204. },
  15205. abort: function() {
  15206. if ( callback ) {
  15207. callback();
  15208. }
  15209. }
  15210. };
  15211. }
  15212. } );
  15213. var oldCallbacks = [],
  15214. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15215. // Default jsonp settings
  15216. jQuery.ajaxSetup( {
  15217. jsonp: "callback",
  15218. jsonpCallback: function() {
  15219. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15220. this[ callback ] = true;
  15221. return callback;
  15222. }
  15223. } );
  15224. // Detect, normalize options and install callbacks for jsonp requests
  15225. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15226. var callbackName, overwritten, responseContainer,
  15227. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15228. "url" :
  15229. typeof s.data === "string" &&
  15230. ( s.contentType || "" )
  15231. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15232. rjsonp.test( s.data ) && "data"
  15233. );
  15234. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15235. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15236. // Get callback name, remembering preexisting value associated with it
  15237. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15238. s.jsonpCallback() :
  15239. s.jsonpCallback;
  15240. // Insert callback into url or form data
  15241. if ( jsonProp ) {
  15242. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15243. } else if ( s.jsonp !== false ) {
  15244. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15245. }
  15246. // Use data converter to retrieve json after script execution
  15247. s.converters[ "script json" ] = function() {
  15248. if ( !responseContainer ) {
  15249. jQuery.error( callbackName + " was not called" );
  15250. }
  15251. return responseContainer[ 0 ];
  15252. };
  15253. // Force json dataType
  15254. s.dataTypes[ 0 ] = "json";
  15255. // Install callback
  15256. overwritten = window[ callbackName ];
  15257. window[ callbackName ] = function() {
  15258. responseContainer = arguments;
  15259. };
  15260. // Clean-up function (fires after converters)
  15261. jqXHR.always( function() {
  15262. // If previous value didn't exist - remove it
  15263. if ( overwritten === undefined ) {
  15264. jQuery( window ).removeProp( callbackName );
  15265. // Otherwise restore preexisting value
  15266. } else {
  15267. window[ callbackName ] = overwritten;
  15268. }
  15269. // Save back as free
  15270. if ( s[ callbackName ] ) {
  15271. // Make sure that re-using the options doesn't screw things around
  15272. s.jsonpCallback = originalSettings.jsonpCallback;
  15273. // Save the callback name for future use
  15274. oldCallbacks.push( callbackName );
  15275. }
  15276. // Call if it was a function and we have a response
  15277. if ( responseContainer && isFunction( overwritten ) ) {
  15278. overwritten( responseContainer[ 0 ] );
  15279. }
  15280. responseContainer = overwritten = undefined;
  15281. } );
  15282. // Delegate to script
  15283. return "script";
  15284. }
  15285. } );
  15286. // Support: Safari 8 only
  15287. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15288. // collapse sibling forms: the second one becomes a child of the first one.
  15289. // Because of that, this security measure has to be disabled in Safari 8.
  15290. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15291. support.createHTMLDocument = ( function() {
  15292. var body = document.implementation.createHTMLDocument( "" ).body;
  15293. body.innerHTML = "<form></form><form></form>";
  15294. return body.childNodes.length === 2;
  15295. } )();
  15296. // Argument "data" should be string of html
  15297. // context (optional): If specified, the fragment will be created in this context,
  15298. // defaults to document
  15299. // keepScripts (optional): If true, will include scripts passed in the html string
  15300. jQuery.parseHTML = function( data, context, keepScripts ) {
  15301. if ( typeof data !== "string" ) {
  15302. return [];
  15303. }
  15304. if ( typeof context === "boolean" ) {
  15305. keepScripts = context;
  15306. context = false;
  15307. }
  15308. var base, parsed, scripts;
  15309. if ( !context ) {
  15310. // Stop scripts or inline event handlers from being executed immediately
  15311. // by using document.implementation
  15312. if ( support.createHTMLDocument ) {
  15313. context = document.implementation.createHTMLDocument( "" );
  15314. // Set the base href for the created document
  15315. // so any parsed elements with URLs
  15316. // are based on the document's URL (gh-2965)
  15317. base = context.createElement( "base" );
  15318. base.href = document.location.href;
  15319. context.head.appendChild( base );
  15320. } else {
  15321. context = document;
  15322. }
  15323. }
  15324. parsed = rsingleTag.exec( data );
  15325. scripts = !keepScripts && [];
  15326. // Single tag
  15327. if ( parsed ) {
  15328. return [ context.createElement( parsed[ 1 ] ) ];
  15329. }
  15330. parsed = buildFragment( [ data ], context, scripts );
  15331. if ( scripts && scripts.length ) {
  15332. jQuery( scripts ).remove();
  15333. }
  15334. return jQuery.merge( [], parsed.childNodes );
  15335. };
  15336. /**
  15337. * Load a url into a page
  15338. */
  15339. jQuery.fn.load = function( url, params, callback ) {
  15340. var selector, type, response,
  15341. self = this,
  15342. off = url.indexOf( " " );
  15343. if ( off > -1 ) {
  15344. selector = stripAndCollapse( url.slice( off ) );
  15345. url = url.slice( 0, off );
  15346. }
  15347. // If it's a function
  15348. if ( isFunction( params ) ) {
  15349. // We assume that it's the callback
  15350. callback = params;
  15351. params = undefined;
  15352. // Otherwise, build a param string
  15353. } else if ( params && typeof params === "object" ) {
  15354. type = "POST";
  15355. }
  15356. // If we have elements to modify, make the request
  15357. if ( self.length > 0 ) {
  15358. jQuery.ajax( {
  15359. url: url,
  15360. // If "type" variable is undefined, then "GET" method will be used.
  15361. // Make value of this field explicit since
  15362. // user can override it through ajaxSetup method
  15363. type: type || "GET",
  15364. dataType: "html",
  15365. data: params
  15366. } ).done( function( responseText ) {
  15367. // Save response for use in complete callback
  15368. response = arguments;
  15369. self.html( selector ?
  15370. // If a selector was specified, locate the right elements in a dummy div
  15371. // Exclude scripts to avoid IE 'Permission Denied' errors
  15372. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15373. // Otherwise use the full result
  15374. responseText );
  15375. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15376. // but they are ignored because response was set above.
  15377. // If it fails, this function gets "jqXHR", "status", "error"
  15378. } ).always( callback && function( jqXHR, status ) {
  15379. self.each( function() {
  15380. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15381. } );
  15382. } );
  15383. }
  15384. return this;
  15385. };
  15386. // Attach a bunch of functions for handling common AJAX events
  15387. jQuery.each( [
  15388. "ajaxStart",
  15389. "ajaxStop",
  15390. "ajaxComplete",
  15391. "ajaxError",
  15392. "ajaxSuccess",
  15393. "ajaxSend"
  15394. ], function( i, type ) {
  15395. jQuery.fn[ type ] = function( fn ) {
  15396. return this.on( type, fn );
  15397. };
  15398. } );
  15399. jQuery.expr.pseudos.animated = function( elem ) {
  15400. return jQuery.grep( jQuery.timers, function( fn ) {
  15401. return elem === fn.elem;
  15402. } ).length;
  15403. };
  15404. jQuery.offset = {
  15405. setOffset: function( elem, options, i ) {
  15406. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15407. position = jQuery.css( elem, "position" ),
  15408. curElem = jQuery( elem ),
  15409. props = {};
  15410. // Set position first, in-case top/left are set even on static elem
  15411. if ( position === "static" ) {
  15412. elem.style.position = "relative";
  15413. }
  15414. curOffset = curElem.offset();
  15415. curCSSTop = jQuery.css( elem, "top" );
  15416. curCSSLeft = jQuery.css( elem, "left" );
  15417. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15418. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15419. // Need to be able to calculate position if either
  15420. // top or left is auto and position is either absolute or fixed
  15421. if ( calculatePosition ) {
  15422. curPosition = curElem.position();
  15423. curTop = curPosition.top;
  15424. curLeft = curPosition.left;
  15425. } else {
  15426. curTop = parseFloat( curCSSTop ) || 0;
  15427. curLeft = parseFloat( curCSSLeft ) || 0;
  15428. }
  15429. if ( isFunction( options ) ) {
  15430. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15431. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15432. }
  15433. if ( options.top != null ) {
  15434. props.top = ( options.top - curOffset.top ) + curTop;
  15435. }
  15436. if ( options.left != null ) {
  15437. props.left = ( options.left - curOffset.left ) + curLeft;
  15438. }
  15439. if ( "using" in options ) {
  15440. options.using.call( elem, props );
  15441. } else {
  15442. curElem.css( props );
  15443. }
  15444. }
  15445. };
  15446. jQuery.fn.extend( {
  15447. // offset() relates an element's border box to the document origin
  15448. offset: function( options ) {
  15449. // Preserve chaining for setter
  15450. if ( arguments.length ) {
  15451. return options === undefined ?
  15452. this :
  15453. this.each( function( i ) {
  15454. jQuery.offset.setOffset( this, options, i );
  15455. } );
  15456. }
  15457. var rect, win,
  15458. elem = this[ 0 ];
  15459. if ( !elem ) {
  15460. return;
  15461. }
  15462. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15463. // Support: IE <=11 only
  15464. // Running getBoundingClientRect on a
  15465. // disconnected node in IE throws an error
  15466. if ( !elem.getClientRects().length ) {
  15467. return { top: 0, left: 0 };
  15468. }
  15469. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15470. rect = elem.getBoundingClientRect();
  15471. win = elem.ownerDocument.defaultView;
  15472. return {
  15473. top: rect.top + win.pageYOffset,
  15474. left: rect.left + win.pageXOffset
  15475. };
  15476. },
  15477. // position() relates an element's margin box to its offset parent's padding box
  15478. // This corresponds to the behavior of CSS absolute positioning
  15479. position: function() {
  15480. if ( !this[ 0 ] ) {
  15481. return;
  15482. }
  15483. var offsetParent, offset, doc,
  15484. elem = this[ 0 ],
  15485. parentOffset = { top: 0, left: 0 };
  15486. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15487. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15488. // Assume position:fixed implies availability of getBoundingClientRect
  15489. offset = elem.getBoundingClientRect();
  15490. } else {
  15491. offset = this.offset();
  15492. // Account for the *real* offset parent, which can be the document or its root element
  15493. // when a statically positioned element is identified
  15494. doc = elem.ownerDocument;
  15495. offsetParent = elem.offsetParent || doc.documentElement;
  15496. while ( offsetParent &&
  15497. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15498. jQuery.css( offsetParent, "position" ) === "static" ) {
  15499. offsetParent = offsetParent.parentNode;
  15500. }
  15501. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15502. // Incorporate borders into its offset, since they are outside its content origin
  15503. parentOffset = jQuery( offsetParent ).offset();
  15504. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15505. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15506. }
  15507. }
  15508. // Subtract parent offsets and element margins
  15509. return {
  15510. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15511. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15512. };
  15513. },
  15514. // This method will return documentElement in the following cases:
  15515. // 1) For the element inside the iframe without offsetParent, this method will return
  15516. // documentElement of the parent window
  15517. // 2) For the hidden or detached element
  15518. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15519. //
  15520. // but those exceptions were never presented as a real life use-cases
  15521. // and might be considered as more preferable results.
  15522. //
  15523. // This logic, however, is not guaranteed and can change at any point in the future
  15524. offsetParent: function() {
  15525. return this.map( function() {
  15526. var offsetParent = this.offsetParent;
  15527. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15528. offsetParent = offsetParent.offsetParent;
  15529. }
  15530. return offsetParent || documentElement;
  15531. } );
  15532. }
  15533. } );
  15534. // Create scrollLeft and scrollTop methods
  15535. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15536. var top = "pageYOffset" === prop;
  15537. jQuery.fn[ method ] = function( val ) {
  15538. return access( this, function( elem, method, val ) {
  15539. // Coalesce documents and windows
  15540. var win;
  15541. if ( isWindow( elem ) ) {
  15542. win = elem;
  15543. } else if ( elem.nodeType === 9 ) {
  15544. win = elem.defaultView;
  15545. }
  15546. if ( val === undefined ) {
  15547. return win ? win[ prop ] : elem[ method ];
  15548. }
  15549. if ( win ) {
  15550. win.scrollTo(
  15551. !top ? val : win.pageXOffset,
  15552. top ? val : win.pageYOffset
  15553. );
  15554. } else {
  15555. elem[ method ] = val;
  15556. }
  15557. }, method, val, arguments.length );
  15558. };
  15559. } );
  15560. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15561. // Add the top/left cssHooks using jQuery.fn.position
  15562. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15563. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15564. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15565. // rather than make the css module depend on the offset module, just check for it here
  15566. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15567. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15568. function( elem, computed ) {
  15569. if ( computed ) {
  15570. computed = curCSS( elem, prop );
  15571. // If curCSS returns percentage, fallback to offset
  15572. return rnumnonpx.test( computed ) ?
  15573. jQuery( elem ).position()[ prop ] + "px" :
  15574. computed;
  15575. }
  15576. }
  15577. );
  15578. } );
  15579. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15580. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15581. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15582. function( defaultExtra, funcName ) {
  15583. // Margin is only for outerHeight, outerWidth
  15584. jQuery.fn[ funcName ] = function( margin, value ) {
  15585. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15586. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15587. return access( this, function( elem, type, value ) {
  15588. var doc;
  15589. if ( isWindow( elem ) ) {
  15590. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15591. return funcName.indexOf( "outer" ) === 0 ?
  15592. elem[ "inner" + name ] :
  15593. elem.document.documentElement[ "client" + name ];
  15594. }
  15595. // Get document width or height
  15596. if ( elem.nodeType === 9 ) {
  15597. doc = elem.documentElement;
  15598. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15599. // whichever is greatest
  15600. return Math.max(
  15601. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15602. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15603. doc[ "client" + name ]
  15604. );
  15605. }
  15606. return value === undefined ?
  15607. // Get width or height on the element, requesting but not forcing parseFloat
  15608. jQuery.css( elem, type, extra ) :
  15609. // Set width or height on the element
  15610. jQuery.style( elem, type, value, extra );
  15611. }, type, chainable ? margin : undefined, chainable );
  15612. };
  15613. } );
  15614. } );
  15615. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15616. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15617. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15618. function( i, name ) {
  15619. // Handle event binding
  15620. jQuery.fn[ name ] = function( data, fn ) {
  15621. return arguments.length > 0 ?
  15622. this.on( name, null, data, fn ) :
  15623. this.trigger( name );
  15624. };
  15625. } );
  15626. jQuery.fn.extend( {
  15627. hover: function( fnOver, fnOut ) {
  15628. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15629. }
  15630. } );
  15631. jQuery.fn.extend( {
  15632. bind: function( types, data, fn ) {
  15633. return this.on( types, null, data, fn );
  15634. },
  15635. unbind: function( types, fn ) {
  15636. return this.off( types, null, fn );
  15637. },
  15638. delegate: function( selector, types, data, fn ) {
  15639. return this.on( types, selector, data, fn );
  15640. },
  15641. undelegate: function( selector, types, fn ) {
  15642. // ( namespace ) or ( selector, types [, fn] )
  15643. return arguments.length === 1 ?
  15644. this.off( selector, "**" ) :
  15645. this.off( types, selector || "**", fn );
  15646. }
  15647. } );
  15648. // Bind a function to a context, optionally partially applying any
  15649. // arguments.
  15650. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15651. // However, it is not slated for removal any time soon
  15652. jQuery.proxy = function( fn, context ) {
  15653. var tmp, args, proxy;
  15654. if ( typeof context === "string" ) {
  15655. tmp = fn[ context ];
  15656. context = fn;
  15657. fn = tmp;
  15658. }
  15659. // Quick check to determine if target is callable, in the spec
  15660. // this throws a TypeError, but we will just return undefined.
  15661. if ( !isFunction( fn ) ) {
  15662. return undefined;
  15663. }
  15664. // Simulated bind
  15665. args = slice.call( arguments, 2 );
  15666. proxy = function() {
  15667. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15668. };
  15669. // Set the guid of unique handler to the same of original handler, so it can be removed
  15670. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15671. return proxy;
  15672. };
  15673. jQuery.holdReady = function( hold ) {
  15674. if ( hold ) {
  15675. jQuery.readyWait++;
  15676. } else {
  15677. jQuery.ready( true );
  15678. }
  15679. };
  15680. jQuery.isArray = Array.isArray;
  15681. jQuery.parseJSON = JSON.parse;
  15682. jQuery.nodeName = nodeName;
  15683. jQuery.isFunction = isFunction;
  15684. jQuery.isWindow = isWindow;
  15685. jQuery.camelCase = camelCase;
  15686. jQuery.type = toType;
  15687. jQuery.now = Date.now;
  15688. jQuery.isNumeric = function( obj ) {
  15689. // As of jQuery 3.0, isNumeric is limited to
  15690. // strings and numbers (primitives or objects)
  15691. // that can be coerced to finite numbers (gh-2662)
  15692. var type = jQuery.type( obj );
  15693. return ( type === "number" || type === "string" ) &&
  15694. // parseFloat NaNs numeric-cast false positives ("")
  15695. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15696. // subtraction forces infinities to NaN
  15697. !isNaN( obj - parseFloat( obj ) );
  15698. };
  15699. // Register as a named AMD module, since jQuery can be concatenated with other
  15700. // files that may use define, but not via a proper concatenation script that
  15701. // understands anonymous AMD modules. A named AMD is safest and most robust
  15702. // way to register. Lowercase jquery is used because AMD module names are
  15703. // derived from file names, and jQuery is normally delivered in a lowercase
  15704. // file name. Do this after creating the global so that if an AMD module wants
  15705. // to call noConflict to hide this version of jQuery, it will work.
  15706. // Note that for maximum portability, libraries that are not jQuery should
  15707. // declare themselves as anonymous modules, and avoid setting a global if an
  15708. // AMD loader is present. jQuery is a special case. For more information, see
  15709. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15710. if ( true ) {
  15711. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15712. return jQuery;
  15713. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15714. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15715. }
  15716. var
  15717. // Map over jQuery in case of overwrite
  15718. _jQuery = window.jQuery,
  15719. // Map over the $ in case of overwrite
  15720. _$ = window.$;
  15721. jQuery.noConflict = function( deep ) {
  15722. if ( window.$ === jQuery ) {
  15723. window.$ = _$;
  15724. }
  15725. if ( deep && window.jQuery === jQuery ) {
  15726. window.jQuery = _jQuery;
  15727. }
  15728. return jQuery;
  15729. };
  15730. // Expose jQuery and $ identifiers, even in AMD
  15731. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15732. // and CommonJS for browser emulators (#13566)
  15733. if ( !noGlobal ) {
  15734. window.jQuery = window.$ = jQuery;
  15735. }
  15736. return jQuery;
  15737. } );
  15738. /***/ }),
  15739. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15740. /*!************************************************!*\
  15741. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15742. \************************************************/
  15743. /*! exports provided: default */
  15744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15745. "use strict";
  15746. __webpack_require__.r(__webpack_exports__);
  15747. var classCallCheck = function (instance, Constructor) {
  15748. if (!(instance instanceof Constructor)) {
  15749. throw new TypeError("Cannot call a class as a function");
  15750. }
  15751. };
  15752. var createClass = function () {
  15753. function defineProperties(target, props) {
  15754. for (var i = 0; i < props.length; i++) {
  15755. var descriptor = props[i];
  15756. descriptor.enumerable = descriptor.enumerable || false;
  15757. descriptor.configurable = true;
  15758. if ("value" in descriptor) descriptor.writable = true;
  15759. Object.defineProperty(target, descriptor.key, descriptor);
  15760. }
  15761. }
  15762. return function (Constructor, protoProps, staticProps) {
  15763. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15764. if (staticProps) defineProperties(Constructor, staticProps);
  15765. return Constructor;
  15766. };
  15767. }();
  15768. var _extends = Object.assign || function (target) {
  15769. for (var i = 1; i < arguments.length; i++) {
  15770. var source = arguments[i];
  15771. for (var key in source) {
  15772. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15773. target[key] = source[key];
  15774. }
  15775. }
  15776. }
  15777. return target;
  15778. };
  15779. var inherits = function (subClass, superClass) {
  15780. if (typeof superClass !== "function" && superClass !== null) {
  15781. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15782. }
  15783. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15784. constructor: {
  15785. value: subClass,
  15786. enumerable: false,
  15787. writable: true,
  15788. configurable: true
  15789. }
  15790. });
  15791. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15792. };
  15793. var possibleConstructorReturn = function (self, call) {
  15794. if (!self) {
  15795. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15796. }
  15797. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15798. };
  15799. var Connector = function () {
  15800. /**
  15801. * Create a new class instance.
  15802. */
  15803. function Connector(options) {
  15804. classCallCheck(this, Connector);
  15805. /**
  15806. * Default connector options.
  15807. */
  15808. this._defaultOptions = {
  15809. auth: {
  15810. headers: {}
  15811. },
  15812. authEndpoint: '/broadcasting/auth',
  15813. broadcaster: 'pusher',
  15814. csrfToken: null,
  15815. host: null,
  15816. key: null,
  15817. namespace: 'App.Events'
  15818. };
  15819. this.setOptions(options);
  15820. this.connect();
  15821. }
  15822. /**
  15823. * Merge the custom options with the defaults.
  15824. */
  15825. createClass(Connector, [{
  15826. key: 'setOptions',
  15827. value: function setOptions(options) {
  15828. this.options = _extends(this._defaultOptions, options);
  15829. if (this.csrfToken()) {
  15830. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15831. }
  15832. return options;
  15833. }
  15834. /**
  15835. * Extract the CSRF token from the page.
  15836. */
  15837. }, {
  15838. key: 'csrfToken',
  15839. value: function csrfToken() {
  15840. var selector = void 0;
  15841. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15842. return window['Laravel'].csrfToken;
  15843. } else if (this.options.csrfToken) {
  15844. return this.options.csrfToken;
  15845. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15846. return selector.getAttribute('content');
  15847. }
  15848. return null;
  15849. }
  15850. }]);
  15851. return Connector;
  15852. }();
  15853. /**
  15854. * This class represents a basic channel.
  15855. */
  15856. var Channel = function () {
  15857. function Channel() {
  15858. classCallCheck(this, Channel);
  15859. }
  15860. createClass(Channel, [{
  15861. key: 'listenForWhisper',
  15862. /**
  15863. * Listen for a whisper event on the channel instance.
  15864. */
  15865. value: function listenForWhisper(event, callback) {
  15866. return this.listen('.client-' + event, callback);
  15867. }
  15868. /**
  15869. * Listen for an event on the channel instance.
  15870. */
  15871. }, {
  15872. key: 'notification',
  15873. value: function notification(callback) {
  15874. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15875. }
  15876. /**
  15877. * Stop listening for a whispser event on the channel instance.
  15878. */
  15879. }, {
  15880. key: 'stopListeningForWhisper',
  15881. value: function stopListeningForWhisper(event) {
  15882. return this.stopListening('.client-' + event);
  15883. }
  15884. }]);
  15885. return Channel;
  15886. }();
  15887. /**
  15888. * Event name formatter
  15889. */
  15890. var EventFormatter = function () {
  15891. /**
  15892. * Create a new class instance.
  15893. */
  15894. function EventFormatter(namespace) {
  15895. classCallCheck(this, EventFormatter);
  15896. this.setNamespace(namespace);
  15897. }
  15898. /**
  15899. * Format the given event name.
  15900. */
  15901. createClass(EventFormatter, [{
  15902. key: 'format',
  15903. value: function format(event) {
  15904. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15905. return event.substr(1);
  15906. } else if (this.namespace) {
  15907. event = this.namespace + '.' + event;
  15908. }
  15909. return event.replace(/\./g, '\\');
  15910. }
  15911. /**
  15912. * Set the event namespace.
  15913. */
  15914. }, {
  15915. key: 'setNamespace',
  15916. value: function setNamespace(value) {
  15917. this.namespace = value;
  15918. }
  15919. }]);
  15920. return EventFormatter;
  15921. }();
  15922. /**
  15923. * This class represents a Pusher channel.
  15924. */
  15925. var PusherChannel = function (_Channel) {
  15926. inherits(PusherChannel, _Channel);
  15927. /**
  15928. * Create a new class instance.
  15929. */
  15930. function PusherChannel(pusher, name, options) {
  15931. classCallCheck(this, PusherChannel);
  15932. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15933. _this.name = name;
  15934. _this.pusher = pusher;
  15935. _this.options = options;
  15936. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15937. _this.subscribe();
  15938. return _this;
  15939. }
  15940. /**
  15941. * Subscribe to a Pusher channel.
  15942. */
  15943. createClass(PusherChannel, [{
  15944. key: 'subscribe',
  15945. value: function subscribe() {
  15946. this.subscription = this.pusher.subscribe(this.name);
  15947. }
  15948. /**
  15949. * Unsubscribe from a Pusher channel.
  15950. */
  15951. }, {
  15952. key: 'unsubscribe',
  15953. value: function unsubscribe() {
  15954. this.pusher.unsubscribe(this.name);
  15955. }
  15956. /**
  15957. * Listen for an event on the channel instance.
  15958. */
  15959. }, {
  15960. key: 'listen',
  15961. value: function listen(event, callback) {
  15962. this.on(this.eventFormatter.format(event), callback);
  15963. return this;
  15964. }
  15965. /**
  15966. * Stop listening for an event on the channel instance.
  15967. */
  15968. }, {
  15969. key: 'stopListening',
  15970. value: function stopListening(event) {
  15971. this.subscription.unbind(this.eventFormatter.format(event));
  15972. return this;
  15973. }
  15974. /**
  15975. * Bind a channel to an event.
  15976. */
  15977. }, {
  15978. key: 'on',
  15979. value: function on(event, callback) {
  15980. this.subscription.bind(event, callback);
  15981. return this;
  15982. }
  15983. }]);
  15984. return PusherChannel;
  15985. }(Channel);
  15986. /**
  15987. * This class represents a Pusher private channel.
  15988. */
  15989. var PusherPrivateChannel = function (_PusherChannel) {
  15990. inherits(PusherPrivateChannel, _PusherChannel);
  15991. function PusherPrivateChannel() {
  15992. classCallCheck(this, PusherPrivateChannel);
  15993. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  15994. }
  15995. createClass(PusherPrivateChannel, [{
  15996. key: 'whisper',
  15997. /**
  15998. * Trigger client event on the channel.
  15999. */
  16000. value: function whisper(eventName, data) {
  16001. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16002. return this;
  16003. }
  16004. }]);
  16005. return PusherPrivateChannel;
  16006. }(PusherChannel);
  16007. /**
  16008. * This class represents a Pusher presence channel.
  16009. */
  16010. var PusherPresenceChannel = function (_PusherChannel) {
  16011. inherits(PusherPresenceChannel, _PusherChannel);
  16012. function PusherPresenceChannel() {
  16013. classCallCheck(this, PusherPresenceChannel);
  16014. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16015. }
  16016. createClass(PusherPresenceChannel, [{
  16017. key: 'here',
  16018. /**
  16019. * Register a callback to be called anytime the member list changes.
  16020. */
  16021. value: function here(callback) {
  16022. this.on('pusher:subscription_succeeded', function (data) {
  16023. callback(Object.keys(data.members).map(function (k) {
  16024. return data.members[k];
  16025. }));
  16026. });
  16027. return this;
  16028. }
  16029. /**
  16030. * Listen for someone joining the channel.
  16031. */
  16032. }, {
  16033. key: 'joining',
  16034. value: function joining(callback) {
  16035. this.on('pusher:member_added', function (member) {
  16036. callback(member.info);
  16037. });
  16038. return this;
  16039. }
  16040. /**
  16041. * Listen for someone leaving the channel.
  16042. */
  16043. }, {
  16044. key: 'leaving',
  16045. value: function leaving(callback) {
  16046. this.on('pusher:member_removed', function (member) {
  16047. callback(member.info);
  16048. });
  16049. return this;
  16050. }
  16051. /**
  16052. * Trigger client event on the channel.
  16053. */
  16054. }, {
  16055. key: 'whisper',
  16056. value: function whisper(eventName, data) {
  16057. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16058. return this;
  16059. }
  16060. }]);
  16061. return PusherPresenceChannel;
  16062. }(PusherChannel);
  16063. /**
  16064. * This class represents a Socket.io channel.
  16065. */
  16066. var SocketIoChannel = function (_Channel) {
  16067. inherits(SocketIoChannel, _Channel);
  16068. /**
  16069. * Create a new class instance.
  16070. */
  16071. function SocketIoChannel(socket, name, options) {
  16072. classCallCheck(this, SocketIoChannel);
  16073. /**
  16074. * The event callbacks applied to the channel.
  16075. */
  16076. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16077. _this.events = {};
  16078. _this.name = name;
  16079. _this.socket = socket;
  16080. _this.options = options;
  16081. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16082. _this.subscribe();
  16083. _this.configureReconnector();
  16084. return _this;
  16085. }
  16086. /**
  16087. * Subscribe to a Socket.io channel.
  16088. */
  16089. createClass(SocketIoChannel, [{
  16090. key: 'subscribe',
  16091. value: function subscribe() {
  16092. this.socket.emit('subscribe', {
  16093. channel: this.name,
  16094. auth: this.options.auth || {}
  16095. });
  16096. }
  16097. /**
  16098. * Unsubscribe from channel and ubind event callbacks.
  16099. */
  16100. }, {
  16101. key: 'unsubscribe',
  16102. value: function unsubscribe() {
  16103. this.unbind();
  16104. this.socket.emit('unsubscribe', {
  16105. channel: this.name,
  16106. auth: this.options.auth || {}
  16107. });
  16108. }
  16109. /**
  16110. * Listen for an event on the channel instance.
  16111. */
  16112. }, {
  16113. key: 'listen',
  16114. value: function listen(event, callback) {
  16115. this.on(this.eventFormatter.format(event), callback);
  16116. return this;
  16117. }
  16118. /**
  16119. * Stop listening for an event on the channel instance.
  16120. */
  16121. }, {
  16122. key: 'stopListening',
  16123. value: function stopListening(event) {
  16124. var name = this.eventFormatter.format(event);
  16125. this.socket.removeListener(name);
  16126. delete this.events[name];
  16127. return this;
  16128. }
  16129. /**
  16130. * Bind the channel's socket to an event and store the callback.
  16131. */
  16132. }, {
  16133. key: 'on',
  16134. value: function on(event, callback) {
  16135. var _this2 = this;
  16136. var listener = function listener(channel, data) {
  16137. if (_this2.name == channel) {
  16138. callback(data);
  16139. }
  16140. };
  16141. this.socket.on(event, listener);
  16142. this.bind(event, listener);
  16143. }
  16144. /**
  16145. * Attach a 'reconnect' listener and bind the event.
  16146. */
  16147. }, {
  16148. key: 'configureReconnector',
  16149. value: function configureReconnector() {
  16150. var _this3 = this;
  16151. var listener = function listener() {
  16152. _this3.subscribe();
  16153. };
  16154. this.socket.on('reconnect', listener);
  16155. this.bind('reconnect', listener);
  16156. }
  16157. /**
  16158. * Bind the channel's socket to an event and store the callback.
  16159. */
  16160. }, {
  16161. key: 'bind',
  16162. value: function bind(event, callback) {
  16163. this.events[event] = this.events[event] || [];
  16164. this.events[event].push(callback);
  16165. }
  16166. /**
  16167. * Unbind the channel's socket from all stored event callbacks.
  16168. */
  16169. }, {
  16170. key: 'unbind',
  16171. value: function unbind() {
  16172. var _this4 = this;
  16173. Object.keys(this.events).forEach(function (event) {
  16174. _this4.events[event].forEach(function (callback) {
  16175. _this4.socket.removeListener(event, callback);
  16176. });
  16177. delete _this4.events[event];
  16178. });
  16179. }
  16180. }]);
  16181. return SocketIoChannel;
  16182. }(Channel);
  16183. /**
  16184. * This class represents a Socket.io presence channel.
  16185. */
  16186. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16187. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16188. function SocketIoPrivateChannel() {
  16189. classCallCheck(this, SocketIoPrivateChannel);
  16190. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16191. }
  16192. createClass(SocketIoPrivateChannel, [{
  16193. key: 'whisper',
  16194. /**
  16195. * Trigger client event on the channel.
  16196. */
  16197. value: function whisper(eventName, data) {
  16198. this.socket.emit('client event', {
  16199. channel: this.name,
  16200. event: 'client-' + eventName,
  16201. data: data
  16202. });
  16203. return this;
  16204. }
  16205. }]);
  16206. return SocketIoPrivateChannel;
  16207. }(SocketIoChannel);
  16208. /**
  16209. * This class represents a Socket.io presence channel.
  16210. */
  16211. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16212. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16213. function SocketIoPresenceChannel() {
  16214. classCallCheck(this, SocketIoPresenceChannel);
  16215. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16216. }
  16217. createClass(SocketIoPresenceChannel, [{
  16218. key: 'here',
  16219. /**
  16220. * Register a callback to be called anytime the member list changes.
  16221. */
  16222. value: function here(callback) {
  16223. this.on('presence:subscribed', function (members) {
  16224. callback(members.map(function (m) {
  16225. return m.user_info;
  16226. }));
  16227. });
  16228. return this;
  16229. }
  16230. /**
  16231. * Listen for someone joining the channel.
  16232. */
  16233. }, {
  16234. key: 'joining',
  16235. value: function joining(callback) {
  16236. this.on('presence:joining', function (member) {
  16237. return callback(member.user_info);
  16238. });
  16239. return this;
  16240. }
  16241. /**
  16242. * Listen for someone leaving the channel.
  16243. */
  16244. }, {
  16245. key: 'leaving',
  16246. value: function leaving(callback) {
  16247. this.on('presence:leaving', function (member) {
  16248. return callback(member.user_info);
  16249. });
  16250. return this;
  16251. }
  16252. }]);
  16253. return SocketIoPresenceChannel;
  16254. }(SocketIoPrivateChannel);
  16255. /**
  16256. * This class represents a null channel.
  16257. */
  16258. var NullChannel = function (_Channel) {
  16259. inherits(NullChannel, _Channel);
  16260. function NullChannel() {
  16261. classCallCheck(this, NullChannel);
  16262. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16263. }
  16264. createClass(NullChannel, [{
  16265. key: 'subscribe',
  16266. /**
  16267. * Subscribe to a channel.
  16268. */
  16269. value: function subscribe() {}
  16270. //
  16271. /**
  16272. * Unsubscribe from a channel.
  16273. */
  16274. }, {
  16275. key: 'unsubscribe',
  16276. value: function unsubscribe() {}
  16277. //
  16278. /**
  16279. * Listen for an event on the channel instance.
  16280. */
  16281. }, {
  16282. key: 'listen',
  16283. value: function listen(event, callback) {
  16284. return this;
  16285. }
  16286. /**
  16287. * Stop listening for an event on the channel instance.
  16288. */
  16289. }, {
  16290. key: 'stopListening',
  16291. value: function stopListening(event) {
  16292. return this;
  16293. }
  16294. /**
  16295. * Bind a channel to an event.
  16296. */
  16297. }, {
  16298. key: 'on',
  16299. value: function on(event, callback) {
  16300. return this;
  16301. }
  16302. }]);
  16303. return NullChannel;
  16304. }(Channel);
  16305. /**
  16306. * This class represents a null private channel.
  16307. */
  16308. var NullPrivateChannel = function (_NullChannel) {
  16309. inherits(NullPrivateChannel, _NullChannel);
  16310. function NullPrivateChannel() {
  16311. classCallCheck(this, NullPrivateChannel);
  16312. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16313. }
  16314. createClass(NullPrivateChannel, [{
  16315. key: 'whisper',
  16316. /**
  16317. * Trigger client event on the channel.
  16318. */
  16319. value: function whisper(eventName, data) {
  16320. return this;
  16321. }
  16322. }]);
  16323. return NullPrivateChannel;
  16324. }(NullChannel);
  16325. /**
  16326. * This class represents a null presence channel.
  16327. */
  16328. var NullPresenceChannel = function (_NullChannel) {
  16329. inherits(NullPresenceChannel, _NullChannel);
  16330. function NullPresenceChannel() {
  16331. classCallCheck(this, NullPresenceChannel);
  16332. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16333. }
  16334. createClass(NullPresenceChannel, [{
  16335. key: 'here',
  16336. /**
  16337. * Register a callback to be called anytime the member list changes.
  16338. */
  16339. value: function here(callback) {
  16340. return this;
  16341. }
  16342. /**
  16343. * Listen for someone joining the channel.
  16344. */
  16345. }, {
  16346. key: 'joining',
  16347. value: function joining(callback) {
  16348. return this;
  16349. }
  16350. /**
  16351. * Listen for someone leaving the channel.
  16352. */
  16353. }, {
  16354. key: 'leaving',
  16355. value: function leaving(callback) {
  16356. return this;
  16357. }
  16358. /**
  16359. * Trigger client event on the channel.
  16360. */
  16361. }, {
  16362. key: 'whisper',
  16363. value: function whisper(eventName, data) {
  16364. return this;
  16365. }
  16366. }]);
  16367. return NullPresenceChannel;
  16368. }(NullChannel);
  16369. /**
  16370. * This class creates a connector to Pusher.
  16371. */
  16372. var PusherConnector = function (_Connector) {
  16373. inherits(PusherConnector, _Connector);
  16374. function PusherConnector() {
  16375. classCallCheck(this, PusherConnector);
  16376. /**
  16377. * All of the subscribed channel names.
  16378. */
  16379. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16380. _this.channels = {};
  16381. return _this;
  16382. }
  16383. /**
  16384. * Create a fresh Pusher connection.
  16385. */
  16386. createClass(PusherConnector, [{
  16387. key: 'connect',
  16388. value: function connect() {
  16389. if (typeof this.options.client !== 'undefined') {
  16390. this.pusher = this.options.client;
  16391. } else {
  16392. this.pusher = new Pusher(this.options.key, this.options);
  16393. }
  16394. }
  16395. /**
  16396. * Listen for an event on a channel instance.
  16397. */
  16398. }, {
  16399. key: 'listen',
  16400. value: function listen(name, event, callback) {
  16401. return this.channel(name).listen(event, callback);
  16402. }
  16403. /**
  16404. * Get a channel instance by name.
  16405. */
  16406. }, {
  16407. key: 'channel',
  16408. value: function channel(name) {
  16409. if (!this.channels[name]) {
  16410. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16411. }
  16412. return this.channels[name];
  16413. }
  16414. /**
  16415. * Get a private channel instance by name.
  16416. */
  16417. }, {
  16418. key: 'privateChannel',
  16419. value: function privateChannel(name) {
  16420. if (!this.channels['private-' + name]) {
  16421. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16422. }
  16423. return this.channels['private-' + name];
  16424. }
  16425. /**
  16426. * Get a presence channel instance by name.
  16427. */
  16428. }, {
  16429. key: 'presenceChannel',
  16430. value: function presenceChannel(name) {
  16431. if (!this.channels['presence-' + name]) {
  16432. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16433. }
  16434. return this.channels['presence-' + name];
  16435. }
  16436. /**
  16437. * Leave the given channel, as well as its private and presence variants.
  16438. */
  16439. }, {
  16440. key: 'leave',
  16441. value: function leave(name) {
  16442. var _this2 = this;
  16443. var channels = [name, 'private-' + name, 'presence-' + name];
  16444. channels.forEach(function (name, index) {
  16445. _this2.leaveChannel(name);
  16446. });
  16447. }
  16448. /**
  16449. * Leave the given channel.
  16450. */
  16451. }, {
  16452. key: 'leaveChannel',
  16453. value: function leaveChannel(name) {
  16454. if (this.channels[name]) {
  16455. this.channels[name].unsubscribe();
  16456. delete this.channels[name];
  16457. }
  16458. }
  16459. /**
  16460. * Get the socket ID for the connection.
  16461. */
  16462. }, {
  16463. key: 'socketId',
  16464. value: function socketId() {
  16465. return this.pusher.connection.socket_id;
  16466. }
  16467. /**
  16468. * Disconnect Pusher connection.
  16469. */
  16470. }, {
  16471. key: 'disconnect',
  16472. value: function disconnect() {
  16473. this.pusher.disconnect();
  16474. }
  16475. }]);
  16476. return PusherConnector;
  16477. }(Connector);
  16478. /**
  16479. * This class creates a connnector to a Socket.io server.
  16480. */
  16481. var SocketIoConnector = function (_Connector) {
  16482. inherits(SocketIoConnector, _Connector);
  16483. function SocketIoConnector() {
  16484. classCallCheck(this, SocketIoConnector);
  16485. /**
  16486. * All of the subscribed channel names.
  16487. */
  16488. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16489. _this.channels = {};
  16490. return _this;
  16491. }
  16492. /**
  16493. * Create a fresh Socket.io connection.
  16494. */
  16495. createClass(SocketIoConnector, [{
  16496. key: 'connect',
  16497. value: function connect() {
  16498. var io = this.getSocketIO();
  16499. this.socket = io(this.options.host, this.options);
  16500. return this.socket;
  16501. }
  16502. /**
  16503. * Get socket.io module from global scope or options.
  16504. */
  16505. }, {
  16506. key: 'getSocketIO',
  16507. value: function getSocketIO() {
  16508. if (typeof this.options.client !== 'undefined') {
  16509. return this.options.client;
  16510. }
  16511. if (typeof io !== 'undefined') {
  16512. return io;
  16513. }
  16514. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16515. }
  16516. /**
  16517. * Listen for an event on a channel instance.
  16518. */
  16519. }, {
  16520. key: 'listen',
  16521. value: function listen(name, event, callback) {
  16522. return this.channel(name).listen(event, callback);
  16523. }
  16524. /**
  16525. * Get a channel instance by name.
  16526. */
  16527. }, {
  16528. key: 'channel',
  16529. value: function channel(name) {
  16530. if (!this.channels[name]) {
  16531. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16532. }
  16533. return this.channels[name];
  16534. }
  16535. /**
  16536. * Get a private channel instance by name.
  16537. */
  16538. }, {
  16539. key: 'privateChannel',
  16540. value: function privateChannel(name) {
  16541. if (!this.channels['private-' + name]) {
  16542. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16543. }
  16544. return this.channels['private-' + name];
  16545. }
  16546. /**
  16547. * Get a presence channel instance by name.
  16548. */
  16549. }, {
  16550. key: 'presenceChannel',
  16551. value: function presenceChannel(name) {
  16552. if (!this.channels['presence-' + name]) {
  16553. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16554. }
  16555. return this.channels['presence-' + name];
  16556. }
  16557. /**
  16558. * Leave the given channel, as well as its private and presence variants.
  16559. */
  16560. }, {
  16561. key: 'leave',
  16562. value: function leave(name) {
  16563. var _this2 = this;
  16564. var channels = [name, 'private-' + name, 'presence-' + name];
  16565. channels.forEach(function (name) {
  16566. _this2.leaveChannel(name);
  16567. });
  16568. }
  16569. /**
  16570. * Leave the given channel.
  16571. */
  16572. }, {
  16573. key: 'leaveChannel',
  16574. value: function leaveChannel(name) {
  16575. if (this.channels[name]) {
  16576. this.channels[name].unsubscribe();
  16577. delete this.channels[name];
  16578. }
  16579. }
  16580. /**
  16581. * Get the socket ID for the connection.
  16582. */
  16583. }, {
  16584. key: 'socketId',
  16585. value: function socketId() {
  16586. return this.socket.id;
  16587. }
  16588. /**
  16589. * Disconnect Socketio connection.
  16590. */
  16591. }, {
  16592. key: 'disconnect',
  16593. value: function disconnect() {
  16594. this.socket.disconnect();
  16595. }
  16596. }]);
  16597. return SocketIoConnector;
  16598. }(Connector);
  16599. /**
  16600. * This class creates a null connector.
  16601. */
  16602. var NullConnector = function (_Connector) {
  16603. inherits(NullConnector, _Connector);
  16604. function NullConnector() {
  16605. classCallCheck(this, NullConnector);
  16606. /**
  16607. * All of the subscribed channel names.
  16608. */
  16609. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16610. _this.channels = {};
  16611. return _this;
  16612. }
  16613. /**
  16614. * Create a fresh connection.
  16615. */
  16616. createClass(NullConnector, [{
  16617. key: 'connect',
  16618. value: function connect() {}
  16619. //
  16620. /**
  16621. * Listen for an event on a channel instance.
  16622. */
  16623. }, {
  16624. key: 'listen',
  16625. value: function listen(name, event, callback) {
  16626. return new NullChannel();
  16627. }
  16628. /**
  16629. * Get a channel instance by name.
  16630. */
  16631. }, {
  16632. key: 'channel',
  16633. value: function channel(name) {
  16634. return new NullChannel();
  16635. }
  16636. /**
  16637. * Get a private channel instance by name.
  16638. */
  16639. }, {
  16640. key: 'privateChannel',
  16641. value: function privateChannel(name) {
  16642. return new NullPrivateChannel();
  16643. }
  16644. /**
  16645. * Get a presence channel instance by name.
  16646. */
  16647. }, {
  16648. key: 'presenceChannel',
  16649. value: function presenceChannel(name) {
  16650. return new NullPresenceChannel();
  16651. }
  16652. /**
  16653. * Leave the given channel, as well as its private and presence variants.
  16654. */
  16655. }, {
  16656. key: 'leave',
  16657. value: function leave(name) {}
  16658. //
  16659. /**
  16660. * Leave the given channel.
  16661. */
  16662. }, {
  16663. key: 'leaveChannel',
  16664. value: function leaveChannel(name) {}
  16665. //
  16666. /**
  16667. * Get the socket ID for the connection.
  16668. */
  16669. }, {
  16670. key: 'socketId',
  16671. value: function socketId() {
  16672. return 'fake-socket-id';
  16673. }
  16674. /**
  16675. * Disconnect the connection.
  16676. */
  16677. }, {
  16678. key: 'disconnect',
  16679. value: function disconnect() {
  16680. //
  16681. }
  16682. }]);
  16683. return NullConnector;
  16684. }(Connector);
  16685. /**
  16686. * This class is the primary API for interacting with broadcasting.
  16687. */
  16688. var Echo = function () {
  16689. /**
  16690. * Create a new class instance.
  16691. */
  16692. function Echo(options) {
  16693. classCallCheck(this, Echo);
  16694. this.options = options;
  16695. this.connect();
  16696. if (!this.options.withoutInterceptors) {
  16697. this.registerInterceptors();
  16698. }
  16699. }
  16700. /**
  16701. * Get a channel instance by name.
  16702. */
  16703. createClass(Echo, [{
  16704. key: 'channel',
  16705. value: function channel(_channel) {
  16706. return this.connector.channel(_channel);
  16707. }
  16708. /**
  16709. * Create a new connection.
  16710. */
  16711. }, {
  16712. key: 'connect',
  16713. value: function connect() {
  16714. if (this.options.broadcaster == 'pusher') {
  16715. this.connector = new PusherConnector(this.options);
  16716. } else if (this.options.broadcaster == 'socket.io') {
  16717. this.connector = new SocketIoConnector(this.options);
  16718. } else if (this.options.broadcaster == 'null') {
  16719. this.connector = new NullConnector(this.options);
  16720. } else if (typeof this.options.broadcaster == 'function') {
  16721. this.connector = new this.options.broadcaster(this.options);
  16722. }
  16723. }
  16724. /**
  16725. * Disconnect from the Echo server.
  16726. */
  16727. }, {
  16728. key: 'disconnect',
  16729. value: function disconnect() {
  16730. this.connector.disconnect();
  16731. }
  16732. /**
  16733. * Get a presence channel instance by name.
  16734. */
  16735. }, {
  16736. key: 'join',
  16737. value: function join(channel) {
  16738. return this.connector.presenceChannel(channel);
  16739. }
  16740. /**
  16741. * Leave the given channel, as well as its private and presence variants.
  16742. */
  16743. }, {
  16744. key: 'leave',
  16745. value: function leave(channel) {
  16746. this.connector.leave(channel);
  16747. }
  16748. /**
  16749. * Leave the given channel.
  16750. */
  16751. }, {
  16752. key: 'leaveChannel',
  16753. value: function leaveChannel(channel) {
  16754. this.connector.leaveChannel(channel);
  16755. }
  16756. /**
  16757. * Listen for an event on a channel instance.
  16758. */
  16759. }, {
  16760. key: 'listen',
  16761. value: function listen(channel, event, callback) {
  16762. return this.connector.listen(channel, event, callback);
  16763. }
  16764. /**
  16765. * Get a private channel instance by name.
  16766. */
  16767. }, {
  16768. key: 'private',
  16769. value: function _private(channel) {
  16770. return this.connector.privateChannel(channel);
  16771. }
  16772. /**
  16773. * Get the Socket ID for the connection.
  16774. */
  16775. }, {
  16776. key: 'socketId',
  16777. value: function socketId() {
  16778. return this.connector.socketId();
  16779. }
  16780. /**
  16781. * Register 3rd party request interceptiors. These are used to automatically
  16782. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16783. */
  16784. }, {
  16785. key: 'registerInterceptors',
  16786. value: function registerInterceptors() {
  16787. if (typeof Vue === 'function' && Vue.http) {
  16788. this.registerVueRequestInterceptor();
  16789. }
  16790. if (typeof axios === 'function') {
  16791. this.registerAxiosRequestInterceptor();
  16792. }
  16793. if (typeof jQuery === 'function') {
  16794. this.registerjQueryAjaxSetup();
  16795. }
  16796. }
  16797. /**
  16798. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16799. */
  16800. }, {
  16801. key: 'registerVueRequestInterceptor',
  16802. value: function registerVueRequestInterceptor() {
  16803. var _this = this;
  16804. Vue.http.interceptors.push(function (request, next) {
  16805. if (_this.socketId()) {
  16806. request.headers.set('X-Socket-ID', _this.socketId());
  16807. }
  16808. next();
  16809. });
  16810. }
  16811. /**
  16812. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16813. */
  16814. }, {
  16815. key: 'registerAxiosRequestInterceptor',
  16816. value: function registerAxiosRequestInterceptor() {
  16817. var _this2 = this;
  16818. axios.interceptors.request.use(function (config) {
  16819. if (_this2.socketId()) {
  16820. config.headers['X-Socket-Id'] = _this2.socketId();
  16821. }
  16822. return config;
  16823. });
  16824. }
  16825. /**
  16826. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16827. */
  16828. }, {
  16829. key: 'registerjQueryAjaxSetup',
  16830. value: function registerjQueryAjaxSetup() {
  16831. var _this3 = this;
  16832. if (typeof jQuery.ajax != 'undefined') {
  16833. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16834. if (_this3.socketId()) {
  16835. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16836. }
  16837. });
  16838. }
  16839. }
  16840. }]);
  16841. return Echo;
  16842. }();
  16843. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16844. /***/ }),
  16845. /***/ "./node_modules/lodash/lodash.js":
  16846. /*!***************************************!*\
  16847. !*** ./node_modules/lodash/lodash.js ***!
  16848. \***************************************/
  16849. /*! no static exports found */
  16850. /***/ (function(module, exports, __webpack_require__) {
  16851. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16852. * @license
  16853. * Lodash <https://lodash.com/>
  16854. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16855. * Released under MIT license <https://lodash.com/license>
  16856. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16857. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16858. */
  16859. ;(function() {
  16860. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16861. var undefined;
  16862. /** Used as the semantic version number. */
  16863. var VERSION = '4.17.15';
  16864. /** Used as the size to enable large array optimizations. */
  16865. var LARGE_ARRAY_SIZE = 200;
  16866. /** Error message constants. */
  16867. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16868. FUNC_ERROR_TEXT = 'Expected a function';
  16869. /** Used to stand-in for `undefined` hash values. */
  16870. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16871. /** Used as the maximum memoize cache size. */
  16872. var MAX_MEMOIZE_SIZE = 500;
  16873. /** Used as the internal argument placeholder. */
  16874. var PLACEHOLDER = '__lodash_placeholder__';
  16875. /** Used to compose bitmasks for cloning. */
  16876. var CLONE_DEEP_FLAG = 1,
  16877. CLONE_FLAT_FLAG = 2,
  16878. CLONE_SYMBOLS_FLAG = 4;
  16879. /** Used to compose bitmasks for value comparisons. */
  16880. var COMPARE_PARTIAL_FLAG = 1,
  16881. COMPARE_UNORDERED_FLAG = 2;
  16882. /** Used to compose bitmasks for function metadata. */
  16883. var WRAP_BIND_FLAG = 1,
  16884. WRAP_BIND_KEY_FLAG = 2,
  16885. WRAP_CURRY_BOUND_FLAG = 4,
  16886. WRAP_CURRY_FLAG = 8,
  16887. WRAP_CURRY_RIGHT_FLAG = 16,
  16888. WRAP_PARTIAL_FLAG = 32,
  16889. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16890. WRAP_ARY_FLAG = 128,
  16891. WRAP_REARG_FLAG = 256,
  16892. WRAP_FLIP_FLAG = 512;
  16893. /** Used as default options for `_.truncate`. */
  16894. var DEFAULT_TRUNC_LENGTH = 30,
  16895. DEFAULT_TRUNC_OMISSION = '...';
  16896. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16897. var HOT_COUNT = 800,
  16898. HOT_SPAN = 16;
  16899. /** Used to indicate the type of lazy iteratees. */
  16900. var LAZY_FILTER_FLAG = 1,
  16901. LAZY_MAP_FLAG = 2,
  16902. LAZY_WHILE_FLAG = 3;
  16903. /** Used as references for various `Number` constants. */
  16904. var INFINITY = 1 / 0,
  16905. MAX_SAFE_INTEGER = 9007199254740991,
  16906. MAX_INTEGER = 1.7976931348623157e+308,
  16907. NAN = 0 / 0;
  16908. /** Used as references for the maximum length and index of an array. */
  16909. var MAX_ARRAY_LENGTH = 4294967295,
  16910. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16911. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16912. /** Used to associate wrap methods with their bit flags. */
  16913. var wrapFlags = [
  16914. ['ary', WRAP_ARY_FLAG],
  16915. ['bind', WRAP_BIND_FLAG],
  16916. ['bindKey', WRAP_BIND_KEY_FLAG],
  16917. ['curry', WRAP_CURRY_FLAG],
  16918. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16919. ['flip', WRAP_FLIP_FLAG],
  16920. ['partial', WRAP_PARTIAL_FLAG],
  16921. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16922. ['rearg', WRAP_REARG_FLAG]
  16923. ];
  16924. /** `Object#toString` result references. */
  16925. var argsTag = '[object Arguments]',
  16926. arrayTag = '[object Array]',
  16927. asyncTag = '[object AsyncFunction]',
  16928. boolTag = '[object Boolean]',
  16929. dateTag = '[object Date]',
  16930. domExcTag = '[object DOMException]',
  16931. errorTag = '[object Error]',
  16932. funcTag = '[object Function]',
  16933. genTag = '[object GeneratorFunction]',
  16934. mapTag = '[object Map]',
  16935. numberTag = '[object Number]',
  16936. nullTag = '[object Null]',
  16937. objectTag = '[object Object]',
  16938. promiseTag = '[object Promise]',
  16939. proxyTag = '[object Proxy]',
  16940. regexpTag = '[object RegExp]',
  16941. setTag = '[object Set]',
  16942. stringTag = '[object String]',
  16943. symbolTag = '[object Symbol]',
  16944. undefinedTag = '[object Undefined]',
  16945. weakMapTag = '[object WeakMap]',
  16946. weakSetTag = '[object WeakSet]';
  16947. var arrayBufferTag = '[object ArrayBuffer]',
  16948. dataViewTag = '[object DataView]',
  16949. float32Tag = '[object Float32Array]',
  16950. float64Tag = '[object Float64Array]',
  16951. int8Tag = '[object Int8Array]',
  16952. int16Tag = '[object Int16Array]',
  16953. int32Tag = '[object Int32Array]',
  16954. uint8Tag = '[object Uint8Array]',
  16955. uint8ClampedTag = '[object Uint8ClampedArray]',
  16956. uint16Tag = '[object Uint16Array]',
  16957. uint32Tag = '[object Uint32Array]';
  16958. /** Used to match empty string literals in compiled template source. */
  16959. var reEmptyStringLeading = /\b__p \+= '';/g,
  16960. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16961. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16962. /** Used to match HTML entities and HTML characters. */
  16963. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16964. reUnescapedHtml = /[&<>"']/g,
  16965. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  16966. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  16967. /** Used to match template delimiters. */
  16968. var reEscape = /<%-([\s\S]+?)%>/g,
  16969. reEvaluate = /<%([\s\S]+?)%>/g,
  16970. reInterpolate = /<%=([\s\S]+?)%>/g;
  16971. /** Used to match property names within property paths. */
  16972. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  16973. reIsPlainProp = /^\w*$/,
  16974. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  16975. /**
  16976. * Used to match `RegExp`
  16977. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  16978. */
  16979. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  16980. reHasRegExpChar = RegExp(reRegExpChar.source);
  16981. /** Used to match leading and trailing whitespace. */
  16982. var reTrim = /^\s+|\s+$/g,
  16983. reTrimStart = /^\s+/,
  16984. reTrimEnd = /\s+$/;
  16985. /** Used to match wrap detail comments. */
  16986. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  16987. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  16988. reSplitDetails = /,? & /;
  16989. /** Used to match words composed of alphanumeric characters. */
  16990. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  16991. /** Used to match backslashes in property paths. */
  16992. var reEscapeChar = /\\(\\)?/g;
  16993. /**
  16994. * Used to match
  16995. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  16996. */
  16997. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  16998. /** Used to match `RegExp` flags from their coerced string values. */
  16999. var reFlags = /\w*$/;
  17000. /** Used to detect bad signed hexadecimal string values. */
  17001. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17002. /** Used to detect binary string values. */
  17003. var reIsBinary = /^0b[01]+$/i;
  17004. /** Used to detect host constructors (Safari). */
  17005. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17006. /** Used to detect octal string values. */
  17007. var reIsOctal = /^0o[0-7]+$/i;
  17008. /** Used to detect unsigned integer values. */
  17009. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17010. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17011. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17012. /** Used to ensure capturing order of template delimiters. */
  17013. var reNoMatch = /($^)/;
  17014. /** Used to match unescaped characters in compiled string literals. */
  17015. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17016. /** Used to compose unicode character classes. */
  17017. var rsAstralRange = '\\ud800-\\udfff',
  17018. rsComboMarksRange = '\\u0300-\\u036f',
  17019. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17020. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17021. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17022. rsDingbatRange = '\\u2700-\\u27bf',
  17023. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17024. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17025. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17026. rsPunctuationRange = '\\u2000-\\u206f',
  17027. 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',
  17028. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17029. rsVarRange = '\\ufe0e\\ufe0f',
  17030. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17031. /** Used to compose unicode capture groups. */
  17032. var rsApos = "['\u2019]",
  17033. rsAstral = '[' + rsAstralRange + ']',
  17034. rsBreak = '[' + rsBreakRange + ']',
  17035. rsCombo = '[' + rsComboRange + ']',
  17036. rsDigits = '\\d+',
  17037. rsDingbat = '[' + rsDingbatRange + ']',
  17038. rsLower = '[' + rsLowerRange + ']',
  17039. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17040. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17041. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17042. rsNonAstral = '[^' + rsAstralRange + ']',
  17043. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17044. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17045. rsUpper = '[' + rsUpperRange + ']',
  17046. rsZWJ = '\\u200d';
  17047. /** Used to compose unicode regexes. */
  17048. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17049. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17050. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17051. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17052. reOptMod = rsModifier + '?',
  17053. rsOptVar = '[' + rsVarRange + ']?',
  17054. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17055. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17056. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17057. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17058. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17059. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17060. /** Used to match apostrophes. */
  17061. var reApos = RegExp(rsApos, 'g');
  17062. /**
  17063. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17064. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17065. */
  17066. var reComboMark = RegExp(rsCombo, 'g');
  17067. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17068. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17069. /** Used to match complex or compound words. */
  17070. var reUnicodeWord = RegExp([
  17071. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17072. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17073. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17074. rsUpper + '+' + rsOptContrUpper,
  17075. rsOrdUpper,
  17076. rsOrdLower,
  17077. rsDigits,
  17078. rsEmoji
  17079. ].join('|'), 'g');
  17080. /** 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/). */
  17081. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17082. /** Used to detect strings that need a more robust regexp to match words. */
  17083. 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 ]/;
  17084. /** Used to assign default `context` object properties. */
  17085. var contextProps = [
  17086. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17087. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17088. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17089. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17090. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17091. ];
  17092. /** Used to make template sourceURLs easier to identify. */
  17093. var templateCounter = -1;
  17094. /** Used to identify `toStringTag` values of typed arrays. */
  17095. var typedArrayTags = {};
  17096. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17097. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17098. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17099. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17100. typedArrayTags[uint32Tag] = true;
  17101. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17102. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17103. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17104. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17105. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17106. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17107. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17108. typedArrayTags[weakMapTag] = false;
  17109. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17110. var cloneableTags = {};
  17111. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17112. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17113. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17114. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17115. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17116. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17117. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17118. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17119. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17120. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17121. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17122. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17123. cloneableTags[weakMapTag] = false;
  17124. /** Used to map Latin Unicode letters to basic Latin letters. */
  17125. var deburredLetters = {
  17126. // Latin-1 Supplement block.
  17127. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17128. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17129. '\xc7': 'C', '\xe7': 'c',
  17130. '\xd0': 'D', '\xf0': 'd',
  17131. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17132. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17133. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17134. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17135. '\xd1': 'N', '\xf1': 'n',
  17136. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17137. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17138. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17139. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17140. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17141. '\xc6': 'Ae', '\xe6': 'ae',
  17142. '\xde': 'Th', '\xfe': 'th',
  17143. '\xdf': 'ss',
  17144. // Latin Extended-A block.
  17145. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17146. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17147. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17148. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17149. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17150. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17151. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17152. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17153. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17154. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17155. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17156. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17157. '\u0134': 'J', '\u0135': 'j',
  17158. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17159. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17160. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17161. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17162. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17163. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17164. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17165. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17166. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17167. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17168. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17169. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17170. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17171. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17172. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17173. '\u0174': 'W', '\u0175': 'w',
  17174. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17175. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17176. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17177. '\u0132': 'IJ', '\u0133': 'ij',
  17178. '\u0152': 'Oe', '\u0153': 'oe',
  17179. '\u0149': "'n", '\u017f': 's'
  17180. };
  17181. /** Used to map characters to HTML entities. */
  17182. var htmlEscapes = {
  17183. '&': '&amp;',
  17184. '<': '&lt;',
  17185. '>': '&gt;',
  17186. '"': '&quot;',
  17187. "'": '&#39;'
  17188. };
  17189. /** Used to map HTML entities to characters. */
  17190. var htmlUnescapes = {
  17191. '&amp;': '&',
  17192. '&lt;': '<',
  17193. '&gt;': '>',
  17194. '&quot;': '"',
  17195. '&#39;': "'"
  17196. };
  17197. /** Used to escape characters for inclusion in compiled string literals. */
  17198. var stringEscapes = {
  17199. '\\': '\\',
  17200. "'": "'",
  17201. '\n': 'n',
  17202. '\r': 'r',
  17203. '\u2028': 'u2028',
  17204. '\u2029': 'u2029'
  17205. };
  17206. /** Built-in method references without a dependency on `root`. */
  17207. var freeParseFloat = parseFloat,
  17208. freeParseInt = parseInt;
  17209. /** Detect free variable `global` from Node.js. */
  17210. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17211. /** Detect free variable `self`. */
  17212. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17213. /** Used as a reference to the global object. */
  17214. var root = freeGlobal || freeSelf || Function('return this')();
  17215. /** Detect free variable `exports`. */
  17216. var freeExports = true && exports && !exports.nodeType && exports;
  17217. /** Detect free variable `module`. */
  17218. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17219. /** Detect the popular CommonJS extension `module.exports`. */
  17220. var moduleExports = freeModule && freeModule.exports === freeExports;
  17221. /** Detect free variable `process` from Node.js. */
  17222. var freeProcess = moduleExports && freeGlobal.process;
  17223. /** Used to access faster Node.js helpers. */
  17224. var nodeUtil = (function() {
  17225. try {
  17226. // Use `util.types` for Node.js 10+.
  17227. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17228. if (types) {
  17229. return types;
  17230. }
  17231. // Legacy `process.binding('util')` for Node.js < 10.
  17232. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17233. } catch (e) {}
  17234. }());
  17235. /* Node.js helper references. */
  17236. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17237. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17238. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17239. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17240. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17241. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17242. /*--------------------------------------------------------------------------*/
  17243. /**
  17244. * A faster alternative to `Function#apply`, this function invokes `func`
  17245. * with the `this` binding of `thisArg` and the arguments of `args`.
  17246. *
  17247. * @private
  17248. * @param {Function} func The function to invoke.
  17249. * @param {*} thisArg The `this` binding of `func`.
  17250. * @param {Array} args The arguments to invoke `func` with.
  17251. * @returns {*} Returns the result of `func`.
  17252. */
  17253. function apply(func, thisArg, args) {
  17254. switch (args.length) {
  17255. case 0: return func.call(thisArg);
  17256. case 1: return func.call(thisArg, args[0]);
  17257. case 2: return func.call(thisArg, args[0], args[1]);
  17258. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17259. }
  17260. return func.apply(thisArg, args);
  17261. }
  17262. /**
  17263. * A specialized version of `baseAggregator` for arrays.
  17264. *
  17265. * @private
  17266. * @param {Array} [array] The array to iterate over.
  17267. * @param {Function} setter The function to set `accumulator` values.
  17268. * @param {Function} iteratee The iteratee to transform keys.
  17269. * @param {Object} accumulator The initial aggregated object.
  17270. * @returns {Function} Returns `accumulator`.
  17271. */
  17272. function arrayAggregator(array, setter, iteratee, accumulator) {
  17273. var index = -1,
  17274. length = array == null ? 0 : array.length;
  17275. while (++index < length) {
  17276. var value = array[index];
  17277. setter(accumulator, value, iteratee(value), array);
  17278. }
  17279. return accumulator;
  17280. }
  17281. /**
  17282. * A specialized version of `_.forEach` for arrays without support for
  17283. * iteratee shorthands.
  17284. *
  17285. * @private
  17286. * @param {Array} [array] The array to iterate over.
  17287. * @param {Function} iteratee The function invoked per iteration.
  17288. * @returns {Array} Returns `array`.
  17289. */
  17290. function arrayEach(array, iteratee) {
  17291. var index = -1,
  17292. length = array == null ? 0 : array.length;
  17293. while (++index < length) {
  17294. if (iteratee(array[index], index, array) === false) {
  17295. break;
  17296. }
  17297. }
  17298. return array;
  17299. }
  17300. /**
  17301. * A specialized version of `_.forEachRight` for arrays without support for
  17302. * iteratee shorthands.
  17303. *
  17304. * @private
  17305. * @param {Array} [array] The array to iterate over.
  17306. * @param {Function} iteratee The function invoked per iteration.
  17307. * @returns {Array} Returns `array`.
  17308. */
  17309. function arrayEachRight(array, iteratee) {
  17310. var length = array == null ? 0 : array.length;
  17311. while (length--) {
  17312. if (iteratee(array[length], length, array) === false) {
  17313. break;
  17314. }
  17315. }
  17316. return array;
  17317. }
  17318. /**
  17319. * A specialized version of `_.every` for arrays without support for
  17320. * iteratee shorthands.
  17321. *
  17322. * @private
  17323. * @param {Array} [array] The array to iterate over.
  17324. * @param {Function} predicate The function invoked per iteration.
  17325. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17326. * else `false`.
  17327. */
  17328. function arrayEvery(array, predicate) {
  17329. var index = -1,
  17330. length = array == null ? 0 : array.length;
  17331. while (++index < length) {
  17332. if (!predicate(array[index], index, array)) {
  17333. return false;
  17334. }
  17335. }
  17336. return true;
  17337. }
  17338. /**
  17339. * A specialized version of `_.filter` for arrays without support for
  17340. * iteratee shorthands.
  17341. *
  17342. * @private
  17343. * @param {Array} [array] The array to iterate over.
  17344. * @param {Function} predicate The function invoked per iteration.
  17345. * @returns {Array} Returns the new filtered array.
  17346. */
  17347. function arrayFilter(array, predicate) {
  17348. var index = -1,
  17349. length = array == null ? 0 : array.length,
  17350. resIndex = 0,
  17351. result = [];
  17352. while (++index < length) {
  17353. var value = array[index];
  17354. if (predicate(value, index, array)) {
  17355. result[resIndex++] = value;
  17356. }
  17357. }
  17358. return result;
  17359. }
  17360. /**
  17361. * A specialized version of `_.includes` for arrays without support for
  17362. * specifying an index to search from.
  17363. *
  17364. * @private
  17365. * @param {Array} [array] The array to inspect.
  17366. * @param {*} target The value to search for.
  17367. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17368. */
  17369. function arrayIncludes(array, value) {
  17370. var length = array == null ? 0 : array.length;
  17371. return !!length && baseIndexOf(array, value, 0) > -1;
  17372. }
  17373. /**
  17374. * This function is like `arrayIncludes` except that it accepts a comparator.
  17375. *
  17376. * @private
  17377. * @param {Array} [array] The array to inspect.
  17378. * @param {*} target The value to search for.
  17379. * @param {Function} comparator The comparator invoked per element.
  17380. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17381. */
  17382. function arrayIncludesWith(array, value, comparator) {
  17383. var index = -1,
  17384. length = array == null ? 0 : array.length;
  17385. while (++index < length) {
  17386. if (comparator(value, array[index])) {
  17387. return true;
  17388. }
  17389. }
  17390. return false;
  17391. }
  17392. /**
  17393. * A specialized version of `_.map` for arrays without support for iteratee
  17394. * shorthands.
  17395. *
  17396. * @private
  17397. * @param {Array} [array] The array to iterate over.
  17398. * @param {Function} iteratee The function invoked per iteration.
  17399. * @returns {Array} Returns the new mapped array.
  17400. */
  17401. function arrayMap(array, iteratee) {
  17402. var index = -1,
  17403. length = array == null ? 0 : array.length,
  17404. result = Array(length);
  17405. while (++index < length) {
  17406. result[index] = iteratee(array[index], index, array);
  17407. }
  17408. return result;
  17409. }
  17410. /**
  17411. * Appends the elements of `values` to `array`.
  17412. *
  17413. * @private
  17414. * @param {Array} array The array to modify.
  17415. * @param {Array} values The values to append.
  17416. * @returns {Array} Returns `array`.
  17417. */
  17418. function arrayPush(array, values) {
  17419. var index = -1,
  17420. length = values.length,
  17421. offset = array.length;
  17422. while (++index < length) {
  17423. array[offset + index] = values[index];
  17424. }
  17425. return array;
  17426. }
  17427. /**
  17428. * A specialized version of `_.reduce` for arrays without support for
  17429. * iteratee shorthands.
  17430. *
  17431. * @private
  17432. * @param {Array} [array] The array to iterate over.
  17433. * @param {Function} iteratee The function invoked per iteration.
  17434. * @param {*} [accumulator] The initial value.
  17435. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17436. * the initial value.
  17437. * @returns {*} Returns the accumulated value.
  17438. */
  17439. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17440. var index = -1,
  17441. length = array == null ? 0 : array.length;
  17442. if (initAccum && length) {
  17443. accumulator = array[++index];
  17444. }
  17445. while (++index < length) {
  17446. accumulator = iteratee(accumulator, array[index], index, array);
  17447. }
  17448. return accumulator;
  17449. }
  17450. /**
  17451. * A specialized version of `_.reduceRight` for arrays without support for
  17452. * iteratee shorthands.
  17453. *
  17454. * @private
  17455. * @param {Array} [array] The array to iterate over.
  17456. * @param {Function} iteratee The function invoked per iteration.
  17457. * @param {*} [accumulator] The initial value.
  17458. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17459. * the initial value.
  17460. * @returns {*} Returns the accumulated value.
  17461. */
  17462. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17463. var length = array == null ? 0 : array.length;
  17464. if (initAccum && length) {
  17465. accumulator = array[--length];
  17466. }
  17467. while (length--) {
  17468. accumulator = iteratee(accumulator, array[length], length, array);
  17469. }
  17470. return accumulator;
  17471. }
  17472. /**
  17473. * A specialized version of `_.some` for arrays without support for iteratee
  17474. * shorthands.
  17475. *
  17476. * @private
  17477. * @param {Array} [array] The array to iterate over.
  17478. * @param {Function} predicate The function invoked per iteration.
  17479. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17480. * else `false`.
  17481. */
  17482. function arraySome(array, predicate) {
  17483. var index = -1,
  17484. length = array == null ? 0 : array.length;
  17485. while (++index < length) {
  17486. if (predicate(array[index], index, array)) {
  17487. return true;
  17488. }
  17489. }
  17490. return false;
  17491. }
  17492. /**
  17493. * Gets the size of an ASCII `string`.
  17494. *
  17495. * @private
  17496. * @param {string} string The string inspect.
  17497. * @returns {number} Returns the string size.
  17498. */
  17499. var asciiSize = baseProperty('length');
  17500. /**
  17501. * Converts an ASCII `string` to an array.
  17502. *
  17503. * @private
  17504. * @param {string} string The string to convert.
  17505. * @returns {Array} Returns the converted array.
  17506. */
  17507. function asciiToArray(string) {
  17508. return string.split('');
  17509. }
  17510. /**
  17511. * Splits an ASCII `string` into an array of its words.
  17512. *
  17513. * @private
  17514. * @param {string} The string to inspect.
  17515. * @returns {Array} Returns the words of `string`.
  17516. */
  17517. function asciiWords(string) {
  17518. return string.match(reAsciiWord) || [];
  17519. }
  17520. /**
  17521. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17522. * without support for iteratee shorthands, which iterates over `collection`
  17523. * using `eachFunc`.
  17524. *
  17525. * @private
  17526. * @param {Array|Object} collection The collection to inspect.
  17527. * @param {Function} predicate The function invoked per iteration.
  17528. * @param {Function} eachFunc The function to iterate over `collection`.
  17529. * @returns {*} Returns the found element or its key, else `undefined`.
  17530. */
  17531. function baseFindKey(collection, predicate, eachFunc) {
  17532. var result;
  17533. eachFunc(collection, function(value, key, collection) {
  17534. if (predicate(value, key, collection)) {
  17535. result = key;
  17536. return false;
  17537. }
  17538. });
  17539. return result;
  17540. }
  17541. /**
  17542. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17543. * support for iteratee shorthands.
  17544. *
  17545. * @private
  17546. * @param {Array} array The array to inspect.
  17547. * @param {Function} predicate The function invoked per iteration.
  17548. * @param {number} fromIndex The index to search from.
  17549. * @param {boolean} [fromRight] Specify iterating from right to left.
  17550. * @returns {number} Returns the index of the matched value, else `-1`.
  17551. */
  17552. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17553. var length = array.length,
  17554. index = fromIndex + (fromRight ? 1 : -1);
  17555. while ((fromRight ? index-- : ++index < length)) {
  17556. if (predicate(array[index], index, array)) {
  17557. return index;
  17558. }
  17559. }
  17560. return -1;
  17561. }
  17562. /**
  17563. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17564. *
  17565. * @private
  17566. * @param {Array} array The array to inspect.
  17567. * @param {*} value The value to search for.
  17568. * @param {number} fromIndex The index to search from.
  17569. * @returns {number} Returns the index of the matched value, else `-1`.
  17570. */
  17571. function baseIndexOf(array, value, fromIndex) {
  17572. return value === value
  17573. ? strictIndexOf(array, value, fromIndex)
  17574. : baseFindIndex(array, baseIsNaN, fromIndex);
  17575. }
  17576. /**
  17577. * This function is like `baseIndexOf` except that it accepts a comparator.
  17578. *
  17579. * @private
  17580. * @param {Array} array The array to inspect.
  17581. * @param {*} value The value to search for.
  17582. * @param {number} fromIndex The index to search from.
  17583. * @param {Function} comparator The comparator invoked per element.
  17584. * @returns {number} Returns the index of the matched value, else `-1`.
  17585. */
  17586. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17587. var index = fromIndex - 1,
  17588. length = array.length;
  17589. while (++index < length) {
  17590. if (comparator(array[index], value)) {
  17591. return index;
  17592. }
  17593. }
  17594. return -1;
  17595. }
  17596. /**
  17597. * The base implementation of `_.isNaN` without support for number objects.
  17598. *
  17599. * @private
  17600. * @param {*} value The value to check.
  17601. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17602. */
  17603. function baseIsNaN(value) {
  17604. return value !== value;
  17605. }
  17606. /**
  17607. * The base implementation of `_.mean` and `_.meanBy` without support for
  17608. * iteratee shorthands.
  17609. *
  17610. * @private
  17611. * @param {Array} array The array to iterate over.
  17612. * @param {Function} iteratee The function invoked per iteration.
  17613. * @returns {number} Returns the mean.
  17614. */
  17615. function baseMean(array, iteratee) {
  17616. var length = array == null ? 0 : array.length;
  17617. return length ? (baseSum(array, iteratee) / length) : NAN;
  17618. }
  17619. /**
  17620. * The base implementation of `_.property` without support for deep paths.
  17621. *
  17622. * @private
  17623. * @param {string} key The key of the property to get.
  17624. * @returns {Function} Returns the new accessor function.
  17625. */
  17626. function baseProperty(key) {
  17627. return function(object) {
  17628. return object == null ? undefined : object[key];
  17629. };
  17630. }
  17631. /**
  17632. * The base implementation of `_.propertyOf` without support for deep paths.
  17633. *
  17634. * @private
  17635. * @param {Object} object The object to query.
  17636. * @returns {Function} Returns the new accessor function.
  17637. */
  17638. function basePropertyOf(object) {
  17639. return function(key) {
  17640. return object == null ? undefined : object[key];
  17641. };
  17642. }
  17643. /**
  17644. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17645. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17646. *
  17647. * @private
  17648. * @param {Array|Object} collection The collection to iterate over.
  17649. * @param {Function} iteratee The function invoked per iteration.
  17650. * @param {*} accumulator The initial value.
  17651. * @param {boolean} initAccum Specify using the first or last element of
  17652. * `collection` as the initial value.
  17653. * @param {Function} eachFunc The function to iterate over `collection`.
  17654. * @returns {*} Returns the accumulated value.
  17655. */
  17656. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17657. eachFunc(collection, function(value, index, collection) {
  17658. accumulator = initAccum
  17659. ? (initAccum = false, value)
  17660. : iteratee(accumulator, value, index, collection);
  17661. });
  17662. return accumulator;
  17663. }
  17664. /**
  17665. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17666. * sort order of `array` and replaces criteria objects with their corresponding
  17667. * values.
  17668. *
  17669. * @private
  17670. * @param {Array} array The array to sort.
  17671. * @param {Function} comparer The function to define sort order.
  17672. * @returns {Array} Returns `array`.
  17673. */
  17674. function baseSortBy(array, comparer) {
  17675. var length = array.length;
  17676. array.sort(comparer);
  17677. while (length--) {
  17678. array[length] = array[length].value;
  17679. }
  17680. return array;
  17681. }
  17682. /**
  17683. * The base implementation of `_.sum` and `_.sumBy` without support for
  17684. * iteratee shorthands.
  17685. *
  17686. * @private
  17687. * @param {Array} array The array to iterate over.
  17688. * @param {Function} iteratee The function invoked per iteration.
  17689. * @returns {number} Returns the sum.
  17690. */
  17691. function baseSum(array, iteratee) {
  17692. var result,
  17693. index = -1,
  17694. length = array.length;
  17695. while (++index < length) {
  17696. var current = iteratee(array[index]);
  17697. if (current !== undefined) {
  17698. result = result === undefined ? current : (result + current);
  17699. }
  17700. }
  17701. return result;
  17702. }
  17703. /**
  17704. * The base implementation of `_.times` without support for iteratee shorthands
  17705. * or max array length checks.
  17706. *
  17707. * @private
  17708. * @param {number} n The number of times to invoke `iteratee`.
  17709. * @param {Function} iteratee The function invoked per iteration.
  17710. * @returns {Array} Returns the array of results.
  17711. */
  17712. function baseTimes(n, iteratee) {
  17713. var index = -1,
  17714. result = Array(n);
  17715. while (++index < n) {
  17716. result[index] = iteratee(index);
  17717. }
  17718. return result;
  17719. }
  17720. /**
  17721. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17722. * of key-value pairs for `object` corresponding to the property names of `props`.
  17723. *
  17724. * @private
  17725. * @param {Object} object The object to query.
  17726. * @param {Array} props The property names to get values for.
  17727. * @returns {Object} Returns the key-value pairs.
  17728. */
  17729. function baseToPairs(object, props) {
  17730. return arrayMap(props, function(key) {
  17731. return [key, object[key]];
  17732. });
  17733. }
  17734. /**
  17735. * The base implementation of `_.unary` without support for storing metadata.
  17736. *
  17737. * @private
  17738. * @param {Function} func The function to cap arguments for.
  17739. * @returns {Function} Returns the new capped function.
  17740. */
  17741. function baseUnary(func) {
  17742. return function(value) {
  17743. return func(value);
  17744. };
  17745. }
  17746. /**
  17747. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17748. * array of `object` property values corresponding to the property names
  17749. * of `props`.
  17750. *
  17751. * @private
  17752. * @param {Object} object The object to query.
  17753. * @param {Array} props The property names to get values for.
  17754. * @returns {Object} Returns the array of property values.
  17755. */
  17756. function baseValues(object, props) {
  17757. return arrayMap(props, function(key) {
  17758. return object[key];
  17759. });
  17760. }
  17761. /**
  17762. * Checks if a `cache` value for `key` exists.
  17763. *
  17764. * @private
  17765. * @param {Object} cache The cache to query.
  17766. * @param {string} key The key of the entry to check.
  17767. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17768. */
  17769. function cacheHas(cache, key) {
  17770. return cache.has(key);
  17771. }
  17772. /**
  17773. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17774. * that is not found in the character symbols.
  17775. *
  17776. * @private
  17777. * @param {Array} strSymbols The string symbols to inspect.
  17778. * @param {Array} chrSymbols The character symbols to find.
  17779. * @returns {number} Returns the index of the first unmatched string symbol.
  17780. */
  17781. function charsStartIndex(strSymbols, chrSymbols) {
  17782. var index = -1,
  17783. length = strSymbols.length;
  17784. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17785. return index;
  17786. }
  17787. /**
  17788. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17789. * that is not found in the character symbols.
  17790. *
  17791. * @private
  17792. * @param {Array} strSymbols The string symbols to inspect.
  17793. * @param {Array} chrSymbols The character symbols to find.
  17794. * @returns {number} Returns the index of the last unmatched string symbol.
  17795. */
  17796. function charsEndIndex(strSymbols, chrSymbols) {
  17797. var index = strSymbols.length;
  17798. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17799. return index;
  17800. }
  17801. /**
  17802. * Gets the number of `placeholder` occurrences in `array`.
  17803. *
  17804. * @private
  17805. * @param {Array} array The array to inspect.
  17806. * @param {*} placeholder The placeholder to search for.
  17807. * @returns {number} Returns the placeholder count.
  17808. */
  17809. function countHolders(array, placeholder) {
  17810. var length = array.length,
  17811. result = 0;
  17812. while (length--) {
  17813. if (array[length] === placeholder) {
  17814. ++result;
  17815. }
  17816. }
  17817. return result;
  17818. }
  17819. /**
  17820. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17821. * letters to basic Latin letters.
  17822. *
  17823. * @private
  17824. * @param {string} letter The matched letter to deburr.
  17825. * @returns {string} Returns the deburred letter.
  17826. */
  17827. var deburrLetter = basePropertyOf(deburredLetters);
  17828. /**
  17829. * Used by `_.escape` to convert characters to HTML entities.
  17830. *
  17831. * @private
  17832. * @param {string} chr The matched character to escape.
  17833. * @returns {string} Returns the escaped character.
  17834. */
  17835. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17836. /**
  17837. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17838. *
  17839. * @private
  17840. * @param {string} chr The matched character to escape.
  17841. * @returns {string} Returns the escaped character.
  17842. */
  17843. function escapeStringChar(chr) {
  17844. return '\\' + stringEscapes[chr];
  17845. }
  17846. /**
  17847. * Gets the value at `key` of `object`.
  17848. *
  17849. * @private
  17850. * @param {Object} [object] The object to query.
  17851. * @param {string} key The key of the property to get.
  17852. * @returns {*} Returns the property value.
  17853. */
  17854. function getValue(object, key) {
  17855. return object == null ? undefined : object[key];
  17856. }
  17857. /**
  17858. * Checks if `string` contains Unicode symbols.
  17859. *
  17860. * @private
  17861. * @param {string} string The string to inspect.
  17862. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17863. */
  17864. function hasUnicode(string) {
  17865. return reHasUnicode.test(string);
  17866. }
  17867. /**
  17868. * Checks if `string` contains a word composed of Unicode symbols.
  17869. *
  17870. * @private
  17871. * @param {string} string The string to inspect.
  17872. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17873. */
  17874. function hasUnicodeWord(string) {
  17875. return reHasUnicodeWord.test(string);
  17876. }
  17877. /**
  17878. * Converts `iterator` to an array.
  17879. *
  17880. * @private
  17881. * @param {Object} iterator The iterator to convert.
  17882. * @returns {Array} Returns the converted array.
  17883. */
  17884. function iteratorToArray(iterator) {
  17885. var data,
  17886. result = [];
  17887. while (!(data = iterator.next()).done) {
  17888. result.push(data.value);
  17889. }
  17890. return result;
  17891. }
  17892. /**
  17893. * Converts `map` to its key-value pairs.
  17894. *
  17895. * @private
  17896. * @param {Object} map The map to convert.
  17897. * @returns {Array} Returns the key-value pairs.
  17898. */
  17899. function mapToArray(map) {
  17900. var index = -1,
  17901. result = Array(map.size);
  17902. map.forEach(function(value, key) {
  17903. result[++index] = [key, value];
  17904. });
  17905. return result;
  17906. }
  17907. /**
  17908. * Creates a unary function that invokes `func` with its argument transformed.
  17909. *
  17910. * @private
  17911. * @param {Function} func The function to wrap.
  17912. * @param {Function} transform The argument transform.
  17913. * @returns {Function} Returns the new function.
  17914. */
  17915. function overArg(func, transform) {
  17916. return function(arg) {
  17917. return func(transform(arg));
  17918. };
  17919. }
  17920. /**
  17921. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17922. * and returns an array of their indexes.
  17923. *
  17924. * @private
  17925. * @param {Array} array The array to modify.
  17926. * @param {*} placeholder The placeholder to replace.
  17927. * @returns {Array} Returns the new array of placeholder indexes.
  17928. */
  17929. function replaceHolders(array, placeholder) {
  17930. var index = -1,
  17931. length = array.length,
  17932. resIndex = 0,
  17933. result = [];
  17934. while (++index < length) {
  17935. var value = array[index];
  17936. if (value === placeholder || value === PLACEHOLDER) {
  17937. array[index] = PLACEHOLDER;
  17938. result[resIndex++] = index;
  17939. }
  17940. }
  17941. return result;
  17942. }
  17943. /**
  17944. * Converts `set` to an array of its values.
  17945. *
  17946. * @private
  17947. * @param {Object} set The set to convert.
  17948. * @returns {Array} Returns the values.
  17949. */
  17950. function setToArray(set) {
  17951. var index = -1,
  17952. result = Array(set.size);
  17953. set.forEach(function(value) {
  17954. result[++index] = value;
  17955. });
  17956. return result;
  17957. }
  17958. /**
  17959. * Converts `set` to its value-value pairs.
  17960. *
  17961. * @private
  17962. * @param {Object} set The set to convert.
  17963. * @returns {Array} Returns the value-value pairs.
  17964. */
  17965. function setToPairs(set) {
  17966. var index = -1,
  17967. result = Array(set.size);
  17968. set.forEach(function(value) {
  17969. result[++index] = [value, value];
  17970. });
  17971. return result;
  17972. }
  17973. /**
  17974. * A specialized version of `_.indexOf` which performs strict equality
  17975. * comparisons of values, i.e. `===`.
  17976. *
  17977. * @private
  17978. * @param {Array} array The array to inspect.
  17979. * @param {*} value The value to search for.
  17980. * @param {number} fromIndex The index to search from.
  17981. * @returns {number} Returns the index of the matched value, else `-1`.
  17982. */
  17983. function strictIndexOf(array, value, fromIndex) {
  17984. var index = fromIndex - 1,
  17985. length = array.length;
  17986. while (++index < length) {
  17987. if (array[index] === value) {
  17988. return index;
  17989. }
  17990. }
  17991. return -1;
  17992. }
  17993. /**
  17994. * A specialized version of `_.lastIndexOf` which performs strict equality
  17995. * comparisons of values, i.e. `===`.
  17996. *
  17997. * @private
  17998. * @param {Array} array The array to inspect.
  17999. * @param {*} value The value to search for.
  18000. * @param {number} fromIndex The index to search from.
  18001. * @returns {number} Returns the index of the matched value, else `-1`.
  18002. */
  18003. function strictLastIndexOf(array, value, fromIndex) {
  18004. var index = fromIndex + 1;
  18005. while (index--) {
  18006. if (array[index] === value) {
  18007. return index;
  18008. }
  18009. }
  18010. return index;
  18011. }
  18012. /**
  18013. * Gets the number of symbols in `string`.
  18014. *
  18015. * @private
  18016. * @param {string} string The string to inspect.
  18017. * @returns {number} Returns the string size.
  18018. */
  18019. function stringSize(string) {
  18020. return hasUnicode(string)
  18021. ? unicodeSize(string)
  18022. : asciiSize(string);
  18023. }
  18024. /**
  18025. * Converts `string` to an array.
  18026. *
  18027. * @private
  18028. * @param {string} string The string to convert.
  18029. * @returns {Array} Returns the converted array.
  18030. */
  18031. function stringToArray(string) {
  18032. return hasUnicode(string)
  18033. ? unicodeToArray(string)
  18034. : asciiToArray(string);
  18035. }
  18036. /**
  18037. * Used by `_.unescape` to convert HTML entities to characters.
  18038. *
  18039. * @private
  18040. * @param {string} chr The matched character to unescape.
  18041. * @returns {string} Returns the unescaped character.
  18042. */
  18043. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18044. /**
  18045. * Gets the size of a Unicode `string`.
  18046. *
  18047. * @private
  18048. * @param {string} string The string inspect.
  18049. * @returns {number} Returns the string size.
  18050. */
  18051. function unicodeSize(string) {
  18052. var result = reUnicode.lastIndex = 0;
  18053. while (reUnicode.test(string)) {
  18054. ++result;
  18055. }
  18056. return result;
  18057. }
  18058. /**
  18059. * Converts a Unicode `string` to an array.
  18060. *
  18061. * @private
  18062. * @param {string} string The string to convert.
  18063. * @returns {Array} Returns the converted array.
  18064. */
  18065. function unicodeToArray(string) {
  18066. return string.match(reUnicode) || [];
  18067. }
  18068. /**
  18069. * Splits a Unicode `string` into an array of its words.
  18070. *
  18071. * @private
  18072. * @param {string} The string to inspect.
  18073. * @returns {Array} Returns the words of `string`.
  18074. */
  18075. function unicodeWords(string) {
  18076. return string.match(reUnicodeWord) || [];
  18077. }
  18078. /*--------------------------------------------------------------------------*/
  18079. /**
  18080. * Create a new pristine `lodash` function using the `context` object.
  18081. *
  18082. * @static
  18083. * @memberOf _
  18084. * @since 1.1.0
  18085. * @category Util
  18086. * @param {Object} [context=root] The context object.
  18087. * @returns {Function} Returns a new `lodash` function.
  18088. * @example
  18089. *
  18090. * _.mixin({ 'foo': _.constant('foo') });
  18091. *
  18092. * var lodash = _.runInContext();
  18093. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18094. *
  18095. * _.isFunction(_.foo);
  18096. * // => true
  18097. * _.isFunction(_.bar);
  18098. * // => false
  18099. *
  18100. * lodash.isFunction(lodash.foo);
  18101. * // => false
  18102. * lodash.isFunction(lodash.bar);
  18103. * // => true
  18104. *
  18105. * // Create a suped-up `defer` in Node.js.
  18106. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18107. */
  18108. var runInContext = (function runInContext(context) {
  18109. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18110. /** Built-in constructor references. */
  18111. var Array = context.Array,
  18112. Date = context.Date,
  18113. Error = context.Error,
  18114. Function = context.Function,
  18115. Math = context.Math,
  18116. Object = context.Object,
  18117. RegExp = context.RegExp,
  18118. String = context.String,
  18119. TypeError = context.TypeError;
  18120. /** Used for built-in method references. */
  18121. var arrayProto = Array.prototype,
  18122. funcProto = Function.prototype,
  18123. objectProto = Object.prototype;
  18124. /** Used to detect overreaching core-js shims. */
  18125. var coreJsData = context['__core-js_shared__'];
  18126. /** Used to resolve the decompiled source of functions. */
  18127. var funcToString = funcProto.toString;
  18128. /** Used to check objects for own properties. */
  18129. var hasOwnProperty = objectProto.hasOwnProperty;
  18130. /** Used to generate unique IDs. */
  18131. var idCounter = 0;
  18132. /** Used to detect methods masquerading as native. */
  18133. var maskSrcKey = (function() {
  18134. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18135. return uid ? ('Symbol(src)_1.' + uid) : '';
  18136. }());
  18137. /**
  18138. * Used to resolve the
  18139. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18140. * of values.
  18141. */
  18142. var nativeObjectToString = objectProto.toString;
  18143. /** Used to infer the `Object` constructor. */
  18144. var objectCtorString = funcToString.call(Object);
  18145. /** Used to restore the original `_` reference in `_.noConflict`. */
  18146. var oldDash = root._;
  18147. /** Used to detect if a method is native. */
  18148. var reIsNative = RegExp('^' +
  18149. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18150. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18151. );
  18152. /** Built-in value references. */
  18153. var Buffer = moduleExports ? context.Buffer : undefined,
  18154. Symbol = context.Symbol,
  18155. Uint8Array = context.Uint8Array,
  18156. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18157. getPrototype = overArg(Object.getPrototypeOf, Object),
  18158. objectCreate = Object.create,
  18159. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18160. splice = arrayProto.splice,
  18161. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18162. symIterator = Symbol ? Symbol.iterator : undefined,
  18163. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18164. var defineProperty = (function() {
  18165. try {
  18166. var func = getNative(Object, 'defineProperty');
  18167. func({}, '', {});
  18168. return func;
  18169. } catch (e) {}
  18170. }());
  18171. /** Mocked built-ins. */
  18172. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18173. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18174. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18175. /* Built-in method references for those with the same name as other `lodash` methods. */
  18176. var nativeCeil = Math.ceil,
  18177. nativeFloor = Math.floor,
  18178. nativeGetSymbols = Object.getOwnPropertySymbols,
  18179. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18180. nativeIsFinite = context.isFinite,
  18181. nativeJoin = arrayProto.join,
  18182. nativeKeys = overArg(Object.keys, Object),
  18183. nativeMax = Math.max,
  18184. nativeMin = Math.min,
  18185. nativeNow = Date.now,
  18186. nativeParseInt = context.parseInt,
  18187. nativeRandom = Math.random,
  18188. nativeReverse = arrayProto.reverse;
  18189. /* Built-in method references that are verified to be native. */
  18190. var DataView = getNative(context, 'DataView'),
  18191. Map = getNative(context, 'Map'),
  18192. Promise = getNative(context, 'Promise'),
  18193. Set = getNative(context, 'Set'),
  18194. WeakMap = getNative(context, 'WeakMap'),
  18195. nativeCreate = getNative(Object, 'create');
  18196. /** Used to store function metadata. */
  18197. var metaMap = WeakMap && new WeakMap;
  18198. /** Used to lookup unminified function names. */
  18199. var realNames = {};
  18200. /** Used to detect maps, sets, and weakmaps. */
  18201. var dataViewCtorString = toSource(DataView),
  18202. mapCtorString = toSource(Map),
  18203. promiseCtorString = toSource(Promise),
  18204. setCtorString = toSource(Set),
  18205. weakMapCtorString = toSource(WeakMap);
  18206. /** Used to convert symbols to primitives and strings. */
  18207. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18208. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18209. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18210. /*------------------------------------------------------------------------*/
  18211. /**
  18212. * Creates a `lodash` object which wraps `value` to enable implicit method
  18213. * chain sequences. Methods that operate on and return arrays, collections,
  18214. * and functions can be chained together. Methods that retrieve a single value
  18215. * or may return a primitive value will automatically end the chain sequence
  18216. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18217. * with `_#value`.
  18218. *
  18219. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18220. * enabled using `_.chain`.
  18221. *
  18222. * The execution of chained methods is lazy, that is, it's deferred until
  18223. * `_#value` is implicitly or explicitly called.
  18224. *
  18225. * Lazy evaluation allows several methods to support shortcut fusion.
  18226. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18227. * the creation of intermediate arrays and can greatly reduce the number of
  18228. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18229. * fusion if the section is applied to an array and iteratees accept only
  18230. * one argument. The heuristic for whether a section qualifies for shortcut
  18231. * fusion is subject to change.
  18232. *
  18233. * Chaining is supported in custom builds as long as the `_#value` method is
  18234. * directly or indirectly included in the build.
  18235. *
  18236. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18237. *
  18238. * The wrapper `Array` methods are:
  18239. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18240. *
  18241. * The wrapper `String` methods are:
  18242. * `replace` and `split`
  18243. *
  18244. * The wrapper methods that support shortcut fusion are:
  18245. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18246. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18247. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18248. *
  18249. * The chainable wrapper methods are:
  18250. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18251. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18252. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18253. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18254. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18255. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18256. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18257. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18258. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18259. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18260. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18261. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18262. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18263. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18264. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18265. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18266. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18267. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18268. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18269. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18270. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18271. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18272. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18273. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18274. *
  18275. * The wrapper methods that are **not** chainable by default are:
  18276. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18277. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18278. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18279. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18280. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18281. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18282. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18283. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18284. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18285. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18286. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18287. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18288. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18289. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18290. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18291. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18292. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18293. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18294. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18295. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18296. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18297. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18298. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18299. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18300. * `upperFirst`, `value`, and `words`
  18301. *
  18302. * @name _
  18303. * @constructor
  18304. * @category Seq
  18305. * @param {*} value The value to wrap in a `lodash` instance.
  18306. * @returns {Object} Returns the new `lodash` wrapper instance.
  18307. * @example
  18308. *
  18309. * function square(n) {
  18310. * return n * n;
  18311. * }
  18312. *
  18313. * var wrapped = _([1, 2, 3]);
  18314. *
  18315. * // Returns an unwrapped value.
  18316. * wrapped.reduce(_.add);
  18317. * // => 6
  18318. *
  18319. * // Returns a wrapped value.
  18320. * var squares = wrapped.map(square);
  18321. *
  18322. * _.isArray(squares);
  18323. * // => false
  18324. *
  18325. * _.isArray(squares.value());
  18326. * // => true
  18327. */
  18328. function lodash(value) {
  18329. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18330. if (value instanceof LodashWrapper) {
  18331. return value;
  18332. }
  18333. if (hasOwnProperty.call(value, '__wrapped__')) {
  18334. return wrapperClone(value);
  18335. }
  18336. }
  18337. return new LodashWrapper(value);
  18338. }
  18339. /**
  18340. * The base implementation of `_.create` without support for assigning
  18341. * properties to the created object.
  18342. *
  18343. * @private
  18344. * @param {Object} proto The object to inherit from.
  18345. * @returns {Object} Returns the new object.
  18346. */
  18347. var baseCreate = (function() {
  18348. function object() {}
  18349. return function(proto) {
  18350. if (!isObject(proto)) {
  18351. return {};
  18352. }
  18353. if (objectCreate) {
  18354. return objectCreate(proto);
  18355. }
  18356. object.prototype = proto;
  18357. var result = new object;
  18358. object.prototype = undefined;
  18359. return result;
  18360. };
  18361. }());
  18362. /**
  18363. * The function whose prototype chain sequence wrappers inherit from.
  18364. *
  18365. * @private
  18366. */
  18367. function baseLodash() {
  18368. // No operation performed.
  18369. }
  18370. /**
  18371. * The base constructor for creating `lodash` wrapper objects.
  18372. *
  18373. * @private
  18374. * @param {*} value The value to wrap.
  18375. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18376. */
  18377. function LodashWrapper(value, chainAll) {
  18378. this.__wrapped__ = value;
  18379. this.__actions__ = [];
  18380. this.__chain__ = !!chainAll;
  18381. this.__index__ = 0;
  18382. this.__values__ = undefined;
  18383. }
  18384. /**
  18385. * By default, the template delimiters used by lodash are like those in
  18386. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18387. * following template settings to use alternative delimiters.
  18388. *
  18389. * @static
  18390. * @memberOf _
  18391. * @type {Object}
  18392. */
  18393. lodash.templateSettings = {
  18394. /**
  18395. * Used to detect `data` property values to be HTML-escaped.
  18396. *
  18397. * @memberOf _.templateSettings
  18398. * @type {RegExp}
  18399. */
  18400. 'escape': reEscape,
  18401. /**
  18402. * Used to detect code to be evaluated.
  18403. *
  18404. * @memberOf _.templateSettings
  18405. * @type {RegExp}
  18406. */
  18407. 'evaluate': reEvaluate,
  18408. /**
  18409. * Used to detect `data` property values to inject.
  18410. *
  18411. * @memberOf _.templateSettings
  18412. * @type {RegExp}
  18413. */
  18414. 'interpolate': reInterpolate,
  18415. /**
  18416. * Used to reference the data object in the template text.
  18417. *
  18418. * @memberOf _.templateSettings
  18419. * @type {string}
  18420. */
  18421. 'variable': '',
  18422. /**
  18423. * Used to import variables into the compiled template.
  18424. *
  18425. * @memberOf _.templateSettings
  18426. * @type {Object}
  18427. */
  18428. 'imports': {
  18429. /**
  18430. * A reference to the `lodash` function.
  18431. *
  18432. * @memberOf _.templateSettings.imports
  18433. * @type {Function}
  18434. */
  18435. '_': lodash
  18436. }
  18437. };
  18438. // Ensure wrappers are instances of `baseLodash`.
  18439. lodash.prototype = baseLodash.prototype;
  18440. lodash.prototype.constructor = lodash;
  18441. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18442. LodashWrapper.prototype.constructor = LodashWrapper;
  18443. /*------------------------------------------------------------------------*/
  18444. /**
  18445. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18446. *
  18447. * @private
  18448. * @constructor
  18449. * @param {*} value The value to wrap.
  18450. */
  18451. function LazyWrapper(value) {
  18452. this.__wrapped__ = value;
  18453. this.__actions__ = [];
  18454. this.__dir__ = 1;
  18455. this.__filtered__ = false;
  18456. this.__iteratees__ = [];
  18457. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18458. this.__views__ = [];
  18459. }
  18460. /**
  18461. * Creates a clone of the lazy wrapper object.
  18462. *
  18463. * @private
  18464. * @name clone
  18465. * @memberOf LazyWrapper
  18466. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18467. */
  18468. function lazyClone() {
  18469. var result = new LazyWrapper(this.__wrapped__);
  18470. result.__actions__ = copyArray(this.__actions__);
  18471. result.__dir__ = this.__dir__;
  18472. result.__filtered__ = this.__filtered__;
  18473. result.__iteratees__ = copyArray(this.__iteratees__);
  18474. result.__takeCount__ = this.__takeCount__;
  18475. result.__views__ = copyArray(this.__views__);
  18476. return result;
  18477. }
  18478. /**
  18479. * Reverses the direction of lazy iteration.
  18480. *
  18481. * @private
  18482. * @name reverse
  18483. * @memberOf LazyWrapper
  18484. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18485. */
  18486. function lazyReverse() {
  18487. if (this.__filtered__) {
  18488. var result = new LazyWrapper(this);
  18489. result.__dir__ = -1;
  18490. result.__filtered__ = true;
  18491. } else {
  18492. result = this.clone();
  18493. result.__dir__ *= -1;
  18494. }
  18495. return result;
  18496. }
  18497. /**
  18498. * Extracts the unwrapped value from its lazy wrapper.
  18499. *
  18500. * @private
  18501. * @name value
  18502. * @memberOf LazyWrapper
  18503. * @returns {*} Returns the unwrapped value.
  18504. */
  18505. function lazyValue() {
  18506. var array = this.__wrapped__.value(),
  18507. dir = this.__dir__,
  18508. isArr = isArray(array),
  18509. isRight = dir < 0,
  18510. arrLength = isArr ? array.length : 0,
  18511. view = getView(0, arrLength, this.__views__),
  18512. start = view.start,
  18513. end = view.end,
  18514. length = end - start,
  18515. index = isRight ? end : (start - 1),
  18516. iteratees = this.__iteratees__,
  18517. iterLength = iteratees.length,
  18518. resIndex = 0,
  18519. takeCount = nativeMin(length, this.__takeCount__);
  18520. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18521. return baseWrapperValue(array, this.__actions__);
  18522. }
  18523. var result = [];
  18524. outer:
  18525. while (length-- && resIndex < takeCount) {
  18526. index += dir;
  18527. var iterIndex = -1,
  18528. value = array[index];
  18529. while (++iterIndex < iterLength) {
  18530. var data = iteratees[iterIndex],
  18531. iteratee = data.iteratee,
  18532. type = data.type,
  18533. computed = iteratee(value);
  18534. if (type == LAZY_MAP_FLAG) {
  18535. value = computed;
  18536. } else if (!computed) {
  18537. if (type == LAZY_FILTER_FLAG) {
  18538. continue outer;
  18539. } else {
  18540. break outer;
  18541. }
  18542. }
  18543. }
  18544. result[resIndex++] = value;
  18545. }
  18546. return result;
  18547. }
  18548. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18549. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18550. LazyWrapper.prototype.constructor = LazyWrapper;
  18551. /*------------------------------------------------------------------------*/
  18552. /**
  18553. * Creates a hash object.
  18554. *
  18555. * @private
  18556. * @constructor
  18557. * @param {Array} [entries] The key-value pairs to cache.
  18558. */
  18559. function Hash(entries) {
  18560. var index = -1,
  18561. length = entries == null ? 0 : entries.length;
  18562. this.clear();
  18563. while (++index < length) {
  18564. var entry = entries[index];
  18565. this.set(entry[0], entry[1]);
  18566. }
  18567. }
  18568. /**
  18569. * Removes all key-value entries from the hash.
  18570. *
  18571. * @private
  18572. * @name clear
  18573. * @memberOf Hash
  18574. */
  18575. function hashClear() {
  18576. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18577. this.size = 0;
  18578. }
  18579. /**
  18580. * Removes `key` and its value from the hash.
  18581. *
  18582. * @private
  18583. * @name delete
  18584. * @memberOf Hash
  18585. * @param {Object} hash The hash to modify.
  18586. * @param {string} key The key of the value to remove.
  18587. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18588. */
  18589. function hashDelete(key) {
  18590. var result = this.has(key) && delete this.__data__[key];
  18591. this.size -= result ? 1 : 0;
  18592. return result;
  18593. }
  18594. /**
  18595. * Gets the hash value for `key`.
  18596. *
  18597. * @private
  18598. * @name get
  18599. * @memberOf Hash
  18600. * @param {string} key The key of the value to get.
  18601. * @returns {*} Returns the entry value.
  18602. */
  18603. function hashGet(key) {
  18604. var data = this.__data__;
  18605. if (nativeCreate) {
  18606. var result = data[key];
  18607. return result === HASH_UNDEFINED ? undefined : result;
  18608. }
  18609. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18610. }
  18611. /**
  18612. * Checks if a hash value for `key` exists.
  18613. *
  18614. * @private
  18615. * @name has
  18616. * @memberOf Hash
  18617. * @param {string} key The key of the entry to check.
  18618. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18619. */
  18620. function hashHas(key) {
  18621. var data = this.__data__;
  18622. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18623. }
  18624. /**
  18625. * Sets the hash `key` to `value`.
  18626. *
  18627. * @private
  18628. * @name set
  18629. * @memberOf Hash
  18630. * @param {string} key The key of the value to set.
  18631. * @param {*} value The value to set.
  18632. * @returns {Object} Returns the hash instance.
  18633. */
  18634. function hashSet(key, value) {
  18635. var data = this.__data__;
  18636. this.size += this.has(key) ? 0 : 1;
  18637. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18638. return this;
  18639. }
  18640. // Add methods to `Hash`.
  18641. Hash.prototype.clear = hashClear;
  18642. Hash.prototype['delete'] = hashDelete;
  18643. Hash.prototype.get = hashGet;
  18644. Hash.prototype.has = hashHas;
  18645. Hash.prototype.set = hashSet;
  18646. /*------------------------------------------------------------------------*/
  18647. /**
  18648. * Creates an list cache object.
  18649. *
  18650. * @private
  18651. * @constructor
  18652. * @param {Array} [entries] The key-value pairs to cache.
  18653. */
  18654. function ListCache(entries) {
  18655. var index = -1,
  18656. length = entries == null ? 0 : entries.length;
  18657. this.clear();
  18658. while (++index < length) {
  18659. var entry = entries[index];
  18660. this.set(entry[0], entry[1]);
  18661. }
  18662. }
  18663. /**
  18664. * Removes all key-value entries from the list cache.
  18665. *
  18666. * @private
  18667. * @name clear
  18668. * @memberOf ListCache
  18669. */
  18670. function listCacheClear() {
  18671. this.__data__ = [];
  18672. this.size = 0;
  18673. }
  18674. /**
  18675. * Removes `key` and its value from the list cache.
  18676. *
  18677. * @private
  18678. * @name delete
  18679. * @memberOf ListCache
  18680. * @param {string} key The key of the value to remove.
  18681. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18682. */
  18683. function listCacheDelete(key) {
  18684. var data = this.__data__,
  18685. index = assocIndexOf(data, key);
  18686. if (index < 0) {
  18687. return false;
  18688. }
  18689. var lastIndex = data.length - 1;
  18690. if (index == lastIndex) {
  18691. data.pop();
  18692. } else {
  18693. splice.call(data, index, 1);
  18694. }
  18695. --this.size;
  18696. return true;
  18697. }
  18698. /**
  18699. * Gets the list cache value for `key`.
  18700. *
  18701. * @private
  18702. * @name get
  18703. * @memberOf ListCache
  18704. * @param {string} key The key of the value to get.
  18705. * @returns {*} Returns the entry value.
  18706. */
  18707. function listCacheGet(key) {
  18708. var data = this.__data__,
  18709. index = assocIndexOf(data, key);
  18710. return index < 0 ? undefined : data[index][1];
  18711. }
  18712. /**
  18713. * Checks if a list cache value for `key` exists.
  18714. *
  18715. * @private
  18716. * @name has
  18717. * @memberOf ListCache
  18718. * @param {string} key The key of the entry to check.
  18719. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18720. */
  18721. function listCacheHas(key) {
  18722. return assocIndexOf(this.__data__, key) > -1;
  18723. }
  18724. /**
  18725. * Sets the list cache `key` to `value`.
  18726. *
  18727. * @private
  18728. * @name set
  18729. * @memberOf ListCache
  18730. * @param {string} key The key of the value to set.
  18731. * @param {*} value The value to set.
  18732. * @returns {Object} Returns the list cache instance.
  18733. */
  18734. function listCacheSet(key, value) {
  18735. var data = this.__data__,
  18736. index = assocIndexOf(data, key);
  18737. if (index < 0) {
  18738. ++this.size;
  18739. data.push([key, value]);
  18740. } else {
  18741. data[index][1] = value;
  18742. }
  18743. return this;
  18744. }
  18745. // Add methods to `ListCache`.
  18746. ListCache.prototype.clear = listCacheClear;
  18747. ListCache.prototype['delete'] = listCacheDelete;
  18748. ListCache.prototype.get = listCacheGet;
  18749. ListCache.prototype.has = listCacheHas;
  18750. ListCache.prototype.set = listCacheSet;
  18751. /*------------------------------------------------------------------------*/
  18752. /**
  18753. * Creates a map cache object to store key-value pairs.
  18754. *
  18755. * @private
  18756. * @constructor
  18757. * @param {Array} [entries] The key-value pairs to cache.
  18758. */
  18759. function MapCache(entries) {
  18760. var index = -1,
  18761. length = entries == null ? 0 : entries.length;
  18762. this.clear();
  18763. while (++index < length) {
  18764. var entry = entries[index];
  18765. this.set(entry[0], entry[1]);
  18766. }
  18767. }
  18768. /**
  18769. * Removes all key-value entries from the map.
  18770. *
  18771. * @private
  18772. * @name clear
  18773. * @memberOf MapCache
  18774. */
  18775. function mapCacheClear() {
  18776. this.size = 0;
  18777. this.__data__ = {
  18778. 'hash': new Hash,
  18779. 'map': new (Map || ListCache),
  18780. 'string': new Hash
  18781. };
  18782. }
  18783. /**
  18784. * Removes `key` and its value from the map.
  18785. *
  18786. * @private
  18787. * @name delete
  18788. * @memberOf MapCache
  18789. * @param {string} key The key of the value to remove.
  18790. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18791. */
  18792. function mapCacheDelete(key) {
  18793. var result = getMapData(this, key)['delete'](key);
  18794. this.size -= result ? 1 : 0;
  18795. return result;
  18796. }
  18797. /**
  18798. * Gets the map value for `key`.
  18799. *
  18800. * @private
  18801. * @name get
  18802. * @memberOf MapCache
  18803. * @param {string} key The key of the value to get.
  18804. * @returns {*} Returns the entry value.
  18805. */
  18806. function mapCacheGet(key) {
  18807. return getMapData(this, key).get(key);
  18808. }
  18809. /**
  18810. * Checks if a map value for `key` exists.
  18811. *
  18812. * @private
  18813. * @name has
  18814. * @memberOf MapCache
  18815. * @param {string} key The key of the entry to check.
  18816. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18817. */
  18818. function mapCacheHas(key) {
  18819. return getMapData(this, key).has(key);
  18820. }
  18821. /**
  18822. * Sets the map `key` to `value`.
  18823. *
  18824. * @private
  18825. * @name set
  18826. * @memberOf MapCache
  18827. * @param {string} key The key of the value to set.
  18828. * @param {*} value The value to set.
  18829. * @returns {Object} Returns the map cache instance.
  18830. */
  18831. function mapCacheSet(key, value) {
  18832. var data = getMapData(this, key),
  18833. size = data.size;
  18834. data.set(key, value);
  18835. this.size += data.size == size ? 0 : 1;
  18836. return this;
  18837. }
  18838. // Add methods to `MapCache`.
  18839. MapCache.prototype.clear = mapCacheClear;
  18840. MapCache.prototype['delete'] = mapCacheDelete;
  18841. MapCache.prototype.get = mapCacheGet;
  18842. MapCache.prototype.has = mapCacheHas;
  18843. MapCache.prototype.set = mapCacheSet;
  18844. /*------------------------------------------------------------------------*/
  18845. /**
  18846. *
  18847. * Creates an array cache object to store unique values.
  18848. *
  18849. * @private
  18850. * @constructor
  18851. * @param {Array} [values] The values to cache.
  18852. */
  18853. function SetCache(values) {
  18854. var index = -1,
  18855. length = values == null ? 0 : values.length;
  18856. this.__data__ = new MapCache;
  18857. while (++index < length) {
  18858. this.add(values[index]);
  18859. }
  18860. }
  18861. /**
  18862. * Adds `value` to the array cache.
  18863. *
  18864. * @private
  18865. * @name add
  18866. * @memberOf SetCache
  18867. * @alias push
  18868. * @param {*} value The value to cache.
  18869. * @returns {Object} Returns the cache instance.
  18870. */
  18871. function setCacheAdd(value) {
  18872. this.__data__.set(value, HASH_UNDEFINED);
  18873. return this;
  18874. }
  18875. /**
  18876. * Checks if `value` is in the array cache.
  18877. *
  18878. * @private
  18879. * @name has
  18880. * @memberOf SetCache
  18881. * @param {*} value The value to search for.
  18882. * @returns {number} Returns `true` if `value` is found, else `false`.
  18883. */
  18884. function setCacheHas(value) {
  18885. return this.__data__.has(value);
  18886. }
  18887. // Add methods to `SetCache`.
  18888. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18889. SetCache.prototype.has = setCacheHas;
  18890. /*------------------------------------------------------------------------*/
  18891. /**
  18892. * Creates a stack cache object to store key-value pairs.
  18893. *
  18894. * @private
  18895. * @constructor
  18896. * @param {Array} [entries] The key-value pairs to cache.
  18897. */
  18898. function Stack(entries) {
  18899. var data = this.__data__ = new ListCache(entries);
  18900. this.size = data.size;
  18901. }
  18902. /**
  18903. * Removes all key-value entries from the stack.
  18904. *
  18905. * @private
  18906. * @name clear
  18907. * @memberOf Stack
  18908. */
  18909. function stackClear() {
  18910. this.__data__ = new ListCache;
  18911. this.size = 0;
  18912. }
  18913. /**
  18914. * Removes `key` and its value from the stack.
  18915. *
  18916. * @private
  18917. * @name delete
  18918. * @memberOf Stack
  18919. * @param {string} key The key of the value to remove.
  18920. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18921. */
  18922. function stackDelete(key) {
  18923. var data = this.__data__,
  18924. result = data['delete'](key);
  18925. this.size = data.size;
  18926. return result;
  18927. }
  18928. /**
  18929. * Gets the stack value for `key`.
  18930. *
  18931. * @private
  18932. * @name get
  18933. * @memberOf Stack
  18934. * @param {string} key The key of the value to get.
  18935. * @returns {*} Returns the entry value.
  18936. */
  18937. function stackGet(key) {
  18938. return this.__data__.get(key);
  18939. }
  18940. /**
  18941. * Checks if a stack value for `key` exists.
  18942. *
  18943. * @private
  18944. * @name has
  18945. * @memberOf Stack
  18946. * @param {string} key The key of the entry to check.
  18947. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18948. */
  18949. function stackHas(key) {
  18950. return this.__data__.has(key);
  18951. }
  18952. /**
  18953. * Sets the stack `key` to `value`.
  18954. *
  18955. * @private
  18956. * @name set
  18957. * @memberOf Stack
  18958. * @param {string} key The key of the value to set.
  18959. * @param {*} value The value to set.
  18960. * @returns {Object} Returns the stack cache instance.
  18961. */
  18962. function stackSet(key, value) {
  18963. var data = this.__data__;
  18964. if (data instanceof ListCache) {
  18965. var pairs = data.__data__;
  18966. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  18967. pairs.push([key, value]);
  18968. this.size = ++data.size;
  18969. return this;
  18970. }
  18971. data = this.__data__ = new MapCache(pairs);
  18972. }
  18973. data.set(key, value);
  18974. this.size = data.size;
  18975. return this;
  18976. }
  18977. // Add methods to `Stack`.
  18978. Stack.prototype.clear = stackClear;
  18979. Stack.prototype['delete'] = stackDelete;
  18980. Stack.prototype.get = stackGet;
  18981. Stack.prototype.has = stackHas;
  18982. Stack.prototype.set = stackSet;
  18983. /*------------------------------------------------------------------------*/
  18984. /**
  18985. * Creates an array of the enumerable property names of the array-like `value`.
  18986. *
  18987. * @private
  18988. * @param {*} value The value to query.
  18989. * @param {boolean} inherited Specify returning inherited property names.
  18990. * @returns {Array} Returns the array of property names.
  18991. */
  18992. function arrayLikeKeys(value, inherited) {
  18993. var isArr = isArray(value),
  18994. isArg = !isArr && isArguments(value),
  18995. isBuff = !isArr && !isArg && isBuffer(value),
  18996. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  18997. skipIndexes = isArr || isArg || isBuff || isType,
  18998. result = skipIndexes ? baseTimes(value.length, String) : [],
  18999. length = result.length;
  19000. for (var key in value) {
  19001. if ((inherited || hasOwnProperty.call(value, key)) &&
  19002. !(skipIndexes && (
  19003. // Safari 9 has enumerable `arguments.length` in strict mode.
  19004. key == 'length' ||
  19005. // Node.js 0.10 has enumerable non-index properties on buffers.
  19006. (isBuff && (key == 'offset' || key == 'parent')) ||
  19007. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19008. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19009. // Skip index properties.
  19010. isIndex(key, length)
  19011. ))) {
  19012. result.push(key);
  19013. }
  19014. }
  19015. return result;
  19016. }
  19017. /**
  19018. * A specialized version of `_.sample` for arrays.
  19019. *
  19020. * @private
  19021. * @param {Array} array The array to sample.
  19022. * @returns {*} Returns the random element.
  19023. */
  19024. function arraySample(array) {
  19025. var length = array.length;
  19026. return length ? array[baseRandom(0, length - 1)] : undefined;
  19027. }
  19028. /**
  19029. * A specialized version of `_.sampleSize` for arrays.
  19030. *
  19031. * @private
  19032. * @param {Array} array The array to sample.
  19033. * @param {number} n The number of elements to sample.
  19034. * @returns {Array} Returns the random elements.
  19035. */
  19036. function arraySampleSize(array, n) {
  19037. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19038. }
  19039. /**
  19040. * A specialized version of `_.shuffle` for arrays.
  19041. *
  19042. * @private
  19043. * @param {Array} array The array to shuffle.
  19044. * @returns {Array} Returns the new shuffled array.
  19045. */
  19046. function arrayShuffle(array) {
  19047. return shuffleSelf(copyArray(array));
  19048. }
  19049. /**
  19050. * This function is like `assignValue` except that it doesn't assign
  19051. * `undefined` values.
  19052. *
  19053. * @private
  19054. * @param {Object} object The object to modify.
  19055. * @param {string} key The key of the property to assign.
  19056. * @param {*} value The value to assign.
  19057. */
  19058. function assignMergeValue(object, key, value) {
  19059. if ((value !== undefined && !eq(object[key], value)) ||
  19060. (value === undefined && !(key in object))) {
  19061. baseAssignValue(object, key, value);
  19062. }
  19063. }
  19064. /**
  19065. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19066. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19067. * for equality comparisons.
  19068. *
  19069. * @private
  19070. * @param {Object} object The object to modify.
  19071. * @param {string} key The key of the property to assign.
  19072. * @param {*} value The value to assign.
  19073. */
  19074. function assignValue(object, key, value) {
  19075. var objValue = object[key];
  19076. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19077. (value === undefined && !(key in object))) {
  19078. baseAssignValue(object, key, value);
  19079. }
  19080. }
  19081. /**
  19082. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19083. *
  19084. * @private
  19085. * @param {Array} array The array to inspect.
  19086. * @param {*} key The key to search for.
  19087. * @returns {number} Returns the index of the matched value, else `-1`.
  19088. */
  19089. function assocIndexOf(array, key) {
  19090. var length = array.length;
  19091. while (length--) {
  19092. if (eq(array[length][0], key)) {
  19093. return length;
  19094. }
  19095. }
  19096. return -1;
  19097. }
  19098. /**
  19099. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19100. * by `iteratee` and values set by `setter`.
  19101. *
  19102. * @private
  19103. * @param {Array|Object} collection The collection to iterate over.
  19104. * @param {Function} setter The function to set `accumulator` values.
  19105. * @param {Function} iteratee The iteratee to transform keys.
  19106. * @param {Object} accumulator The initial aggregated object.
  19107. * @returns {Function} Returns `accumulator`.
  19108. */
  19109. function baseAggregator(collection, setter, iteratee, accumulator) {
  19110. baseEach(collection, function(value, key, collection) {
  19111. setter(accumulator, value, iteratee(value), collection);
  19112. });
  19113. return accumulator;
  19114. }
  19115. /**
  19116. * The base implementation of `_.assign` without support for multiple sources
  19117. * or `customizer` functions.
  19118. *
  19119. * @private
  19120. * @param {Object} object The destination object.
  19121. * @param {Object} source The source object.
  19122. * @returns {Object} Returns `object`.
  19123. */
  19124. function baseAssign(object, source) {
  19125. return object && copyObject(source, keys(source), object);
  19126. }
  19127. /**
  19128. * The base implementation of `_.assignIn` without support for multiple sources
  19129. * or `customizer` functions.
  19130. *
  19131. * @private
  19132. * @param {Object} object The destination object.
  19133. * @param {Object} source The source object.
  19134. * @returns {Object} Returns `object`.
  19135. */
  19136. function baseAssignIn(object, source) {
  19137. return object && copyObject(source, keysIn(source), object);
  19138. }
  19139. /**
  19140. * The base implementation of `assignValue` and `assignMergeValue` without
  19141. * value checks.
  19142. *
  19143. * @private
  19144. * @param {Object} object The object to modify.
  19145. * @param {string} key The key of the property to assign.
  19146. * @param {*} value The value to assign.
  19147. */
  19148. function baseAssignValue(object, key, value) {
  19149. if (key == '__proto__' && defineProperty) {
  19150. defineProperty(object, key, {
  19151. 'configurable': true,
  19152. 'enumerable': true,
  19153. 'value': value,
  19154. 'writable': true
  19155. });
  19156. } else {
  19157. object[key] = value;
  19158. }
  19159. }
  19160. /**
  19161. * The base implementation of `_.at` without support for individual paths.
  19162. *
  19163. * @private
  19164. * @param {Object} object The object to iterate over.
  19165. * @param {string[]} paths The property paths to pick.
  19166. * @returns {Array} Returns the picked elements.
  19167. */
  19168. function baseAt(object, paths) {
  19169. var index = -1,
  19170. length = paths.length,
  19171. result = Array(length),
  19172. skip = object == null;
  19173. while (++index < length) {
  19174. result[index] = skip ? undefined : get(object, paths[index]);
  19175. }
  19176. return result;
  19177. }
  19178. /**
  19179. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19180. *
  19181. * @private
  19182. * @param {number} number The number to clamp.
  19183. * @param {number} [lower] The lower bound.
  19184. * @param {number} upper The upper bound.
  19185. * @returns {number} Returns the clamped number.
  19186. */
  19187. function baseClamp(number, lower, upper) {
  19188. if (number === number) {
  19189. if (upper !== undefined) {
  19190. number = number <= upper ? number : upper;
  19191. }
  19192. if (lower !== undefined) {
  19193. number = number >= lower ? number : lower;
  19194. }
  19195. }
  19196. return number;
  19197. }
  19198. /**
  19199. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19200. * traversed objects.
  19201. *
  19202. * @private
  19203. * @param {*} value The value to clone.
  19204. * @param {boolean} bitmask The bitmask flags.
  19205. * 1 - Deep clone
  19206. * 2 - Flatten inherited properties
  19207. * 4 - Clone symbols
  19208. * @param {Function} [customizer] The function to customize cloning.
  19209. * @param {string} [key] The key of `value`.
  19210. * @param {Object} [object] The parent object of `value`.
  19211. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19212. * @returns {*} Returns the cloned value.
  19213. */
  19214. function baseClone(value, bitmask, customizer, key, object, stack) {
  19215. var result,
  19216. isDeep = bitmask & CLONE_DEEP_FLAG,
  19217. isFlat = bitmask & CLONE_FLAT_FLAG,
  19218. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19219. if (customizer) {
  19220. result = object ? customizer(value, key, object, stack) : customizer(value);
  19221. }
  19222. if (result !== undefined) {
  19223. return result;
  19224. }
  19225. if (!isObject(value)) {
  19226. return value;
  19227. }
  19228. var isArr = isArray(value);
  19229. if (isArr) {
  19230. result = initCloneArray(value);
  19231. if (!isDeep) {
  19232. return copyArray(value, result);
  19233. }
  19234. } else {
  19235. var tag = getTag(value),
  19236. isFunc = tag == funcTag || tag == genTag;
  19237. if (isBuffer(value)) {
  19238. return cloneBuffer(value, isDeep);
  19239. }
  19240. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19241. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19242. if (!isDeep) {
  19243. return isFlat
  19244. ? copySymbolsIn(value, baseAssignIn(result, value))
  19245. : copySymbols(value, baseAssign(result, value));
  19246. }
  19247. } else {
  19248. if (!cloneableTags[tag]) {
  19249. return object ? value : {};
  19250. }
  19251. result = initCloneByTag(value, tag, isDeep);
  19252. }
  19253. }
  19254. // Check for circular references and return its corresponding clone.
  19255. stack || (stack = new Stack);
  19256. var stacked = stack.get(value);
  19257. if (stacked) {
  19258. return stacked;
  19259. }
  19260. stack.set(value, result);
  19261. if (isSet(value)) {
  19262. value.forEach(function(subValue) {
  19263. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19264. });
  19265. } else if (isMap(value)) {
  19266. value.forEach(function(subValue, key) {
  19267. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19268. });
  19269. }
  19270. var keysFunc = isFull
  19271. ? (isFlat ? getAllKeysIn : getAllKeys)
  19272. : (isFlat ? keysIn : keys);
  19273. var props = isArr ? undefined : keysFunc(value);
  19274. arrayEach(props || value, function(subValue, key) {
  19275. if (props) {
  19276. key = subValue;
  19277. subValue = value[key];
  19278. }
  19279. // Recursively populate clone (susceptible to call stack limits).
  19280. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19281. });
  19282. return result;
  19283. }
  19284. /**
  19285. * The base implementation of `_.conforms` which doesn't clone `source`.
  19286. *
  19287. * @private
  19288. * @param {Object} source The object of property predicates to conform to.
  19289. * @returns {Function} Returns the new spec function.
  19290. */
  19291. function baseConforms(source) {
  19292. var props = keys(source);
  19293. return function(object) {
  19294. return baseConformsTo(object, source, props);
  19295. };
  19296. }
  19297. /**
  19298. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19299. *
  19300. * @private
  19301. * @param {Object} object The object to inspect.
  19302. * @param {Object} source The object of property predicates to conform to.
  19303. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19304. */
  19305. function baseConformsTo(object, source, props) {
  19306. var length = props.length;
  19307. if (object == null) {
  19308. return !length;
  19309. }
  19310. object = Object(object);
  19311. while (length--) {
  19312. var key = props[length],
  19313. predicate = source[key],
  19314. value = object[key];
  19315. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19316. return false;
  19317. }
  19318. }
  19319. return true;
  19320. }
  19321. /**
  19322. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19323. * to provide to `func`.
  19324. *
  19325. * @private
  19326. * @param {Function} func The function to delay.
  19327. * @param {number} wait The number of milliseconds to delay invocation.
  19328. * @param {Array} args The arguments to provide to `func`.
  19329. * @returns {number|Object} Returns the timer id or timeout object.
  19330. */
  19331. function baseDelay(func, wait, args) {
  19332. if (typeof func != 'function') {
  19333. throw new TypeError(FUNC_ERROR_TEXT);
  19334. }
  19335. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19336. }
  19337. /**
  19338. * The base implementation of methods like `_.difference` without support
  19339. * for excluding multiple arrays or iteratee shorthands.
  19340. *
  19341. * @private
  19342. * @param {Array} array The array to inspect.
  19343. * @param {Array} values The values to exclude.
  19344. * @param {Function} [iteratee] The iteratee invoked per element.
  19345. * @param {Function} [comparator] The comparator invoked per element.
  19346. * @returns {Array} Returns the new array of filtered values.
  19347. */
  19348. function baseDifference(array, values, iteratee, comparator) {
  19349. var index = -1,
  19350. includes = arrayIncludes,
  19351. isCommon = true,
  19352. length = array.length,
  19353. result = [],
  19354. valuesLength = values.length;
  19355. if (!length) {
  19356. return result;
  19357. }
  19358. if (iteratee) {
  19359. values = arrayMap(values, baseUnary(iteratee));
  19360. }
  19361. if (comparator) {
  19362. includes = arrayIncludesWith;
  19363. isCommon = false;
  19364. }
  19365. else if (values.length >= LARGE_ARRAY_SIZE) {
  19366. includes = cacheHas;
  19367. isCommon = false;
  19368. values = new SetCache(values);
  19369. }
  19370. outer:
  19371. while (++index < length) {
  19372. var value = array[index],
  19373. computed = iteratee == null ? value : iteratee(value);
  19374. value = (comparator || value !== 0) ? value : 0;
  19375. if (isCommon && computed === computed) {
  19376. var valuesIndex = valuesLength;
  19377. while (valuesIndex--) {
  19378. if (values[valuesIndex] === computed) {
  19379. continue outer;
  19380. }
  19381. }
  19382. result.push(value);
  19383. }
  19384. else if (!includes(values, computed, comparator)) {
  19385. result.push(value);
  19386. }
  19387. }
  19388. return result;
  19389. }
  19390. /**
  19391. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19392. *
  19393. * @private
  19394. * @param {Array|Object} collection The collection to iterate over.
  19395. * @param {Function} iteratee The function invoked per iteration.
  19396. * @returns {Array|Object} Returns `collection`.
  19397. */
  19398. var baseEach = createBaseEach(baseForOwn);
  19399. /**
  19400. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19401. *
  19402. * @private
  19403. * @param {Array|Object} collection The collection to iterate over.
  19404. * @param {Function} iteratee The function invoked per iteration.
  19405. * @returns {Array|Object} Returns `collection`.
  19406. */
  19407. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19408. /**
  19409. * The base implementation of `_.every` without support for iteratee shorthands.
  19410. *
  19411. * @private
  19412. * @param {Array|Object} collection The collection to iterate over.
  19413. * @param {Function} predicate The function invoked per iteration.
  19414. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19415. * else `false`
  19416. */
  19417. function baseEvery(collection, predicate) {
  19418. var result = true;
  19419. baseEach(collection, function(value, index, collection) {
  19420. result = !!predicate(value, index, collection);
  19421. return result;
  19422. });
  19423. return result;
  19424. }
  19425. /**
  19426. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19427. * `comparator` to determine the extremum value.
  19428. *
  19429. * @private
  19430. * @param {Array} array The array to iterate over.
  19431. * @param {Function} iteratee The iteratee invoked per iteration.
  19432. * @param {Function} comparator The comparator used to compare values.
  19433. * @returns {*} Returns the extremum value.
  19434. */
  19435. function baseExtremum(array, iteratee, comparator) {
  19436. var index = -1,
  19437. length = array.length;
  19438. while (++index < length) {
  19439. var value = array[index],
  19440. current = iteratee(value);
  19441. if (current != null && (computed === undefined
  19442. ? (current === current && !isSymbol(current))
  19443. : comparator(current, computed)
  19444. )) {
  19445. var computed = current,
  19446. result = value;
  19447. }
  19448. }
  19449. return result;
  19450. }
  19451. /**
  19452. * The base implementation of `_.fill` without an iteratee call guard.
  19453. *
  19454. * @private
  19455. * @param {Array} array The array to fill.
  19456. * @param {*} value The value to fill `array` with.
  19457. * @param {number} [start=0] The start position.
  19458. * @param {number} [end=array.length] The end position.
  19459. * @returns {Array} Returns `array`.
  19460. */
  19461. function baseFill(array, value, start, end) {
  19462. var length = array.length;
  19463. start = toInteger(start);
  19464. if (start < 0) {
  19465. start = -start > length ? 0 : (length + start);
  19466. }
  19467. end = (end === undefined || end > length) ? length : toInteger(end);
  19468. if (end < 0) {
  19469. end += length;
  19470. }
  19471. end = start > end ? 0 : toLength(end);
  19472. while (start < end) {
  19473. array[start++] = value;
  19474. }
  19475. return array;
  19476. }
  19477. /**
  19478. * The base implementation of `_.filter` without support for iteratee shorthands.
  19479. *
  19480. * @private
  19481. * @param {Array|Object} collection The collection to iterate over.
  19482. * @param {Function} predicate The function invoked per iteration.
  19483. * @returns {Array} Returns the new filtered array.
  19484. */
  19485. function baseFilter(collection, predicate) {
  19486. var result = [];
  19487. baseEach(collection, function(value, index, collection) {
  19488. if (predicate(value, index, collection)) {
  19489. result.push(value);
  19490. }
  19491. });
  19492. return result;
  19493. }
  19494. /**
  19495. * The base implementation of `_.flatten` with support for restricting flattening.
  19496. *
  19497. * @private
  19498. * @param {Array} array The array to flatten.
  19499. * @param {number} depth The maximum recursion depth.
  19500. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19501. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19502. * @param {Array} [result=[]] The initial result value.
  19503. * @returns {Array} Returns the new flattened array.
  19504. */
  19505. function baseFlatten(array, depth, predicate, isStrict, result) {
  19506. var index = -1,
  19507. length = array.length;
  19508. predicate || (predicate = isFlattenable);
  19509. result || (result = []);
  19510. while (++index < length) {
  19511. var value = array[index];
  19512. if (depth > 0 && predicate(value)) {
  19513. if (depth > 1) {
  19514. // Recursively flatten arrays (susceptible to call stack limits).
  19515. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19516. } else {
  19517. arrayPush(result, value);
  19518. }
  19519. } else if (!isStrict) {
  19520. result[result.length] = value;
  19521. }
  19522. }
  19523. return result;
  19524. }
  19525. /**
  19526. * The base implementation of `baseForOwn` which iterates over `object`
  19527. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19528. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19529. *
  19530. * @private
  19531. * @param {Object} object The object to iterate over.
  19532. * @param {Function} iteratee The function invoked per iteration.
  19533. * @param {Function} keysFunc The function to get the keys of `object`.
  19534. * @returns {Object} Returns `object`.
  19535. */
  19536. var baseFor = createBaseFor();
  19537. /**
  19538. * This function is like `baseFor` except that it iterates over properties
  19539. * in the opposite order.
  19540. *
  19541. * @private
  19542. * @param {Object} object The object to iterate over.
  19543. * @param {Function} iteratee The function invoked per iteration.
  19544. * @param {Function} keysFunc The function to get the keys of `object`.
  19545. * @returns {Object} Returns `object`.
  19546. */
  19547. var baseForRight = createBaseFor(true);
  19548. /**
  19549. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19550. *
  19551. * @private
  19552. * @param {Object} object The object to iterate over.
  19553. * @param {Function} iteratee The function invoked per iteration.
  19554. * @returns {Object} Returns `object`.
  19555. */
  19556. function baseForOwn(object, iteratee) {
  19557. return object && baseFor(object, iteratee, keys);
  19558. }
  19559. /**
  19560. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19561. *
  19562. * @private
  19563. * @param {Object} object The object to iterate over.
  19564. * @param {Function} iteratee The function invoked per iteration.
  19565. * @returns {Object} Returns `object`.
  19566. */
  19567. function baseForOwnRight(object, iteratee) {
  19568. return object && baseForRight(object, iteratee, keys);
  19569. }
  19570. /**
  19571. * The base implementation of `_.functions` which creates an array of
  19572. * `object` function property names filtered from `props`.
  19573. *
  19574. * @private
  19575. * @param {Object} object The object to inspect.
  19576. * @param {Array} props The property names to filter.
  19577. * @returns {Array} Returns the function names.
  19578. */
  19579. function baseFunctions(object, props) {
  19580. return arrayFilter(props, function(key) {
  19581. return isFunction(object[key]);
  19582. });
  19583. }
  19584. /**
  19585. * The base implementation of `_.get` without support for default values.
  19586. *
  19587. * @private
  19588. * @param {Object} object The object to query.
  19589. * @param {Array|string} path The path of the property to get.
  19590. * @returns {*} Returns the resolved value.
  19591. */
  19592. function baseGet(object, path) {
  19593. path = castPath(path, object);
  19594. var index = 0,
  19595. length = path.length;
  19596. while (object != null && index < length) {
  19597. object = object[toKey(path[index++])];
  19598. }
  19599. return (index && index == length) ? object : undefined;
  19600. }
  19601. /**
  19602. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19603. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19604. * symbols of `object`.
  19605. *
  19606. * @private
  19607. * @param {Object} object The object to query.
  19608. * @param {Function} keysFunc The function to get the keys of `object`.
  19609. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19610. * @returns {Array} Returns the array of property names and symbols.
  19611. */
  19612. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19613. var result = keysFunc(object);
  19614. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19615. }
  19616. /**
  19617. * The base implementation of `getTag` without fallbacks for buggy environments.
  19618. *
  19619. * @private
  19620. * @param {*} value The value to query.
  19621. * @returns {string} Returns the `toStringTag`.
  19622. */
  19623. function baseGetTag(value) {
  19624. if (value == null) {
  19625. return value === undefined ? undefinedTag : nullTag;
  19626. }
  19627. return (symToStringTag && symToStringTag in Object(value))
  19628. ? getRawTag(value)
  19629. : objectToString(value);
  19630. }
  19631. /**
  19632. * The base implementation of `_.gt` which doesn't coerce arguments.
  19633. *
  19634. * @private
  19635. * @param {*} value The value to compare.
  19636. * @param {*} other The other value to compare.
  19637. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19638. * else `false`.
  19639. */
  19640. function baseGt(value, other) {
  19641. return value > other;
  19642. }
  19643. /**
  19644. * The base implementation of `_.has` without support for deep paths.
  19645. *
  19646. * @private
  19647. * @param {Object} [object] The object to query.
  19648. * @param {Array|string} key The key to check.
  19649. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19650. */
  19651. function baseHas(object, key) {
  19652. return object != null && hasOwnProperty.call(object, key);
  19653. }
  19654. /**
  19655. * The base implementation of `_.hasIn` without support for deep paths.
  19656. *
  19657. * @private
  19658. * @param {Object} [object] The object to query.
  19659. * @param {Array|string} key The key to check.
  19660. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19661. */
  19662. function baseHasIn(object, key) {
  19663. return object != null && key in Object(object);
  19664. }
  19665. /**
  19666. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19667. *
  19668. * @private
  19669. * @param {number} number The number to check.
  19670. * @param {number} start The start of the range.
  19671. * @param {number} end The end of the range.
  19672. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19673. */
  19674. function baseInRange(number, start, end) {
  19675. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19676. }
  19677. /**
  19678. * The base implementation of methods like `_.intersection`, without support
  19679. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19680. *
  19681. * @private
  19682. * @param {Array} arrays The arrays to inspect.
  19683. * @param {Function} [iteratee] The iteratee invoked per element.
  19684. * @param {Function} [comparator] The comparator invoked per element.
  19685. * @returns {Array} Returns the new array of shared values.
  19686. */
  19687. function baseIntersection(arrays, iteratee, comparator) {
  19688. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19689. length = arrays[0].length,
  19690. othLength = arrays.length,
  19691. othIndex = othLength,
  19692. caches = Array(othLength),
  19693. maxLength = Infinity,
  19694. result = [];
  19695. while (othIndex--) {
  19696. var array = arrays[othIndex];
  19697. if (othIndex && iteratee) {
  19698. array = arrayMap(array, baseUnary(iteratee));
  19699. }
  19700. maxLength = nativeMin(array.length, maxLength);
  19701. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19702. ? new SetCache(othIndex && array)
  19703. : undefined;
  19704. }
  19705. array = arrays[0];
  19706. var index = -1,
  19707. seen = caches[0];
  19708. outer:
  19709. while (++index < length && result.length < maxLength) {
  19710. var value = array[index],
  19711. computed = iteratee ? iteratee(value) : value;
  19712. value = (comparator || value !== 0) ? value : 0;
  19713. if (!(seen
  19714. ? cacheHas(seen, computed)
  19715. : includes(result, computed, comparator)
  19716. )) {
  19717. othIndex = othLength;
  19718. while (--othIndex) {
  19719. var cache = caches[othIndex];
  19720. if (!(cache
  19721. ? cacheHas(cache, computed)
  19722. : includes(arrays[othIndex], computed, comparator))
  19723. ) {
  19724. continue outer;
  19725. }
  19726. }
  19727. if (seen) {
  19728. seen.push(computed);
  19729. }
  19730. result.push(value);
  19731. }
  19732. }
  19733. return result;
  19734. }
  19735. /**
  19736. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19737. * `object` with values transformed by `iteratee` and set by `setter`.
  19738. *
  19739. * @private
  19740. * @param {Object} object The object to iterate over.
  19741. * @param {Function} setter The function to set `accumulator` values.
  19742. * @param {Function} iteratee The iteratee to transform values.
  19743. * @param {Object} accumulator The initial inverted object.
  19744. * @returns {Function} Returns `accumulator`.
  19745. */
  19746. function baseInverter(object, setter, iteratee, accumulator) {
  19747. baseForOwn(object, function(value, key, object) {
  19748. setter(accumulator, iteratee(value), key, object);
  19749. });
  19750. return accumulator;
  19751. }
  19752. /**
  19753. * The base implementation of `_.invoke` without support for individual
  19754. * method arguments.
  19755. *
  19756. * @private
  19757. * @param {Object} object The object to query.
  19758. * @param {Array|string} path The path of the method to invoke.
  19759. * @param {Array} args The arguments to invoke the method with.
  19760. * @returns {*} Returns the result of the invoked method.
  19761. */
  19762. function baseInvoke(object, path, args) {
  19763. path = castPath(path, object);
  19764. object = parent(object, path);
  19765. var func = object == null ? object : object[toKey(last(path))];
  19766. return func == null ? undefined : apply(func, object, args);
  19767. }
  19768. /**
  19769. * The base implementation of `_.isArguments`.
  19770. *
  19771. * @private
  19772. * @param {*} value The value to check.
  19773. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19774. */
  19775. function baseIsArguments(value) {
  19776. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19777. }
  19778. /**
  19779. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19780. *
  19781. * @private
  19782. * @param {*} value The value to check.
  19783. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19784. */
  19785. function baseIsArrayBuffer(value) {
  19786. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19787. }
  19788. /**
  19789. * The base implementation of `_.isDate` without Node.js optimizations.
  19790. *
  19791. * @private
  19792. * @param {*} value The value to check.
  19793. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19794. */
  19795. function baseIsDate(value) {
  19796. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19797. }
  19798. /**
  19799. * The base implementation of `_.isEqual` which supports partial comparisons
  19800. * and tracks traversed objects.
  19801. *
  19802. * @private
  19803. * @param {*} value The value to compare.
  19804. * @param {*} other The other value to compare.
  19805. * @param {boolean} bitmask The bitmask flags.
  19806. * 1 - Unordered comparison
  19807. * 2 - Partial comparison
  19808. * @param {Function} [customizer] The function to customize comparisons.
  19809. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19810. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19811. */
  19812. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19813. if (value === other) {
  19814. return true;
  19815. }
  19816. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19817. return value !== value && other !== other;
  19818. }
  19819. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19820. }
  19821. /**
  19822. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19823. * deep comparisons and tracks traversed objects enabling objects with circular
  19824. * references to be compared.
  19825. *
  19826. * @private
  19827. * @param {Object} object The object to compare.
  19828. * @param {Object} other The other object to compare.
  19829. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19830. * @param {Function} customizer The function to customize comparisons.
  19831. * @param {Function} equalFunc The function to determine equivalents of values.
  19832. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19833. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19834. */
  19835. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19836. var objIsArr = isArray(object),
  19837. othIsArr = isArray(other),
  19838. objTag = objIsArr ? arrayTag : getTag(object),
  19839. othTag = othIsArr ? arrayTag : getTag(other);
  19840. objTag = objTag == argsTag ? objectTag : objTag;
  19841. othTag = othTag == argsTag ? objectTag : othTag;
  19842. var objIsObj = objTag == objectTag,
  19843. othIsObj = othTag == objectTag,
  19844. isSameTag = objTag == othTag;
  19845. if (isSameTag && isBuffer(object)) {
  19846. if (!isBuffer(other)) {
  19847. return false;
  19848. }
  19849. objIsArr = true;
  19850. objIsObj = false;
  19851. }
  19852. if (isSameTag && !objIsObj) {
  19853. stack || (stack = new Stack);
  19854. return (objIsArr || isTypedArray(object))
  19855. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19856. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19857. }
  19858. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19859. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19860. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19861. if (objIsWrapped || othIsWrapped) {
  19862. var objUnwrapped = objIsWrapped ? object.value() : object,
  19863. othUnwrapped = othIsWrapped ? other.value() : other;
  19864. stack || (stack = new Stack);
  19865. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19866. }
  19867. }
  19868. if (!isSameTag) {
  19869. return false;
  19870. }
  19871. stack || (stack = new Stack);
  19872. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19873. }
  19874. /**
  19875. * The base implementation of `_.isMap` without Node.js optimizations.
  19876. *
  19877. * @private
  19878. * @param {*} value The value to check.
  19879. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19880. */
  19881. function baseIsMap(value) {
  19882. return isObjectLike(value) && getTag(value) == mapTag;
  19883. }
  19884. /**
  19885. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19886. *
  19887. * @private
  19888. * @param {Object} object The object to inspect.
  19889. * @param {Object} source The object of property values to match.
  19890. * @param {Array} matchData The property names, values, and compare flags to match.
  19891. * @param {Function} [customizer] The function to customize comparisons.
  19892. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19893. */
  19894. function baseIsMatch(object, source, matchData, customizer) {
  19895. var index = matchData.length,
  19896. length = index,
  19897. noCustomizer = !customizer;
  19898. if (object == null) {
  19899. return !length;
  19900. }
  19901. object = Object(object);
  19902. while (index--) {
  19903. var data = matchData[index];
  19904. if ((noCustomizer && data[2])
  19905. ? data[1] !== object[data[0]]
  19906. : !(data[0] in object)
  19907. ) {
  19908. return false;
  19909. }
  19910. }
  19911. while (++index < length) {
  19912. data = matchData[index];
  19913. var key = data[0],
  19914. objValue = object[key],
  19915. srcValue = data[1];
  19916. if (noCustomizer && data[2]) {
  19917. if (objValue === undefined && !(key in object)) {
  19918. return false;
  19919. }
  19920. } else {
  19921. var stack = new Stack;
  19922. if (customizer) {
  19923. var result = customizer(objValue, srcValue, key, object, source, stack);
  19924. }
  19925. if (!(result === undefined
  19926. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19927. : result
  19928. )) {
  19929. return false;
  19930. }
  19931. }
  19932. }
  19933. return true;
  19934. }
  19935. /**
  19936. * The base implementation of `_.isNative` without bad shim checks.
  19937. *
  19938. * @private
  19939. * @param {*} value The value to check.
  19940. * @returns {boolean} Returns `true` if `value` is a native function,
  19941. * else `false`.
  19942. */
  19943. function baseIsNative(value) {
  19944. if (!isObject(value) || isMasked(value)) {
  19945. return false;
  19946. }
  19947. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19948. return pattern.test(toSource(value));
  19949. }
  19950. /**
  19951. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19952. *
  19953. * @private
  19954. * @param {*} value The value to check.
  19955. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19956. */
  19957. function baseIsRegExp(value) {
  19958. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19959. }
  19960. /**
  19961. * The base implementation of `_.isSet` without Node.js optimizations.
  19962. *
  19963. * @private
  19964. * @param {*} value The value to check.
  19965. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  19966. */
  19967. function baseIsSet(value) {
  19968. return isObjectLike(value) && getTag(value) == setTag;
  19969. }
  19970. /**
  19971. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  19972. *
  19973. * @private
  19974. * @param {*} value The value to check.
  19975. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  19976. */
  19977. function baseIsTypedArray(value) {
  19978. return isObjectLike(value) &&
  19979. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  19980. }
  19981. /**
  19982. * The base implementation of `_.iteratee`.
  19983. *
  19984. * @private
  19985. * @param {*} [value=_.identity] The value to convert to an iteratee.
  19986. * @returns {Function} Returns the iteratee.
  19987. */
  19988. function baseIteratee(value) {
  19989. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  19990. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  19991. if (typeof value == 'function') {
  19992. return value;
  19993. }
  19994. if (value == null) {
  19995. return identity;
  19996. }
  19997. if (typeof value == 'object') {
  19998. return isArray(value)
  19999. ? baseMatchesProperty(value[0], value[1])
  20000. : baseMatches(value);
  20001. }
  20002. return property(value);
  20003. }
  20004. /**
  20005. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20006. *
  20007. * @private
  20008. * @param {Object} object The object to query.
  20009. * @returns {Array} Returns the array of property names.
  20010. */
  20011. function baseKeys(object) {
  20012. if (!isPrototype(object)) {
  20013. return nativeKeys(object);
  20014. }
  20015. var result = [];
  20016. for (var key in Object(object)) {
  20017. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20018. result.push(key);
  20019. }
  20020. }
  20021. return result;
  20022. }
  20023. /**
  20024. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20025. *
  20026. * @private
  20027. * @param {Object} object The object to query.
  20028. * @returns {Array} Returns the array of property names.
  20029. */
  20030. function baseKeysIn(object) {
  20031. if (!isObject(object)) {
  20032. return nativeKeysIn(object);
  20033. }
  20034. var isProto = isPrototype(object),
  20035. result = [];
  20036. for (var key in object) {
  20037. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20038. result.push(key);
  20039. }
  20040. }
  20041. return result;
  20042. }
  20043. /**
  20044. * The base implementation of `_.lt` which doesn't coerce arguments.
  20045. *
  20046. * @private
  20047. * @param {*} value The value to compare.
  20048. * @param {*} other The other value to compare.
  20049. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20050. * else `false`.
  20051. */
  20052. function baseLt(value, other) {
  20053. return value < other;
  20054. }
  20055. /**
  20056. * The base implementation of `_.map` without support for iteratee shorthands.
  20057. *
  20058. * @private
  20059. * @param {Array|Object} collection The collection to iterate over.
  20060. * @param {Function} iteratee The function invoked per iteration.
  20061. * @returns {Array} Returns the new mapped array.
  20062. */
  20063. function baseMap(collection, iteratee) {
  20064. var index = -1,
  20065. result = isArrayLike(collection) ? Array(collection.length) : [];
  20066. baseEach(collection, function(value, key, collection) {
  20067. result[++index] = iteratee(value, key, collection);
  20068. });
  20069. return result;
  20070. }
  20071. /**
  20072. * The base implementation of `_.matches` which doesn't clone `source`.
  20073. *
  20074. * @private
  20075. * @param {Object} source The object of property values to match.
  20076. * @returns {Function} Returns the new spec function.
  20077. */
  20078. function baseMatches(source) {
  20079. var matchData = getMatchData(source);
  20080. if (matchData.length == 1 && matchData[0][2]) {
  20081. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20082. }
  20083. return function(object) {
  20084. return object === source || baseIsMatch(object, source, matchData);
  20085. };
  20086. }
  20087. /**
  20088. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20089. *
  20090. * @private
  20091. * @param {string} path The path of the property to get.
  20092. * @param {*} srcValue The value to match.
  20093. * @returns {Function} Returns the new spec function.
  20094. */
  20095. function baseMatchesProperty(path, srcValue) {
  20096. if (isKey(path) && isStrictComparable(srcValue)) {
  20097. return matchesStrictComparable(toKey(path), srcValue);
  20098. }
  20099. return function(object) {
  20100. var objValue = get(object, path);
  20101. return (objValue === undefined && objValue === srcValue)
  20102. ? hasIn(object, path)
  20103. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20104. };
  20105. }
  20106. /**
  20107. * The base implementation of `_.merge` without support for multiple sources.
  20108. *
  20109. * @private
  20110. * @param {Object} object The destination object.
  20111. * @param {Object} source The source object.
  20112. * @param {number} srcIndex The index of `source`.
  20113. * @param {Function} [customizer] The function to customize merged values.
  20114. * @param {Object} [stack] Tracks traversed source values and their merged
  20115. * counterparts.
  20116. */
  20117. function baseMerge(object, source, srcIndex, customizer, stack) {
  20118. if (object === source) {
  20119. return;
  20120. }
  20121. baseFor(source, function(srcValue, key) {
  20122. stack || (stack = new Stack);
  20123. if (isObject(srcValue)) {
  20124. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20125. }
  20126. else {
  20127. var newValue = customizer
  20128. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20129. : undefined;
  20130. if (newValue === undefined) {
  20131. newValue = srcValue;
  20132. }
  20133. assignMergeValue(object, key, newValue);
  20134. }
  20135. }, keysIn);
  20136. }
  20137. /**
  20138. * A specialized version of `baseMerge` for arrays and objects which performs
  20139. * deep merges and tracks traversed objects enabling objects with circular
  20140. * references to be merged.
  20141. *
  20142. * @private
  20143. * @param {Object} object The destination object.
  20144. * @param {Object} source The source object.
  20145. * @param {string} key The key of the value to merge.
  20146. * @param {number} srcIndex The index of `source`.
  20147. * @param {Function} mergeFunc The function to merge values.
  20148. * @param {Function} [customizer] The function to customize assigned values.
  20149. * @param {Object} [stack] Tracks traversed source values and their merged
  20150. * counterparts.
  20151. */
  20152. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20153. var objValue = safeGet(object, key),
  20154. srcValue = safeGet(source, key),
  20155. stacked = stack.get(srcValue);
  20156. if (stacked) {
  20157. assignMergeValue(object, key, stacked);
  20158. return;
  20159. }
  20160. var newValue = customizer
  20161. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20162. : undefined;
  20163. var isCommon = newValue === undefined;
  20164. if (isCommon) {
  20165. var isArr = isArray(srcValue),
  20166. isBuff = !isArr && isBuffer(srcValue),
  20167. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20168. newValue = srcValue;
  20169. if (isArr || isBuff || isTyped) {
  20170. if (isArray(objValue)) {
  20171. newValue = objValue;
  20172. }
  20173. else if (isArrayLikeObject(objValue)) {
  20174. newValue = copyArray(objValue);
  20175. }
  20176. else if (isBuff) {
  20177. isCommon = false;
  20178. newValue = cloneBuffer(srcValue, true);
  20179. }
  20180. else if (isTyped) {
  20181. isCommon = false;
  20182. newValue = cloneTypedArray(srcValue, true);
  20183. }
  20184. else {
  20185. newValue = [];
  20186. }
  20187. }
  20188. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20189. newValue = objValue;
  20190. if (isArguments(objValue)) {
  20191. newValue = toPlainObject(objValue);
  20192. }
  20193. else if (!isObject(objValue) || isFunction(objValue)) {
  20194. newValue = initCloneObject(srcValue);
  20195. }
  20196. }
  20197. else {
  20198. isCommon = false;
  20199. }
  20200. }
  20201. if (isCommon) {
  20202. // Recursively merge objects and arrays (susceptible to call stack limits).
  20203. stack.set(srcValue, newValue);
  20204. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20205. stack['delete'](srcValue);
  20206. }
  20207. assignMergeValue(object, key, newValue);
  20208. }
  20209. /**
  20210. * The base implementation of `_.nth` which doesn't coerce arguments.
  20211. *
  20212. * @private
  20213. * @param {Array} array The array to query.
  20214. * @param {number} n The index of the element to return.
  20215. * @returns {*} Returns the nth element of `array`.
  20216. */
  20217. function baseNth(array, n) {
  20218. var length = array.length;
  20219. if (!length) {
  20220. return;
  20221. }
  20222. n += n < 0 ? length : 0;
  20223. return isIndex(n, length) ? array[n] : undefined;
  20224. }
  20225. /**
  20226. * The base implementation of `_.orderBy` without param guards.
  20227. *
  20228. * @private
  20229. * @param {Array|Object} collection The collection to iterate over.
  20230. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20231. * @param {string[]} orders The sort orders of `iteratees`.
  20232. * @returns {Array} Returns the new sorted array.
  20233. */
  20234. function baseOrderBy(collection, iteratees, orders) {
  20235. var index = -1;
  20236. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20237. var result = baseMap(collection, function(value, key, collection) {
  20238. var criteria = arrayMap(iteratees, function(iteratee) {
  20239. return iteratee(value);
  20240. });
  20241. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20242. });
  20243. return baseSortBy(result, function(object, other) {
  20244. return compareMultiple(object, other, orders);
  20245. });
  20246. }
  20247. /**
  20248. * The base implementation of `_.pick` without support for individual
  20249. * property identifiers.
  20250. *
  20251. * @private
  20252. * @param {Object} object The source object.
  20253. * @param {string[]} paths The property paths to pick.
  20254. * @returns {Object} Returns the new object.
  20255. */
  20256. function basePick(object, paths) {
  20257. return basePickBy(object, paths, function(value, path) {
  20258. return hasIn(object, path);
  20259. });
  20260. }
  20261. /**
  20262. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20263. *
  20264. * @private
  20265. * @param {Object} object The source object.
  20266. * @param {string[]} paths The property paths to pick.
  20267. * @param {Function} predicate The function invoked per property.
  20268. * @returns {Object} Returns the new object.
  20269. */
  20270. function basePickBy(object, paths, predicate) {
  20271. var index = -1,
  20272. length = paths.length,
  20273. result = {};
  20274. while (++index < length) {
  20275. var path = paths[index],
  20276. value = baseGet(object, path);
  20277. if (predicate(value, path)) {
  20278. baseSet(result, castPath(path, object), value);
  20279. }
  20280. }
  20281. return result;
  20282. }
  20283. /**
  20284. * A specialized version of `baseProperty` which supports deep paths.
  20285. *
  20286. * @private
  20287. * @param {Array|string} path The path of the property to get.
  20288. * @returns {Function} Returns the new accessor function.
  20289. */
  20290. function basePropertyDeep(path) {
  20291. return function(object) {
  20292. return baseGet(object, path);
  20293. };
  20294. }
  20295. /**
  20296. * The base implementation of `_.pullAllBy` without support for iteratee
  20297. * shorthands.
  20298. *
  20299. * @private
  20300. * @param {Array} array The array to modify.
  20301. * @param {Array} values The values to remove.
  20302. * @param {Function} [iteratee] The iteratee invoked per element.
  20303. * @param {Function} [comparator] The comparator invoked per element.
  20304. * @returns {Array} Returns `array`.
  20305. */
  20306. function basePullAll(array, values, iteratee, comparator) {
  20307. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20308. index = -1,
  20309. length = values.length,
  20310. seen = array;
  20311. if (array === values) {
  20312. values = copyArray(values);
  20313. }
  20314. if (iteratee) {
  20315. seen = arrayMap(array, baseUnary(iteratee));
  20316. }
  20317. while (++index < length) {
  20318. var fromIndex = 0,
  20319. value = values[index],
  20320. computed = iteratee ? iteratee(value) : value;
  20321. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20322. if (seen !== array) {
  20323. splice.call(seen, fromIndex, 1);
  20324. }
  20325. splice.call(array, fromIndex, 1);
  20326. }
  20327. }
  20328. return array;
  20329. }
  20330. /**
  20331. * The base implementation of `_.pullAt` without support for individual
  20332. * indexes or capturing the removed elements.
  20333. *
  20334. * @private
  20335. * @param {Array} array The array to modify.
  20336. * @param {number[]} indexes The indexes of elements to remove.
  20337. * @returns {Array} Returns `array`.
  20338. */
  20339. function basePullAt(array, indexes) {
  20340. var length = array ? indexes.length : 0,
  20341. lastIndex = length - 1;
  20342. while (length--) {
  20343. var index = indexes[length];
  20344. if (length == lastIndex || index !== previous) {
  20345. var previous = index;
  20346. if (isIndex(index)) {
  20347. splice.call(array, index, 1);
  20348. } else {
  20349. baseUnset(array, index);
  20350. }
  20351. }
  20352. }
  20353. return array;
  20354. }
  20355. /**
  20356. * The base implementation of `_.random` without support for returning
  20357. * floating-point numbers.
  20358. *
  20359. * @private
  20360. * @param {number} lower The lower bound.
  20361. * @param {number} upper The upper bound.
  20362. * @returns {number} Returns the random number.
  20363. */
  20364. function baseRandom(lower, upper) {
  20365. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20366. }
  20367. /**
  20368. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20369. * coerce arguments.
  20370. *
  20371. * @private
  20372. * @param {number} start The start of the range.
  20373. * @param {number} end The end of the range.
  20374. * @param {number} step The value to increment or decrement by.
  20375. * @param {boolean} [fromRight] Specify iterating from right to left.
  20376. * @returns {Array} Returns the range of numbers.
  20377. */
  20378. function baseRange(start, end, step, fromRight) {
  20379. var index = -1,
  20380. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20381. result = Array(length);
  20382. while (length--) {
  20383. result[fromRight ? length : ++index] = start;
  20384. start += step;
  20385. }
  20386. return result;
  20387. }
  20388. /**
  20389. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20390. *
  20391. * @private
  20392. * @param {string} string The string to repeat.
  20393. * @param {number} n The number of times to repeat the string.
  20394. * @returns {string} Returns the repeated string.
  20395. */
  20396. function baseRepeat(string, n) {
  20397. var result = '';
  20398. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20399. return result;
  20400. }
  20401. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20402. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20403. do {
  20404. if (n % 2) {
  20405. result += string;
  20406. }
  20407. n = nativeFloor(n / 2);
  20408. if (n) {
  20409. string += string;
  20410. }
  20411. } while (n);
  20412. return result;
  20413. }
  20414. /**
  20415. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20416. *
  20417. * @private
  20418. * @param {Function} func The function to apply a rest parameter to.
  20419. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20420. * @returns {Function} Returns the new function.
  20421. */
  20422. function baseRest(func, start) {
  20423. return setToString(overRest(func, start, identity), func + '');
  20424. }
  20425. /**
  20426. * The base implementation of `_.sample`.
  20427. *
  20428. * @private
  20429. * @param {Array|Object} collection The collection to sample.
  20430. * @returns {*} Returns the random element.
  20431. */
  20432. function baseSample(collection) {
  20433. return arraySample(values(collection));
  20434. }
  20435. /**
  20436. * The base implementation of `_.sampleSize` without param guards.
  20437. *
  20438. * @private
  20439. * @param {Array|Object} collection The collection to sample.
  20440. * @param {number} n The number of elements to sample.
  20441. * @returns {Array} Returns the random elements.
  20442. */
  20443. function baseSampleSize(collection, n) {
  20444. var array = values(collection);
  20445. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20446. }
  20447. /**
  20448. * The base implementation of `_.set`.
  20449. *
  20450. * @private
  20451. * @param {Object} object The object to modify.
  20452. * @param {Array|string} path The path of the property to set.
  20453. * @param {*} value The value to set.
  20454. * @param {Function} [customizer] The function to customize path creation.
  20455. * @returns {Object} Returns `object`.
  20456. */
  20457. function baseSet(object, path, value, customizer) {
  20458. if (!isObject(object)) {
  20459. return object;
  20460. }
  20461. path = castPath(path, object);
  20462. var index = -1,
  20463. length = path.length,
  20464. lastIndex = length - 1,
  20465. nested = object;
  20466. while (nested != null && ++index < length) {
  20467. var key = toKey(path[index]),
  20468. newValue = value;
  20469. if (index != lastIndex) {
  20470. var objValue = nested[key];
  20471. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20472. if (newValue === undefined) {
  20473. newValue = isObject(objValue)
  20474. ? objValue
  20475. : (isIndex(path[index + 1]) ? [] : {});
  20476. }
  20477. }
  20478. assignValue(nested, key, newValue);
  20479. nested = nested[key];
  20480. }
  20481. return object;
  20482. }
  20483. /**
  20484. * The base implementation of `setData` without support for hot loop shorting.
  20485. *
  20486. * @private
  20487. * @param {Function} func The function to associate metadata with.
  20488. * @param {*} data The metadata.
  20489. * @returns {Function} Returns `func`.
  20490. */
  20491. var baseSetData = !metaMap ? identity : function(func, data) {
  20492. metaMap.set(func, data);
  20493. return func;
  20494. };
  20495. /**
  20496. * The base implementation of `setToString` without support for hot loop shorting.
  20497. *
  20498. * @private
  20499. * @param {Function} func The function to modify.
  20500. * @param {Function} string The `toString` result.
  20501. * @returns {Function} Returns `func`.
  20502. */
  20503. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20504. return defineProperty(func, 'toString', {
  20505. 'configurable': true,
  20506. 'enumerable': false,
  20507. 'value': constant(string),
  20508. 'writable': true
  20509. });
  20510. };
  20511. /**
  20512. * The base implementation of `_.shuffle`.
  20513. *
  20514. * @private
  20515. * @param {Array|Object} collection The collection to shuffle.
  20516. * @returns {Array} Returns the new shuffled array.
  20517. */
  20518. function baseShuffle(collection) {
  20519. return shuffleSelf(values(collection));
  20520. }
  20521. /**
  20522. * The base implementation of `_.slice` without an iteratee call guard.
  20523. *
  20524. * @private
  20525. * @param {Array} array The array to slice.
  20526. * @param {number} [start=0] The start position.
  20527. * @param {number} [end=array.length] The end position.
  20528. * @returns {Array} Returns the slice of `array`.
  20529. */
  20530. function baseSlice(array, start, end) {
  20531. var index = -1,
  20532. length = array.length;
  20533. if (start < 0) {
  20534. start = -start > length ? 0 : (length + start);
  20535. }
  20536. end = end > length ? length : end;
  20537. if (end < 0) {
  20538. end += length;
  20539. }
  20540. length = start > end ? 0 : ((end - start) >>> 0);
  20541. start >>>= 0;
  20542. var result = Array(length);
  20543. while (++index < length) {
  20544. result[index] = array[index + start];
  20545. }
  20546. return result;
  20547. }
  20548. /**
  20549. * The base implementation of `_.some` without support for iteratee shorthands.
  20550. *
  20551. * @private
  20552. * @param {Array|Object} collection The collection to iterate over.
  20553. * @param {Function} predicate The function invoked per iteration.
  20554. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20555. * else `false`.
  20556. */
  20557. function baseSome(collection, predicate) {
  20558. var result;
  20559. baseEach(collection, function(value, index, collection) {
  20560. result = predicate(value, index, collection);
  20561. return !result;
  20562. });
  20563. return !!result;
  20564. }
  20565. /**
  20566. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20567. * performs a binary search of `array` to determine the index at which `value`
  20568. * should be inserted into `array` in order to maintain its sort order.
  20569. *
  20570. * @private
  20571. * @param {Array} array The sorted array to inspect.
  20572. * @param {*} value The value to evaluate.
  20573. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20574. * @returns {number} Returns the index at which `value` should be inserted
  20575. * into `array`.
  20576. */
  20577. function baseSortedIndex(array, value, retHighest) {
  20578. var low = 0,
  20579. high = array == null ? low : array.length;
  20580. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20581. while (low < high) {
  20582. var mid = (low + high) >>> 1,
  20583. computed = array[mid];
  20584. if (computed !== null && !isSymbol(computed) &&
  20585. (retHighest ? (computed <= value) : (computed < value))) {
  20586. low = mid + 1;
  20587. } else {
  20588. high = mid;
  20589. }
  20590. }
  20591. return high;
  20592. }
  20593. return baseSortedIndexBy(array, value, identity, retHighest);
  20594. }
  20595. /**
  20596. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20597. * which invokes `iteratee` for `value` and each element of `array` to compute
  20598. * their sort ranking. The iteratee is invoked with one argument; (value).
  20599. *
  20600. * @private
  20601. * @param {Array} array The sorted array to inspect.
  20602. * @param {*} value The value to evaluate.
  20603. * @param {Function} iteratee The iteratee invoked per element.
  20604. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20605. * @returns {number} Returns the index at which `value` should be inserted
  20606. * into `array`.
  20607. */
  20608. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20609. value = iteratee(value);
  20610. var low = 0,
  20611. high = array == null ? 0 : array.length,
  20612. valIsNaN = value !== value,
  20613. valIsNull = value === null,
  20614. valIsSymbol = isSymbol(value),
  20615. valIsUndefined = value === undefined;
  20616. while (low < high) {
  20617. var mid = nativeFloor((low + high) / 2),
  20618. computed = iteratee(array[mid]),
  20619. othIsDefined = computed !== undefined,
  20620. othIsNull = computed === null,
  20621. othIsReflexive = computed === computed,
  20622. othIsSymbol = isSymbol(computed);
  20623. if (valIsNaN) {
  20624. var setLow = retHighest || othIsReflexive;
  20625. } else if (valIsUndefined) {
  20626. setLow = othIsReflexive && (retHighest || othIsDefined);
  20627. } else if (valIsNull) {
  20628. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20629. } else if (valIsSymbol) {
  20630. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20631. } else if (othIsNull || othIsSymbol) {
  20632. setLow = false;
  20633. } else {
  20634. setLow = retHighest ? (computed <= value) : (computed < value);
  20635. }
  20636. if (setLow) {
  20637. low = mid + 1;
  20638. } else {
  20639. high = mid;
  20640. }
  20641. }
  20642. return nativeMin(high, MAX_ARRAY_INDEX);
  20643. }
  20644. /**
  20645. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20646. * support for iteratee shorthands.
  20647. *
  20648. * @private
  20649. * @param {Array} array The array to inspect.
  20650. * @param {Function} [iteratee] The iteratee invoked per element.
  20651. * @returns {Array} Returns the new duplicate free array.
  20652. */
  20653. function baseSortedUniq(array, iteratee) {
  20654. var index = -1,
  20655. length = array.length,
  20656. resIndex = 0,
  20657. result = [];
  20658. while (++index < length) {
  20659. var value = array[index],
  20660. computed = iteratee ? iteratee(value) : value;
  20661. if (!index || !eq(computed, seen)) {
  20662. var seen = computed;
  20663. result[resIndex++] = value === 0 ? 0 : value;
  20664. }
  20665. }
  20666. return result;
  20667. }
  20668. /**
  20669. * The base implementation of `_.toNumber` which doesn't ensure correct
  20670. * conversions of binary, hexadecimal, or octal string values.
  20671. *
  20672. * @private
  20673. * @param {*} value The value to process.
  20674. * @returns {number} Returns the number.
  20675. */
  20676. function baseToNumber(value) {
  20677. if (typeof value == 'number') {
  20678. return value;
  20679. }
  20680. if (isSymbol(value)) {
  20681. return NAN;
  20682. }
  20683. return +value;
  20684. }
  20685. /**
  20686. * The base implementation of `_.toString` which doesn't convert nullish
  20687. * values to empty strings.
  20688. *
  20689. * @private
  20690. * @param {*} value The value to process.
  20691. * @returns {string} Returns the string.
  20692. */
  20693. function baseToString(value) {
  20694. // Exit early for strings to avoid a performance hit in some environments.
  20695. if (typeof value == 'string') {
  20696. return value;
  20697. }
  20698. if (isArray(value)) {
  20699. // Recursively convert values (susceptible to call stack limits).
  20700. return arrayMap(value, baseToString) + '';
  20701. }
  20702. if (isSymbol(value)) {
  20703. return symbolToString ? symbolToString.call(value) : '';
  20704. }
  20705. var result = (value + '');
  20706. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20707. }
  20708. /**
  20709. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20710. *
  20711. * @private
  20712. * @param {Array} array The array to inspect.
  20713. * @param {Function} [iteratee] The iteratee invoked per element.
  20714. * @param {Function} [comparator] The comparator invoked per element.
  20715. * @returns {Array} Returns the new duplicate free array.
  20716. */
  20717. function baseUniq(array, iteratee, comparator) {
  20718. var index = -1,
  20719. includes = arrayIncludes,
  20720. length = array.length,
  20721. isCommon = true,
  20722. result = [],
  20723. seen = result;
  20724. if (comparator) {
  20725. isCommon = false;
  20726. includes = arrayIncludesWith;
  20727. }
  20728. else if (length >= LARGE_ARRAY_SIZE) {
  20729. var set = iteratee ? null : createSet(array);
  20730. if (set) {
  20731. return setToArray(set);
  20732. }
  20733. isCommon = false;
  20734. includes = cacheHas;
  20735. seen = new SetCache;
  20736. }
  20737. else {
  20738. seen = iteratee ? [] : result;
  20739. }
  20740. outer:
  20741. while (++index < length) {
  20742. var value = array[index],
  20743. computed = iteratee ? iteratee(value) : value;
  20744. value = (comparator || value !== 0) ? value : 0;
  20745. if (isCommon && computed === computed) {
  20746. var seenIndex = seen.length;
  20747. while (seenIndex--) {
  20748. if (seen[seenIndex] === computed) {
  20749. continue outer;
  20750. }
  20751. }
  20752. if (iteratee) {
  20753. seen.push(computed);
  20754. }
  20755. result.push(value);
  20756. }
  20757. else if (!includes(seen, computed, comparator)) {
  20758. if (seen !== result) {
  20759. seen.push(computed);
  20760. }
  20761. result.push(value);
  20762. }
  20763. }
  20764. return result;
  20765. }
  20766. /**
  20767. * The base implementation of `_.unset`.
  20768. *
  20769. * @private
  20770. * @param {Object} object The object to modify.
  20771. * @param {Array|string} path The property path to unset.
  20772. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20773. */
  20774. function baseUnset(object, path) {
  20775. path = castPath(path, object);
  20776. object = parent(object, path);
  20777. return object == null || delete object[toKey(last(path))];
  20778. }
  20779. /**
  20780. * The base implementation of `_.update`.
  20781. *
  20782. * @private
  20783. * @param {Object} object The object to modify.
  20784. * @param {Array|string} path The path of the property to update.
  20785. * @param {Function} updater The function to produce the updated value.
  20786. * @param {Function} [customizer] The function to customize path creation.
  20787. * @returns {Object} Returns `object`.
  20788. */
  20789. function baseUpdate(object, path, updater, customizer) {
  20790. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20791. }
  20792. /**
  20793. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20794. * without support for iteratee shorthands.
  20795. *
  20796. * @private
  20797. * @param {Array} array The array to query.
  20798. * @param {Function} predicate The function invoked per iteration.
  20799. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20800. * @param {boolean} [fromRight] Specify iterating from right to left.
  20801. * @returns {Array} Returns the slice of `array`.
  20802. */
  20803. function baseWhile(array, predicate, isDrop, fromRight) {
  20804. var length = array.length,
  20805. index = fromRight ? length : -1;
  20806. while ((fromRight ? index-- : ++index < length) &&
  20807. predicate(array[index], index, array)) {}
  20808. return isDrop
  20809. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20810. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20811. }
  20812. /**
  20813. * The base implementation of `wrapperValue` which returns the result of
  20814. * performing a sequence of actions on the unwrapped `value`, where each
  20815. * successive action is supplied the return value of the previous.
  20816. *
  20817. * @private
  20818. * @param {*} value The unwrapped value.
  20819. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20820. * @returns {*} Returns the resolved value.
  20821. */
  20822. function baseWrapperValue(value, actions) {
  20823. var result = value;
  20824. if (result instanceof LazyWrapper) {
  20825. result = result.value();
  20826. }
  20827. return arrayReduce(actions, function(result, action) {
  20828. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20829. }, result);
  20830. }
  20831. /**
  20832. * The base implementation of methods like `_.xor`, without support for
  20833. * iteratee shorthands, that accepts an array of arrays to inspect.
  20834. *
  20835. * @private
  20836. * @param {Array} arrays The arrays to inspect.
  20837. * @param {Function} [iteratee] The iteratee invoked per element.
  20838. * @param {Function} [comparator] The comparator invoked per element.
  20839. * @returns {Array} Returns the new array of values.
  20840. */
  20841. function baseXor(arrays, iteratee, comparator) {
  20842. var length = arrays.length;
  20843. if (length < 2) {
  20844. return length ? baseUniq(arrays[0]) : [];
  20845. }
  20846. var index = -1,
  20847. result = Array(length);
  20848. while (++index < length) {
  20849. var array = arrays[index],
  20850. othIndex = -1;
  20851. while (++othIndex < length) {
  20852. if (othIndex != index) {
  20853. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20854. }
  20855. }
  20856. }
  20857. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20858. }
  20859. /**
  20860. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20861. *
  20862. * @private
  20863. * @param {Array} props The property identifiers.
  20864. * @param {Array} values The property values.
  20865. * @param {Function} assignFunc The function to assign values.
  20866. * @returns {Object} Returns the new object.
  20867. */
  20868. function baseZipObject(props, values, assignFunc) {
  20869. var index = -1,
  20870. length = props.length,
  20871. valsLength = values.length,
  20872. result = {};
  20873. while (++index < length) {
  20874. var value = index < valsLength ? values[index] : undefined;
  20875. assignFunc(result, props[index], value);
  20876. }
  20877. return result;
  20878. }
  20879. /**
  20880. * Casts `value` to an empty array if it's not an array like object.
  20881. *
  20882. * @private
  20883. * @param {*} value The value to inspect.
  20884. * @returns {Array|Object} Returns the cast array-like object.
  20885. */
  20886. function castArrayLikeObject(value) {
  20887. return isArrayLikeObject(value) ? value : [];
  20888. }
  20889. /**
  20890. * Casts `value` to `identity` if it's not a function.
  20891. *
  20892. * @private
  20893. * @param {*} value The value to inspect.
  20894. * @returns {Function} Returns cast function.
  20895. */
  20896. function castFunction(value) {
  20897. return typeof value == 'function' ? value : identity;
  20898. }
  20899. /**
  20900. * Casts `value` to a path array if it's not one.
  20901. *
  20902. * @private
  20903. * @param {*} value The value to inspect.
  20904. * @param {Object} [object] The object to query keys on.
  20905. * @returns {Array} Returns the cast property path array.
  20906. */
  20907. function castPath(value, object) {
  20908. if (isArray(value)) {
  20909. return value;
  20910. }
  20911. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20912. }
  20913. /**
  20914. * A `baseRest` alias which can be replaced with `identity` by module
  20915. * replacement plugins.
  20916. *
  20917. * @private
  20918. * @type {Function}
  20919. * @param {Function} func The function to apply a rest parameter to.
  20920. * @returns {Function} Returns the new function.
  20921. */
  20922. var castRest = baseRest;
  20923. /**
  20924. * Casts `array` to a slice if it's needed.
  20925. *
  20926. * @private
  20927. * @param {Array} array The array to inspect.
  20928. * @param {number} start The start position.
  20929. * @param {number} [end=array.length] The end position.
  20930. * @returns {Array} Returns the cast slice.
  20931. */
  20932. function castSlice(array, start, end) {
  20933. var length = array.length;
  20934. end = end === undefined ? length : end;
  20935. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20936. }
  20937. /**
  20938. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20939. *
  20940. * @private
  20941. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20942. */
  20943. var clearTimeout = ctxClearTimeout || function(id) {
  20944. return root.clearTimeout(id);
  20945. };
  20946. /**
  20947. * Creates a clone of `buffer`.
  20948. *
  20949. * @private
  20950. * @param {Buffer} buffer The buffer to clone.
  20951. * @param {boolean} [isDeep] Specify a deep clone.
  20952. * @returns {Buffer} Returns the cloned buffer.
  20953. */
  20954. function cloneBuffer(buffer, isDeep) {
  20955. if (isDeep) {
  20956. return buffer.slice();
  20957. }
  20958. var length = buffer.length,
  20959. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20960. buffer.copy(result);
  20961. return result;
  20962. }
  20963. /**
  20964. * Creates a clone of `arrayBuffer`.
  20965. *
  20966. * @private
  20967. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  20968. * @returns {ArrayBuffer} Returns the cloned array buffer.
  20969. */
  20970. function cloneArrayBuffer(arrayBuffer) {
  20971. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  20972. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  20973. return result;
  20974. }
  20975. /**
  20976. * Creates a clone of `dataView`.
  20977. *
  20978. * @private
  20979. * @param {Object} dataView The data view to clone.
  20980. * @param {boolean} [isDeep] Specify a deep clone.
  20981. * @returns {Object} Returns the cloned data view.
  20982. */
  20983. function cloneDataView(dataView, isDeep) {
  20984. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  20985. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  20986. }
  20987. /**
  20988. * Creates a clone of `regexp`.
  20989. *
  20990. * @private
  20991. * @param {Object} regexp The regexp to clone.
  20992. * @returns {Object} Returns the cloned regexp.
  20993. */
  20994. function cloneRegExp(regexp) {
  20995. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  20996. result.lastIndex = regexp.lastIndex;
  20997. return result;
  20998. }
  20999. /**
  21000. * Creates a clone of the `symbol` object.
  21001. *
  21002. * @private
  21003. * @param {Object} symbol The symbol object to clone.
  21004. * @returns {Object} Returns the cloned symbol object.
  21005. */
  21006. function cloneSymbol(symbol) {
  21007. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21008. }
  21009. /**
  21010. * Creates a clone of `typedArray`.
  21011. *
  21012. * @private
  21013. * @param {Object} typedArray The typed array to clone.
  21014. * @param {boolean} [isDeep] Specify a deep clone.
  21015. * @returns {Object} Returns the cloned typed array.
  21016. */
  21017. function cloneTypedArray(typedArray, isDeep) {
  21018. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21019. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21020. }
  21021. /**
  21022. * Compares values to sort them in ascending order.
  21023. *
  21024. * @private
  21025. * @param {*} value The value to compare.
  21026. * @param {*} other The other value to compare.
  21027. * @returns {number} Returns the sort order indicator for `value`.
  21028. */
  21029. function compareAscending(value, other) {
  21030. if (value !== other) {
  21031. var valIsDefined = value !== undefined,
  21032. valIsNull = value === null,
  21033. valIsReflexive = value === value,
  21034. valIsSymbol = isSymbol(value);
  21035. var othIsDefined = other !== undefined,
  21036. othIsNull = other === null,
  21037. othIsReflexive = other === other,
  21038. othIsSymbol = isSymbol(other);
  21039. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21040. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21041. (valIsNull && othIsDefined && othIsReflexive) ||
  21042. (!valIsDefined && othIsReflexive) ||
  21043. !valIsReflexive) {
  21044. return 1;
  21045. }
  21046. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21047. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21048. (othIsNull && valIsDefined && valIsReflexive) ||
  21049. (!othIsDefined && valIsReflexive) ||
  21050. !othIsReflexive) {
  21051. return -1;
  21052. }
  21053. }
  21054. return 0;
  21055. }
  21056. /**
  21057. * Used by `_.orderBy` to compare multiple properties of a value to another
  21058. * and stable sort them.
  21059. *
  21060. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21061. * specify an order of "desc" for descending or "asc" for ascending sort order
  21062. * of corresponding values.
  21063. *
  21064. * @private
  21065. * @param {Object} object The object to compare.
  21066. * @param {Object} other The other object to compare.
  21067. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21068. * @returns {number} Returns the sort order indicator for `object`.
  21069. */
  21070. function compareMultiple(object, other, orders) {
  21071. var index = -1,
  21072. objCriteria = object.criteria,
  21073. othCriteria = other.criteria,
  21074. length = objCriteria.length,
  21075. ordersLength = orders.length;
  21076. while (++index < length) {
  21077. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21078. if (result) {
  21079. if (index >= ordersLength) {
  21080. return result;
  21081. }
  21082. var order = orders[index];
  21083. return result * (order == 'desc' ? -1 : 1);
  21084. }
  21085. }
  21086. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21087. // that causes it, under certain circumstances, to provide the same value for
  21088. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21089. // for more details.
  21090. //
  21091. // This also ensures a stable sort in V8 and other engines.
  21092. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21093. return object.index - other.index;
  21094. }
  21095. /**
  21096. * Creates an array that is the composition of partially applied arguments,
  21097. * placeholders, and provided arguments into a single array of arguments.
  21098. *
  21099. * @private
  21100. * @param {Array} args The provided arguments.
  21101. * @param {Array} partials The arguments to prepend to those provided.
  21102. * @param {Array} holders The `partials` placeholder indexes.
  21103. * @params {boolean} [isCurried] Specify composing for a curried function.
  21104. * @returns {Array} Returns the new array of composed arguments.
  21105. */
  21106. function composeArgs(args, partials, holders, isCurried) {
  21107. var argsIndex = -1,
  21108. argsLength = args.length,
  21109. holdersLength = holders.length,
  21110. leftIndex = -1,
  21111. leftLength = partials.length,
  21112. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21113. result = Array(leftLength + rangeLength),
  21114. isUncurried = !isCurried;
  21115. while (++leftIndex < leftLength) {
  21116. result[leftIndex] = partials[leftIndex];
  21117. }
  21118. while (++argsIndex < holdersLength) {
  21119. if (isUncurried || argsIndex < argsLength) {
  21120. result[holders[argsIndex]] = args[argsIndex];
  21121. }
  21122. }
  21123. while (rangeLength--) {
  21124. result[leftIndex++] = args[argsIndex++];
  21125. }
  21126. return result;
  21127. }
  21128. /**
  21129. * This function is like `composeArgs` except that the arguments composition
  21130. * is tailored for `_.partialRight`.
  21131. *
  21132. * @private
  21133. * @param {Array} args The provided arguments.
  21134. * @param {Array} partials The arguments to append to those provided.
  21135. * @param {Array} holders The `partials` placeholder indexes.
  21136. * @params {boolean} [isCurried] Specify composing for a curried function.
  21137. * @returns {Array} Returns the new array of composed arguments.
  21138. */
  21139. function composeArgsRight(args, partials, holders, isCurried) {
  21140. var argsIndex = -1,
  21141. argsLength = args.length,
  21142. holdersIndex = -1,
  21143. holdersLength = holders.length,
  21144. rightIndex = -1,
  21145. rightLength = partials.length,
  21146. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21147. result = Array(rangeLength + rightLength),
  21148. isUncurried = !isCurried;
  21149. while (++argsIndex < rangeLength) {
  21150. result[argsIndex] = args[argsIndex];
  21151. }
  21152. var offset = argsIndex;
  21153. while (++rightIndex < rightLength) {
  21154. result[offset + rightIndex] = partials[rightIndex];
  21155. }
  21156. while (++holdersIndex < holdersLength) {
  21157. if (isUncurried || argsIndex < argsLength) {
  21158. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21159. }
  21160. }
  21161. return result;
  21162. }
  21163. /**
  21164. * Copies the values of `source` to `array`.
  21165. *
  21166. * @private
  21167. * @param {Array} source The array to copy values from.
  21168. * @param {Array} [array=[]] The array to copy values to.
  21169. * @returns {Array} Returns `array`.
  21170. */
  21171. function copyArray(source, array) {
  21172. var index = -1,
  21173. length = source.length;
  21174. array || (array = Array(length));
  21175. while (++index < length) {
  21176. array[index] = source[index];
  21177. }
  21178. return array;
  21179. }
  21180. /**
  21181. * Copies properties of `source` to `object`.
  21182. *
  21183. * @private
  21184. * @param {Object} source The object to copy properties from.
  21185. * @param {Array} props The property identifiers to copy.
  21186. * @param {Object} [object={}] The object to copy properties to.
  21187. * @param {Function} [customizer] The function to customize copied values.
  21188. * @returns {Object} Returns `object`.
  21189. */
  21190. function copyObject(source, props, object, customizer) {
  21191. var isNew = !object;
  21192. object || (object = {});
  21193. var index = -1,
  21194. length = props.length;
  21195. while (++index < length) {
  21196. var key = props[index];
  21197. var newValue = customizer
  21198. ? customizer(object[key], source[key], key, object, source)
  21199. : undefined;
  21200. if (newValue === undefined) {
  21201. newValue = source[key];
  21202. }
  21203. if (isNew) {
  21204. baseAssignValue(object, key, newValue);
  21205. } else {
  21206. assignValue(object, key, newValue);
  21207. }
  21208. }
  21209. return object;
  21210. }
  21211. /**
  21212. * Copies own symbols of `source` to `object`.
  21213. *
  21214. * @private
  21215. * @param {Object} source The object to copy symbols from.
  21216. * @param {Object} [object={}] The object to copy symbols to.
  21217. * @returns {Object} Returns `object`.
  21218. */
  21219. function copySymbols(source, object) {
  21220. return copyObject(source, getSymbols(source), object);
  21221. }
  21222. /**
  21223. * Copies own and inherited symbols of `source` to `object`.
  21224. *
  21225. * @private
  21226. * @param {Object} source The object to copy symbols from.
  21227. * @param {Object} [object={}] The object to copy symbols to.
  21228. * @returns {Object} Returns `object`.
  21229. */
  21230. function copySymbolsIn(source, object) {
  21231. return copyObject(source, getSymbolsIn(source), object);
  21232. }
  21233. /**
  21234. * Creates a function like `_.groupBy`.
  21235. *
  21236. * @private
  21237. * @param {Function} setter The function to set accumulator values.
  21238. * @param {Function} [initializer] The accumulator object initializer.
  21239. * @returns {Function} Returns the new aggregator function.
  21240. */
  21241. function createAggregator(setter, initializer) {
  21242. return function(collection, iteratee) {
  21243. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21244. accumulator = initializer ? initializer() : {};
  21245. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21246. };
  21247. }
  21248. /**
  21249. * Creates a function like `_.assign`.
  21250. *
  21251. * @private
  21252. * @param {Function} assigner The function to assign values.
  21253. * @returns {Function} Returns the new assigner function.
  21254. */
  21255. function createAssigner(assigner) {
  21256. return baseRest(function(object, sources) {
  21257. var index = -1,
  21258. length = sources.length,
  21259. customizer = length > 1 ? sources[length - 1] : undefined,
  21260. guard = length > 2 ? sources[2] : undefined;
  21261. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21262. ? (length--, customizer)
  21263. : undefined;
  21264. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21265. customizer = length < 3 ? undefined : customizer;
  21266. length = 1;
  21267. }
  21268. object = Object(object);
  21269. while (++index < length) {
  21270. var source = sources[index];
  21271. if (source) {
  21272. assigner(object, source, index, customizer);
  21273. }
  21274. }
  21275. return object;
  21276. });
  21277. }
  21278. /**
  21279. * Creates a `baseEach` or `baseEachRight` function.
  21280. *
  21281. * @private
  21282. * @param {Function} eachFunc The function to iterate over a collection.
  21283. * @param {boolean} [fromRight] Specify iterating from right to left.
  21284. * @returns {Function} Returns the new base function.
  21285. */
  21286. function createBaseEach(eachFunc, fromRight) {
  21287. return function(collection, iteratee) {
  21288. if (collection == null) {
  21289. return collection;
  21290. }
  21291. if (!isArrayLike(collection)) {
  21292. return eachFunc(collection, iteratee);
  21293. }
  21294. var length = collection.length,
  21295. index = fromRight ? length : -1,
  21296. iterable = Object(collection);
  21297. while ((fromRight ? index-- : ++index < length)) {
  21298. if (iteratee(iterable[index], index, iterable) === false) {
  21299. break;
  21300. }
  21301. }
  21302. return collection;
  21303. };
  21304. }
  21305. /**
  21306. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21307. *
  21308. * @private
  21309. * @param {boolean} [fromRight] Specify iterating from right to left.
  21310. * @returns {Function} Returns the new base function.
  21311. */
  21312. function createBaseFor(fromRight) {
  21313. return function(object, iteratee, keysFunc) {
  21314. var index = -1,
  21315. iterable = Object(object),
  21316. props = keysFunc(object),
  21317. length = props.length;
  21318. while (length--) {
  21319. var key = props[fromRight ? length : ++index];
  21320. if (iteratee(iterable[key], key, iterable) === false) {
  21321. break;
  21322. }
  21323. }
  21324. return object;
  21325. };
  21326. }
  21327. /**
  21328. * Creates a function that wraps `func` to invoke it with the optional `this`
  21329. * binding of `thisArg`.
  21330. *
  21331. * @private
  21332. * @param {Function} func The function to wrap.
  21333. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21334. * @param {*} [thisArg] The `this` binding of `func`.
  21335. * @returns {Function} Returns the new wrapped function.
  21336. */
  21337. function createBind(func, bitmask, thisArg) {
  21338. var isBind = bitmask & WRAP_BIND_FLAG,
  21339. Ctor = createCtor(func);
  21340. function wrapper() {
  21341. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21342. return fn.apply(isBind ? thisArg : this, arguments);
  21343. }
  21344. return wrapper;
  21345. }
  21346. /**
  21347. * Creates a function like `_.lowerFirst`.
  21348. *
  21349. * @private
  21350. * @param {string} methodName The name of the `String` case method to use.
  21351. * @returns {Function} Returns the new case function.
  21352. */
  21353. function createCaseFirst(methodName) {
  21354. return function(string) {
  21355. string = toString(string);
  21356. var strSymbols = hasUnicode(string)
  21357. ? stringToArray(string)
  21358. : undefined;
  21359. var chr = strSymbols
  21360. ? strSymbols[0]
  21361. : string.charAt(0);
  21362. var trailing = strSymbols
  21363. ? castSlice(strSymbols, 1).join('')
  21364. : string.slice(1);
  21365. return chr[methodName]() + trailing;
  21366. };
  21367. }
  21368. /**
  21369. * Creates a function like `_.camelCase`.
  21370. *
  21371. * @private
  21372. * @param {Function} callback The function to combine each word.
  21373. * @returns {Function} Returns the new compounder function.
  21374. */
  21375. function createCompounder(callback) {
  21376. return function(string) {
  21377. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21378. };
  21379. }
  21380. /**
  21381. * Creates a function that produces an instance of `Ctor` regardless of
  21382. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21383. *
  21384. * @private
  21385. * @param {Function} Ctor The constructor to wrap.
  21386. * @returns {Function} Returns the new wrapped function.
  21387. */
  21388. function createCtor(Ctor) {
  21389. return function() {
  21390. // Use a `switch` statement to work with class constructors. See
  21391. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21392. // for more details.
  21393. var args = arguments;
  21394. switch (args.length) {
  21395. case 0: return new Ctor;
  21396. case 1: return new Ctor(args[0]);
  21397. case 2: return new Ctor(args[0], args[1]);
  21398. case 3: return new Ctor(args[0], args[1], args[2]);
  21399. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21400. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21401. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21402. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21403. }
  21404. var thisBinding = baseCreate(Ctor.prototype),
  21405. result = Ctor.apply(thisBinding, args);
  21406. // Mimic the constructor's `return` behavior.
  21407. // See https://es5.github.io/#x13.2.2 for more details.
  21408. return isObject(result) ? result : thisBinding;
  21409. };
  21410. }
  21411. /**
  21412. * Creates a function that wraps `func` to enable currying.
  21413. *
  21414. * @private
  21415. * @param {Function} func The function to wrap.
  21416. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21417. * @param {number} arity The arity of `func`.
  21418. * @returns {Function} Returns the new wrapped function.
  21419. */
  21420. function createCurry(func, bitmask, arity) {
  21421. var Ctor = createCtor(func);
  21422. function wrapper() {
  21423. var length = arguments.length,
  21424. args = Array(length),
  21425. index = length,
  21426. placeholder = getHolder(wrapper);
  21427. while (index--) {
  21428. args[index] = arguments[index];
  21429. }
  21430. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21431. ? []
  21432. : replaceHolders(args, placeholder);
  21433. length -= holders.length;
  21434. if (length < arity) {
  21435. return createRecurry(
  21436. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21437. args, holders, undefined, undefined, arity - length);
  21438. }
  21439. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21440. return apply(fn, this, args);
  21441. }
  21442. return wrapper;
  21443. }
  21444. /**
  21445. * Creates a `_.find` or `_.findLast` function.
  21446. *
  21447. * @private
  21448. * @param {Function} findIndexFunc The function to find the collection index.
  21449. * @returns {Function} Returns the new find function.
  21450. */
  21451. function createFind(findIndexFunc) {
  21452. return function(collection, predicate, fromIndex) {
  21453. var iterable = Object(collection);
  21454. if (!isArrayLike(collection)) {
  21455. var iteratee = getIteratee(predicate, 3);
  21456. collection = keys(collection);
  21457. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21458. }
  21459. var index = findIndexFunc(collection, predicate, fromIndex);
  21460. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21461. };
  21462. }
  21463. /**
  21464. * Creates a `_.flow` or `_.flowRight` function.
  21465. *
  21466. * @private
  21467. * @param {boolean} [fromRight] Specify iterating from right to left.
  21468. * @returns {Function} Returns the new flow function.
  21469. */
  21470. function createFlow(fromRight) {
  21471. return flatRest(function(funcs) {
  21472. var length = funcs.length,
  21473. index = length,
  21474. prereq = LodashWrapper.prototype.thru;
  21475. if (fromRight) {
  21476. funcs.reverse();
  21477. }
  21478. while (index--) {
  21479. var func = funcs[index];
  21480. if (typeof func != 'function') {
  21481. throw new TypeError(FUNC_ERROR_TEXT);
  21482. }
  21483. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21484. var wrapper = new LodashWrapper([], true);
  21485. }
  21486. }
  21487. index = wrapper ? index : length;
  21488. while (++index < length) {
  21489. func = funcs[index];
  21490. var funcName = getFuncName(func),
  21491. data = funcName == 'wrapper' ? getData(func) : undefined;
  21492. if (data && isLaziable(data[0]) &&
  21493. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21494. !data[4].length && data[9] == 1
  21495. ) {
  21496. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21497. } else {
  21498. wrapper = (func.length == 1 && isLaziable(func))
  21499. ? wrapper[funcName]()
  21500. : wrapper.thru(func);
  21501. }
  21502. }
  21503. return function() {
  21504. var args = arguments,
  21505. value = args[0];
  21506. if (wrapper && args.length == 1 && isArray(value)) {
  21507. return wrapper.plant(value).value();
  21508. }
  21509. var index = 0,
  21510. result = length ? funcs[index].apply(this, args) : value;
  21511. while (++index < length) {
  21512. result = funcs[index].call(this, result);
  21513. }
  21514. return result;
  21515. };
  21516. });
  21517. }
  21518. /**
  21519. * Creates a function that wraps `func` to invoke it with optional `this`
  21520. * binding of `thisArg`, partial application, and currying.
  21521. *
  21522. * @private
  21523. * @param {Function|string} func The function or method name to wrap.
  21524. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21525. * @param {*} [thisArg] The `this` binding of `func`.
  21526. * @param {Array} [partials] The arguments to prepend to those provided to
  21527. * the new function.
  21528. * @param {Array} [holders] The `partials` placeholder indexes.
  21529. * @param {Array} [partialsRight] The arguments to append to those provided
  21530. * to the new function.
  21531. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21532. * @param {Array} [argPos] The argument positions of the new function.
  21533. * @param {number} [ary] The arity cap of `func`.
  21534. * @param {number} [arity] The arity of `func`.
  21535. * @returns {Function} Returns the new wrapped function.
  21536. */
  21537. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21538. var isAry = bitmask & WRAP_ARY_FLAG,
  21539. isBind = bitmask & WRAP_BIND_FLAG,
  21540. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21541. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21542. isFlip = bitmask & WRAP_FLIP_FLAG,
  21543. Ctor = isBindKey ? undefined : createCtor(func);
  21544. function wrapper() {
  21545. var length = arguments.length,
  21546. args = Array(length),
  21547. index = length;
  21548. while (index--) {
  21549. args[index] = arguments[index];
  21550. }
  21551. if (isCurried) {
  21552. var placeholder = getHolder(wrapper),
  21553. holdersCount = countHolders(args, placeholder);
  21554. }
  21555. if (partials) {
  21556. args = composeArgs(args, partials, holders, isCurried);
  21557. }
  21558. if (partialsRight) {
  21559. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21560. }
  21561. length -= holdersCount;
  21562. if (isCurried && length < arity) {
  21563. var newHolders = replaceHolders(args, placeholder);
  21564. return createRecurry(
  21565. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21566. args, newHolders, argPos, ary, arity - length
  21567. );
  21568. }
  21569. var thisBinding = isBind ? thisArg : this,
  21570. fn = isBindKey ? thisBinding[func] : func;
  21571. length = args.length;
  21572. if (argPos) {
  21573. args = reorder(args, argPos);
  21574. } else if (isFlip && length > 1) {
  21575. args.reverse();
  21576. }
  21577. if (isAry && ary < length) {
  21578. args.length = ary;
  21579. }
  21580. if (this && this !== root && this instanceof wrapper) {
  21581. fn = Ctor || createCtor(fn);
  21582. }
  21583. return fn.apply(thisBinding, args);
  21584. }
  21585. return wrapper;
  21586. }
  21587. /**
  21588. * Creates a function like `_.invertBy`.
  21589. *
  21590. * @private
  21591. * @param {Function} setter The function to set accumulator values.
  21592. * @param {Function} toIteratee The function to resolve iteratees.
  21593. * @returns {Function} Returns the new inverter function.
  21594. */
  21595. function createInverter(setter, toIteratee) {
  21596. return function(object, iteratee) {
  21597. return baseInverter(object, setter, toIteratee(iteratee), {});
  21598. };
  21599. }
  21600. /**
  21601. * Creates a function that performs a mathematical operation on two values.
  21602. *
  21603. * @private
  21604. * @param {Function} operator The function to perform the operation.
  21605. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21606. * @returns {Function} Returns the new mathematical operation function.
  21607. */
  21608. function createMathOperation(operator, defaultValue) {
  21609. return function(value, other) {
  21610. var result;
  21611. if (value === undefined && other === undefined) {
  21612. return defaultValue;
  21613. }
  21614. if (value !== undefined) {
  21615. result = value;
  21616. }
  21617. if (other !== undefined) {
  21618. if (result === undefined) {
  21619. return other;
  21620. }
  21621. if (typeof value == 'string' || typeof other == 'string') {
  21622. value = baseToString(value);
  21623. other = baseToString(other);
  21624. } else {
  21625. value = baseToNumber(value);
  21626. other = baseToNumber(other);
  21627. }
  21628. result = operator(value, other);
  21629. }
  21630. return result;
  21631. };
  21632. }
  21633. /**
  21634. * Creates a function like `_.over`.
  21635. *
  21636. * @private
  21637. * @param {Function} arrayFunc The function to iterate over iteratees.
  21638. * @returns {Function} Returns the new over function.
  21639. */
  21640. function createOver(arrayFunc) {
  21641. return flatRest(function(iteratees) {
  21642. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21643. return baseRest(function(args) {
  21644. var thisArg = this;
  21645. return arrayFunc(iteratees, function(iteratee) {
  21646. return apply(iteratee, thisArg, args);
  21647. });
  21648. });
  21649. });
  21650. }
  21651. /**
  21652. * Creates the padding for `string` based on `length`. The `chars` string
  21653. * is truncated if the number of characters exceeds `length`.
  21654. *
  21655. * @private
  21656. * @param {number} length The padding length.
  21657. * @param {string} [chars=' '] The string used as padding.
  21658. * @returns {string} Returns the padding for `string`.
  21659. */
  21660. function createPadding(length, chars) {
  21661. chars = chars === undefined ? ' ' : baseToString(chars);
  21662. var charsLength = chars.length;
  21663. if (charsLength < 2) {
  21664. return charsLength ? baseRepeat(chars, length) : chars;
  21665. }
  21666. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21667. return hasUnicode(chars)
  21668. ? castSlice(stringToArray(result), 0, length).join('')
  21669. : result.slice(0, length);
  21670. }
  21671. /**
  21672. * Creates a function that wraps `func` to invoke it with the `this` binding
  21673. * of `thisArg` and `partials` prepended to the arguments it receives.
  21674. *
  21675. * @private
  21676. * @param {Function} func The function to wrap.
  21677. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21678. * @param {*} thisArg The `this` binding of `func`.
  21679. * @param {Array} partials The arguments to prepend to those provided to
  21680. * the new function.
  21681. * @returns {Function} Returns the new wrapped function.
  21682. */
  21683. function createPartial(func, bitmask, thisArg, partials) {
  21684. var isBind = bitmask & WRAP_BIND_FLAG,
  21685. Ctor = createCtor(func);
  21686. function wrapper() {
  21687. var argsIndex = -1,
  21688. argsLength = arguments.length,
  21689. leftIndex = -1,
  21690. leftLength = partials.length,
  21691. args = Array(leftLength + argsLength),
  21692. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21693. while (++leftIndex < leftLength) {
  21694. args[leftIndex] = partials[leftIndex];
  21695. }
  21696. while (argsLength--) {
  21697. args[leftIndex++] = arguments[++argsIndex];
  21698. }
  21699. return apply(fn, isBind ? thisArg : this, args);
  21700. }
  21701. return wrapper;
  21702. }
  21703. /**
  21704. * Creates a `_.range` or `_.rangeRight` function.
  21705. *
  21706. * @private
  21707. * @param {boolean} [fromRight] Specify iterating from right to left.
  21708. * @returns {Function} Returns the new range function.
  21709. */
  21710. function createRange(fromRight) {
  21711. return function(start, end, step) {
  21712. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21713. end = step = undefined;
  21714. }
  21715. // Ensure the sign of `-0` is preserved.
  21716. start = toFinite(start);
  21717. if (end === undefined) {
  21718. end = start;
  21719. start = 0;
  21720. } else {
  21721. end = toFinite(end);
  21722. }
  21723. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21724. return baseRange(start, end, step, fromRight);
  21725. };
  21726. }
  21727. /**
  21728. * Creates a function that performs a relational operation on two values.
  21729. *
  21730. * @private
  21731. * @param {Function} operator The function to perform the operation.
  21732. * @returns {Function} Returns the new relational operation function.
  21733. */
  21734. function createRelationalOperation(operator) {
  21735. return function(value, other) {
  21736. if (!(typeof value == 'string' && typeof other == 'string')) {
  21737. value = toNumber(value);
  21738. other = toNumber(other);
  21739. }
  21740. return operator(value, other);
  21741. };
  21742. }
  21743. /**
  21744. * Creates a function that wraps `func` to continue currying.
  21745. *
  21746. * @private
  21747. * @param {Function} func The function to wrap.
  21748. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21749. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21750. * @param {*} placeholder The placeholder value.
  21751. * @param {*} [thisArg] The `this` binding of `func`.
  21752. * @param {Array} [partials] The arguments to prepend to those provided to
  21753. * the new function.
  21754. * @param {Array} [holders] The `partials` placeholder indexes.
  21755. * @param {Array} [argPos] The argument positions of the new function.
  21756. * @param {number} [ary] The arity cap of `func`.
  21757. * @param {number} [arity] The arity of `func`.
  21758. * @returns {Function} Returns the new wrapped function.
  21759. */
  21760. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21761. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21762. newHolders = isCurry ? holders : undefined,
  21763. newHoldersRight = isCurry ? undefined : holders,
  21764. newPartials = isCurry ? partials : undefined,
  21765. newPartialsRight = isCurry ? undefined : partials;
  21766. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21767. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21768. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21769. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21770. }
  21771. var newData = [
  21772. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21773. newHoldersRight, argPos, ary, arity
  21774. ];
  21775. var result = wrapFunc.apply(undefined, newData);
  21776. if (isLaziable(func)) {
  21777. setData(result, newData);
  21778. }
  21779. result.placeholder = placeholder;
  21780. return setWrapToString(result, func, bitmask);
  21781. }
  21782. /**
  21783. * Creates a function like `_.round`.
  21784. *
  21785. * @private
  21786. * @param {string} methodName The name of the `Math` method to use when rounding.
  21787. * @returns {Function} Returns the new round function.
  21788. */
  21789. function createRound(methodName) {
  21790. var func = Math[methodName];
  21791. return function(number, precision) {
  21792. number = toNumber(number);
  21793. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21794. if (precision && nativeIsFinite(number)) {
  21795. // Shift with exponential notation to avoid floating-point issues.
  21796. // See [MDN](https://mdn.io/round#Examples) for more details.
  21797. var pair = (toString(number) + 'e').split('e'),
  21798. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21799. pair = (toString(value) + 'e').split('e');
  21800. return +(pair[0] + 'e' + (+pair[1] - precision));
  21801. }
  21802. return func(number);
  21803. };
  21804. }
  21805. /**
  21806. * Creates a set object of `values`.
  21807. *
  21808. * @private
  21809. * @param {Array} values The values to add to the set.
  21810. * @returns {Object} Returns the new set.
  21811. */
  21812. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21813. return new Set(values);
  21814. };
  21815. /**
  21816. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21817. *
  21818. * @private
  21819. * @param {Function} keysFunc The function to get the keys of a given object.
  21820. * @returns {Function} Returns the new pairs function.
  21821. */
  21822. function createToPairs(keysFunc) {
  21823. return function(object) {
  21824. var tag = getTag(object);
  21825. if (tag == mapTag) {
  21826. return mapToArray(object);
  21827. }
  21828. if (tag == setTag) {
  21829. return setToPairs(object);
  21830. }
  21831. return baseToPairs(object, keysFunc(object));
  21832. };
  21833. }
  21834. /**
  21835. * Creates a function that either curries or invokes `func` with optional
  21836. * `this` binding and partially applied arguments.
  21837. *
  21838. * @private
  21839. * @param {Function|string} func The function or method name to wrap.
  21840. * @param {number} bitmask The bitmask flags.
  21841. * 1 - `_.bind`
  21842. * 2 - `_.bindKey`
  21843. * 4 - `_.curry` or `_.curryRight` of a bound function
  21844. * 8 - `_.curry`
  21845. * 16 - `_.curryRight`
  21846. * 32 - `_.partial`
  21847. * 64 - `_.partialRight`
  21848. * 128 - `_.rearg`
  21849. * 256 - `_.ary`
  21850. * 512 - `_.flip`
  21851. * @param {*} [thisArg] The `this` binding of `func`.
  21852. * @param {Array} [partials] The arguments to be partially applied.
  21853. * @param {Array} [holders] The `partials` placeholder indexes.
  21854. * @param {Array} [argPos] The argument positions of the new function.
  21855. * @param {number} [ary] The arity cap of `func`.
  21856. * @param {number} [arity] The arity of `func`.
  21857. * @returns {Function} Returns the new wrapped function.
  21858. */
  21859. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21860. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21861. if (!isBindKey && typeof func != 'function') {
  21862. throw new TypeError(FUNC_ERROR_TEXT);
  21863. }
  21864. var length = partials ? partials.length : 0;
  21865. if (!length) {
  21866. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21867. partials = holders = undefined;
  21868. }
  21869. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21870. arity = arity === undefined ? arity : toInteger(arity);
  21871. length -= holders ? holders.length : 0;
  21872. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21873. var partialsRight = partials,
  21874. holdersRight = holders;
  21875. partials = holders = undefined;
  21876. }
  21877. var data = isBindKey ? undefined : getData(func);
  21878. var newData = [
  21879. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21880. argPos, ary, arity
  21881. ];
  21882. if (data) {
  21883. mergeData(newData, data);
  21884. }
  21885. func = newData[0];
  21886. bitmask = newData[1];
  21887. thisArg = newData[2];
  21888. partials = newData[3];
  21889. holders = newData[4];
  21890. arity = newData[9] = newData[9] === undefined
  21891. ? (isBindKey ? 0 : func.length)
  21892. : nativeMax(newData[9] - length, 0);
  21893. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21894. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21895. }
  21896. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21897. var result = createBind(func, bitmask, thisArg);
  21898. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21899. result = createCurry(func, bitmask, arity);
  21900. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21901. result = createPartial(func, bitmask, thisArg, partials);
  21902. } else {
  21903. result = createHybrid.apply(undefined, newData);
  21904. }
  21905. var setter = data ? baseSetData : setData;
  21906. return setWrapToString(setter(result, newData), func, bitmask);
  21907. }
  21908. /**
  21909. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21910. * of source objects to the destination object for all destination properties
  21911. * that resolve to `undefined`.
  21912. *
  21913. * @private
  21914. * @param {*} objValue The destination value.
  21915. * @param {*} srcValue The source value.
  21916. * @param {string} key The key of the property to assign.
  21917. * @param {Object} object The parent object of `objValue`.
  21918. * @returns {*} Returns the value to assign.
  21919. */
  21920. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21921. if (objValue === undefined ||
  21922. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21923. return srcValue;
  21924. }
  21925. return objValue;
  21926. }
  21927. /**
  21928. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21929. * objects into destination objects that are passed thru.
  21930. *
  21931. * @private
  21932. * @param {*} objValue The destination value.
  21933. * @param {*} srcValue The source value.
  21934. * @param {string} key The key of the property to merge.
  21935. * @param {Object} object The parent object of `objValue`.
  21936. * @param {Object} source The parent object of `srcValue`.
  21937. * @param {Object} [stack] Tracks traversed source values and their merged
  21938. * counterparts.
  21939. * @returns {*} Returns the value to assign.
  21940. */
  21941. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21942. if (isObject(objValue) && isObject(srcValue)) {
  21943. // Recursively merge objects and arrays (susceptible to call stack limits).
  21944. stack.set(srcValue, objValue);
  21945. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21946. stack['delete'](srcValue);
  21947. }
  21948. return objValue;
  21949. }
  21950. /**
  21951. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21952. * objects.
  21953. *
  21954. * @private
  21955. * @param {*} value The value to inspect.
  21956. * @param {string} key The key of the property to inspect.
  21957. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21958. */
  21959. function customOmitClone(value) {
  21960. return isPlainObject(value) ? undefined : value;
  21961. }
  21962. /**
  21963. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21964. * partial deep comparisons.
  21965. *
  21966. * @private
  21967. * @param {Array} array The array to compare.
  21968. * @param {Array} other The other array to compare.
  21969. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21970. * @param {Function} customizer The function to customize comparisons.
  21971. * @param {Function} equalFunc The function to determine equivalents of values.
  21972. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21973. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21974. */
  21975. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21976. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  21977. arrLength = array.length,
  21978. othLength = other.length;
  21979. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21980. return false;
  21981. }
  21982. // Assume cyclic values are equal.
  21983. var stacked = stack.get(array);
  21984. if (stacked && stack.get(other)) {
  21985. return stacked == other;
  21986. }
  21987. var index = -1,
  21988. result = true,
  21989. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  21990. stack.set(array, other);
  21991. stack.set(other, array);
  21992. // Ignore non-index properties.
  21993. while (++index < arrLength) {
  21994. var arrValue = array[index],
  21995. othValue = other[index];
  21996. if (customizer) {
  21997. var compared = isPartial
  21998. ? customizer(othValue, arrValue, index, other, array, stack)
  21999. : customizer(arrValue, othValue, index, array, other, stack);
  22000. }
  22001. if (compared !== undefined) {
  22002. if (compared) {
  22003. continue;
  22004. }
  22005. result = false;
  22006. break;
  22007. }
  22008. // Recursively compare arrays (susceptible to call stack limits).
  22009. if (seen) {
  22010. if (!arraySome(other, function(othValue, othIndex) {
  22011. if (!cacheHas(seen, othIndex) &&
  22012. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22013. return seen.push(othIndex);
  22014. }
  22015. })) {
  22016. result = false;
  22017. break;
  22018. }
  22019. } else if (!(
  22020. arrValue === othValue ||
  22021. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22022. )) {
  22023. result = false;
  22024. break;
  22025. }
  22026. }
  22027. stack['delete'](array);
  22028. stack['delete'](other);
  22029. return result;
  22030. }
  22031. /**
  22032. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22033. * the same `toStringTag`.
  22034. *
  22035. * **Note:** This function only supports comparing values with tags of
  22036. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22037. *
  22038. * @private
  22039. * @param {Object} object The object to compare.
  22040. * @param {Object} other The other object to compare.
  22041. * @param {string} tag The `toStringTag` of the objects to compare.
  22042. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22043. * @param {Function} customizer The function to customize comparisons.
  22044. * @param {Function} equalFunc The function to determine equivalents of values.
  22045. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22046. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22047. */
  22048. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22049. switch (tag) {
  22050. case dataViewTag:
  22051. if ((object.byteLength != other.byteLength) ||
  22052. (object.byteOffset != other.byteOffset)) {
  22053. return false;
  22054. }
  22055. object = object.buffer;
  22056. other = other.buffer;
  22057. case arrayBufferTag:
  22058. if ((object.byteLength != other.byteLength) ||
  22059. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22060. return false;
  22061. }
  22062. return true;
  22063. case boolTag:
  22064. case dateTag:
  22065. case numberTag:
  22066. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22067. // Invalid dates are coerced to `NaN`.
  22068. return eq(+object, +other);
  22069. case errorTag:
  22070. return object.name == other.name && object.message == other.message;
  22071. case regexpTag:
  22072. case stringTag:
  22073. // Coerce regexes to strings and treat strings, primitives and objects,
  22074. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22075. // for more details.
  22076. return object == (other + '');
  22077. case mapTag:
  22078. var convert = mapToArray;
  22079. case setTag:
  22080. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22081. convert || (convert = setToArray);
  22082. if (object.size != other.size && !isPartial) {
  22083. return false;
  22084. }
  22085. // Assume cyclic values are equal.
  22086. var stacked = stack.get(object);
  22087. if (stacked) {
  22088. return stacked == other;
  22089. }
  22090. bitmask |= COMPARE_UNORDERED_FLAG;
  22091. // Recursively compare objects (susceptible to call stack limits).
  22092. stack.set(object, other);
  22093. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22094. stack['delete'](object);
  22095. return result;
  22096. case symbolTag:
  22097. if (symbolValueOf) {
  22098. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22099. }
  22100. }
  22101. return false;
  22102. }
  22103. /**
  22104. * A specialized version of `baseIsEqualDeep` for objects with support for
  22105. * partial deep comparisons.
  22106. *
  22107. * @private
  22108. * @param {Object} object The object to compare.
  22109. * @param {Object} other The other object to compare.
  22110. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22111. * @param {Function} customizer The function to customize comparisons.
  22112. * @param {Function} equalFunc The function to determine equivalents of values.
  22113. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22114. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22115. */
  22116. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22117. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22118. objProps = getAllKeys(object),
  22119. objLength = objProps.length,
  22120. othProps = getAllKeys(other),
  22121. othLength = othProps.length;
  22122. if (objLength != othLength && !isPartial) {
  22123. return false;
  22124. }
  22125. var index = objLength;
  22126. while (index--) {
  22127. var key = objProps[index];
  22128. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22129. return false;
  22130. }
  22131. }
  22132. // Assume cyclic values are equal.
  22133. var stacked = stack.get(object);
  22134. if (stacked && stack.get(other)) {
  22135. return stacked == other;
  22136. }
  22137. var result = true;
  22138. stack.set(object, other);
  22139. stack.set(other, object);
  22140. var skipCtor = isPartial;
  22141. while (++index < objLength) {
  22142. key = objProps[index];
  22143. var objValue = object[key],
  22144. othValue = other[key];
  22145. if (customizer) {
  22146. var compared = isPartial
  22147. ? customizer(othValue, objValue, key, other, object, stack)
  22148. : customizer(objValue, othValue, key, object, other, stack);
  22149. }
  22150. // Recursively compare objects (susceptible to call stack limits).
  22151. if (!(compared === undefined
  22152. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22153. : compared
  22154. )) {
  22155. result = false;
  22156. break;
  22157. }
  22158. skipCtor || (skipCtor = key == 'constructor');
  22159. }
  22160. if (result && !skipCtor) {
  22161. var objCtor = object.constructor,
  22162. othCtor = other.constructor;
  22163. // Non `Object` object instances with different constructors are not equal.
  22164. if (objCtor != othCtor &&
  22165. ('constructor' in object && 'constructor' in other) &&
  22166. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22167. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22168. result = false;
  22169. }
  22170. }
  22171. stack['delete'](object);
  22172. stack['delete'](other);
  22173. return result;
  22174. }
  22175. /**
  22176. * A specialized version of `baseRest` which flattens the rest array.
  22177. *
  22178. * @private
  22179. * @param {Function} func The function to apply a rest parameter to.
  22180. * @returns {Function} Returns the new function.
  22181. */
  22182. function flatRest(func) {
  22183. return setToString(overRest(func, undefined, flatten), func + '');
  22184. }
  22185. /**
  22186. * Creates an array of own enumerable property names and symbols of `object`.
  22187. *
  22188. * @private
  22189. * @param {Object} object The object to query.
  22190. * @returns {Array} Returns the array of property names and symbols.
  22191. */
  22192. function getAllKeys(object) {
  22193. return baseGetAllKeys(object, keys, getSymbols);
  22194. }
  22195. /**
  22196. * Creates an array of own and inherited enumerable property names and
  22197. * symbols of `object`.
  22198. *
  22199. * @private
  22200. * @param {Object} object The object to query.
  22201. * @returns {Array} Returns the array of property names and symbols.
  22202. */
  22203. function getAllKeysIn(object) {
  22204. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22205. }
  22206. /**
  22207. * Gets metadata for `func`.
  22208. *
  22209. * @private
  22210. * @param {Function} func The function to query.
  22211. * @returns {*} Returns the metadata for `func`.
  22212. */
  22213. var getData = !metaMap ? noop : function(func) {
  22214. return metaMap.get(func);
  22215. };
  22216. /**
  22217. * Gets the name of `func`.
  22218. *
  22219. * @private
  22220. * @param {Function} func The function to query.
  22221. * @returns {string} Returns the function name.
  22222. */
  22223. function getFuncName(func) {
  22224. var result = (func.name + ''),
  22225. array = realNames[result],
  22226. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22227. while (length--) {
  22228. var data = array[length],
  22229. otherFunc = data.func;
  22230. if (otherFunc == null || otherFunc == func) {
  22231. return data.name;
  22232. }
  22233. }
  22234. return result;
  22235. }
  22236. /**
  22237. * Gets the argument placeholder value for `func`.
  22238. *
  22239. * @private
  22240. * @param {Function} func The function to inspect.
  22241. * @returns {*} Returns the placeholder value.
  22242. */
  22243. function getHolder(func) {
  22244. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22245. return object.placeholder;
  22246. }
  22247. /**
  22248. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22249. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22250. * If arguments are provided, the chosen function is invoked with them and
  22251. * its result is returned.
  22252. *
  22253. * @private
  22254. * @param {*} [value] The value to convert to an iteratee.
  22255. * @param {number} [arity] The arity of the created iteratee.
  22256. * @returns {Function} Returns the chosen function or its result.
  22257. */
  22258. function getIteratee() {
  22259. var result = lodash.iteratee || iteratee;
  22260. result = result === iteratee ? baseIteratee : result;
  22261. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22262. }
  22263. /**
  22264. * Gets the data for `map`.
  22265. *
  22266. * @private
  22267. * @param {Object} map The map to query.
  22268. * @param {string} key The reference key.
  22269. * @returns {*} Returns the map data.
  22270. */
  22271. function getMapData(map, key) {
  22272. var data = map.__data__;
  22273. return isKeyable(key)
  22274. ? data[typeof key == 'string' ? 'string' : 'hash']
  22275. : data.map;
  22276. }
  22277. /**
  22278. * Gets the property names, values, and compare flags of `object`.
  22279. *
  22280. * @private
  22281. * @param {Object} object The object to query.
  22282. * @returns {Array} Returns the match data of `object`.
  22283. */
  22284. function getMatchData(object) {
  22285. var result = keys(object),
  22286. length = result.length;
  22287. while (length--) {
  22288. var key = result[length],
  22289. value = object[key];
  22290. result[length] = [key, value, isStrictComparable(value)];
  22291. }
  22292. return result;
  22293. }
  22294. /**
  22295. * Gets the native function at `key` of `object`.
  22296. *
  22297. * @private
  22298. * @param {Object} object The object to query.
  22299. * @param {string} key The key of the method to get.
  22300. * @returns {*} Returns the function if it's native, else `undefined`.
  22301. */
  22302. function getNative(object, key) {
  22303. var value = getValue(object, key);
  22304. return baseIsNative(value) ? value : undefined;
  22305. }
  22306. /**
  22307. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22308. *
  22309. * @private
  22310. * @param {*} value The value to query.
  22311. * @returns {string} Returns the raw `toStringTag`.
  22312. */
  22313. function getRawTag(value) {
  22314. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22315. tag = value[symToStringTag];
  22316. try {
  22317. value[symToStringTag] = undefined;
  22318. var unmasked = true;
  22319. } catch (e) {}
  22320. var result = nativeObjectToString.call(value);
  22321. if (unmasked) {
  22322. if (isOwn) {
  22323. value[symToStringTag] = tag;
  22324. } else {
  22325. delete value[symToStringTag];
  22326. }
  22327. }
  22328. return result;
  22329. }
  22330. /**
  22331. * Creates an array of the own enumerable symbols of `object`.
  22332. *
  22333. * @private
  22334. * @param {Object} object The object to query.
  22335. * @returns {Array} Returns the array of symbols.
  22336. */
  22337. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22338. if (object == null) {
  22339. return [];
  22340. }
  22341. object = Object(object);
  22342. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22343. return propertyIsEnumerable.call(object, symbol);
  22344. });
  22345. };
  22346. /**
  22347. * Creates an array of the own and inherited enumerable symbols of `object`.
  22348. *
  22349. * @private
  22350. * @param {Object} object The object to query.
  22351. * @returns {Array} Returns the array of symbols.
  22352. */
  22353. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22354. var result = [];
  22355. while (object) {
  22356. arrayPush(result, getSymbols(object));
  22357. object = getPrototype(object);
  22358. }
  22359. return result;
  22360. };
  22361. /**
  22362. * Gets the `toStringTag` of `value`.
  22363. *
  22364. * @private
  22365. * @param {*} value The value to query.
  22366. * @returns {string} Returns the `toStringTag`.
  22367. */
  22368. var getTag = baseGetTag;
  22369. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22370. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22371. (Map && getTag(new Map) != mapTag) ||
  22372. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22373. (Set && getTag(new Set) != setTag) ||
  22374. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22375. getTag = function(value) {
  22376. var result = baseGetTag(value),
  22377. Ctor = result == objectTag ? value.constructor : undefined,
  22378. ctorString = Ctor ? toSource(Ctor) : '';
  22379. if (ctorString) {
  22380. switch (ctorString) {
  22381. case dataViewCtorString: return dataViewTag;
  22382. case mapCtorString: return mapTag;
  22383. case promiseCtorString: return promiseTag;
  22384. case setCtorString: return setTag;
  22385. case weakMapCtorString: return weakMapTag;
  22386. }
  22387. }
  22388. return result;
  22389. };
  22390. }
  22391. /**
  22392. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22393. *
  22394. * @private
  22395. * @param {number} start The start of the view.
  22396. * @param {number} end The end of the view.
  22397. * @param {Array} transforms The transformations to apply to the view.
  22398. * @returns {Object} Returns an object containing the `start` and `end`
  22399. * positions of the view.
  22400. */
  22401. function getView(start, end, transforms) {
  22402. var index = -1,
  22403. length = transforms.length;
  22404. while (++index < length) {
  22405. var data = transforms[index],
  22406. size = data.size;
  22407. switch (data.type) {
  22408. case 'drop': start += size; break;
  22409. case 'dropRight': end -= size; break;
  22410. case 'take': end = nativeMin(end, start + size); break;
  22411. case 'takeRight': start = nativeMax(start, end - size); break;
  22412. }
  22413. }
  22414. return { 'start': start, 'end': end };
  22415. }
  22416. /**
  22417. * Extracts wrapper details from the `source` body comment.
  22418. *
  22419. * @private
  22420. * @param {string} source The source to inspect.
  22421. * @returns {Array} Returns the wrapper details.
  22422. */
  22423. function getWrapDetails(source) {
  22424. var match = source.match(reWrapDetails);
  22425. return match ? match[1].split(reSplitDetails) : [];
  22426. }
  22427. /**
  22428. * Checks if `path` exists on `object`.
  22429. *
  22430. * @private
  22431. * @param {Object} object The object to query.
  22432. * @param {Array|string} path The path to check.
  22433. * @param {Function} hasFunc The function to check properties.
  22434. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22435. */
  22436. function hasPath(object, path, hasFunc) {
  22437. path = castPath(path, object);
  22438. var index = -1,
  22439. length = path.length,
  22440. result = false;
  22441. while (++index < length) {
  22442. var key = toKey(path[index]);
  22443. if (!(result = object != null && hasFunc(object, key))) {
  22444. break;
  22445. }
  22446. object = object[key];
  22447. }
  22448. if (result || ++index != length) {
  22449. return result;
  22450. }
  22451. length = object == null ? 0 : object.length;
  22452. return !!length && isLength(length) && isIndex(key, length) &&
  22453. (isArray(object) || isArguments(object));
  22454. }
  22455. /**
  22456. * Initializes an array clone.
  22457. *
  22458. * @private
  22459. * @param {Array} array The array to clone.
  22460. * @returns {Array} Returns the initialized clone.
  22461. */
  22462. function initCloneArray(array) {
  22463. var length = array.length,
  22464. result = new array.constructor(length);
  22465. // Add properties assigned by `RegExp#exec`.
  22466. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22467. result.index = array.index;
  22468. result.input = array.input;
  22469. }
  22470. return result;
  22471. }
  22472. /**
  22473. * Initializes an object clone.
  22474. *
  22475. * @private
  22476. * @param {Object} object The object to clone.
  22477. * @returns {Object} Returns the initialized clone.
  22478. */
  22479. function initCloneObject(object) {
  22480. return (typeof object.constructor == 'function' && !isPrototype(object))
  22481. ? baseCreate(getPrototype(object))
  22482. : {};
  22483. }
  22484. /**
  22485. * Initializes an object clone based on its `toStringTag`.
  22486. *
  22487. * **Note:** This function only supports cloning values with tags of
  22488. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22489. *
  22490. * @private
  22491. * @param {Object} object The object to clone.
  22492. * @param {string} tag The `toStringTag` of the object to clone.
  22493. * @param {boolean} [isDeep] Specify a deep clone.
  22494. * @returns {Object} Returns the initialized clone.
  22495. */
  22496. function initCloneByTag(object, tag, isDeep) {
  22497. var Ctor = object.constructor;
  22498. switch (tag) {
  22499. case arrayBufferTag:
  22500. return cloneArrayBuffer(object);
  22501. case boolTag:
  22502. case dateTag:
  22503. return new Ctor(+object);
  22504. case dataViewTag:
  22505. return cloneDataView(object, isDeep);
  22506. case float32Tag: case float64Tag:
  22507. case int8Tag: case int16Tag: case int32Tag:
  22508. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22509. return cloneTypedArray(object, isDeep);
  22510. case mapTag:
  22511. return new Ctor;
  22512. case numberTag:
  22513. case stringTag:
  22514. return new Ctor(object);
  22515. case regexpTag:
  22516. return cloneRegExp(object);
  22517. case setTag:
  22518. return new Ctor;
  22519. case symbolTag:
  22520. return cloneSymbol(object);
  22521. }
  22522. }
  22523. /**
  22524. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22525. *
  22526. * @private
  22527. * @param {string} source The source to modify.
  22528. * @returns {Array} details The details to insert.
  22529. * @returns {string} Returns the modified source.
  22530. */
  22531. function insertWrapDetails(source, details) {
  22532. var length = details.length;
  22533. if (!length) {
  22534. return source;
  22535. }
  22536. var lastIndex = length - 1;
  22537. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22538. details = details.join(length > 2 ? ', ' : ' ');
  22539. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22540. }
  22541. /**
  22542. * Checks if `value` is a flattenable `arguments` object or array.
  22543. *
  22544. * @private
  22545. * @param {*} value The value to check.
  22546. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22547. */
  22548. function isFlattenable(value) {
  22549. return isArray(value) || isArguments(value) ||
  22550. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22551. }
  22552. /**
  22553. * Checks if `value` is a valid array-like index.
  22554. *
  22555. * @private
  22556. * @param {*} value The value to check.
  22557. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22558. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22559. */
  22560. function isIndex(value, length) {
  22561. var type = typeof value;
  22562. length = length == null ? MAX_SAFE_INTEGER : length;
  22563. return !!length &&
  22564. (type == 'number' ||
  22565. (type != 'symbol' && reIsUint.test(value))) &&
  22566. (value > -1 && value % 1 == 0 && value < length);
  22567. }
  22568. /**
  22569. * Checks if the given arguments are from an iteratee call.
  22570. *
  22571. * @private
  22572. * @param {*} value The potential iteratee value argument.
  22573. * @param {*} index The potential iteratee index or key argument.
  22574. * @param {*} object The potential iteratee object argument.
  22575. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22576. * else `false`.
  22577. */
  22578. function isIterateeCall(value, index, object) {
  22579. if (!isObject(object)) {
  22580. return false;
  22581. }
  22582. var type = typeof index;
  22583. if (type == 'number'
  22584. ? (isArrayLike(object) && isIndex(index, object.length))
  22585. : (type == 'string' && index in object)
  22586. ) {
  22587. return eq(object[index], value);
  22588. }
  22589. return false;
  22590. }
  22591. /**
  22592. * Checks if `value` is a property name and not a property path.
  22593. *
  22594. * @private
  22595. * @param {*} value The value to check.
  22596. * @param {Object} [object] The object to query keys on.
  22597. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22598. */
  22599. function isKey(value, object) {
  22600. if (isArray(value)) {
  22601. return false;
  22602. }
  22603. var type = typeof value;
  22604. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22605. value == null || isSymbol(value)) {
  22606. return true;
  22607. }
  22608. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22609. (object != null && value in Object(object));
  22610. }
  22611. /**
  22612. * Checks if `value` is suitable for use as unique object key.
  22613. *
  22614. * @private
  22615. * @param {*} value The value to check.
  22616. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22617. */
  22618. function isKeyable(value) {
  22619. var type = typeof value;
  22620. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22621. ? (value !== '__proto__')
  22622. : (value === null);
  22623. }
  22624. /**
  22625. * Checks if `func` has a lazy counterpart.
  22626. *
  22627. * @private
  22628. * @param {Function} func The function to check.
  22629. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22630. * else `false`.
  22631. */
  22632. function isLaziable(func) {
  22633. var funcName = getFuncName(func),
  22634. other = lodash[funcName];
  22635. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22636. return false;
  22637. }
  22638. if (func === other) {
  22639. return true;
  22640. }
  22641. var data = getData(other);
  22642. return !!data && func === data[0];
  22643. }
  22644. /**
  22645. * Checks if `func` has its source masked.
  22646. *
  22647. * @private
  22648. * @param {Function} func The function to check.
  22649. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22650. */
  22651. function isMasked(func) {
  22652. return !!maskSrcKey && (maskSrcKey in func);
  22653. }
  22654. /**
  22655. * Checks if `func` is capable of being masked.
  22656. *
  22657. * @private
  22658. * @param {*} value The value to check.
  22659. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22660. */
  22661. var isMaskable = coreJsData ? isFunction : stubFalse;
  22662. /**
  22663. * Checks if `value` is likely a prototype object.
  22664. *
  22665. * @private
  22666. * @param {*} value The value to check.
  22667. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22668. */
  22669. function isPrototype(value) {
  22670. var Ctor = value && value.constructor,
  22671. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22672. return value === proto;
  22673. }
  22674. /**
  22675. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22676. *
  22677. * @private
  22678. * @param {*} value The value to check.
  22679. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22680. * equality comparisons, else `false`.
  22681. */
  22682. function isStrictComparable(value) {
  22683. return value === value && !isObject(value);
  22684. }
  22685. /**
  22686. * A specialized version of `matchesProperty` for source values suitable
  22687. * for strict equality comparisons, i.e. `===`.
  22688. *
  22689. * @private
  22690. * @param {string} key The key of the property to get.
  22691. * @param {*} srcValue The value to match.
  22692. * @returns {Function} Returns the new spec function.
  22693. */
  22694. function matchesStrictComparable(key, srcValue) {
  22695. return function(object) {
  22696. if (object == null) {
  22697. return false;
  22698. }
  22699. return object[key] === srcValue &&
  22700. (srcValue !== undefined || (key in Object(object)));
  22701. };
  22702. }
  22703. /**
  22704. * A specialized version of `_.memoize` which clears the memoized function's
  22705. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22706. *
  22707. * @private
  22708. * @param {Function} func The function to have its output memoized.
  22709. * @returns {Function} Returns the new memoized function.
  22710. */
  22711. function memoizeCapped(func) {
  22712. var result = memoize(func, function(key) {
  22713. if (cache.size === MAX_MEMOIZE_SIZE) {
  22714. cache.clear();
  22715. }
  22716. return key;
  22717. });
  22718. var cache = result.cache;
  22719. return result;
  22720. }
  22721. /**
  22722. * Merges the function metadata of `source` into `data`.
  22723. *
  22724. * Merging metadata reduces the number of wrappers used to invoke a function.
  22725. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22726. * may be applied regardless of execution order. Methods like `_.ary` and
  22727. * `_.rearg` modify function arguments, making the order in which they are
  22728. * executed important, preventing the merging of metadata. However, we make
  22729. * an exception for a safe combined case where curried functions have `_.ary`
  22730. * and or `_.rearg` applied.
  22731. *
  22732. * @private
  22733. * @param {Array} data The destination metadata.
  22734. * @param {Array} source The source metadata.
  22735. * @returns {Array} Returns `data`.
  22736. */
  22737. function mergeData(data, source) {
  22738. var bitmask = data[1],
  22739. srcBitmask = source[1],
  22740. newBitmask = bitmask | srcBitmask,
  22741. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22742. var isCombo =
  22743. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22744. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22745. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22746. // Exit early if metadata can't be merged.
  22747. if (!(isCommon || isCombo)) {
  22748. return data;
  22749. }
  22750. // Use source `thisArg` if available.
  22751. if (srcBitmask & WRAP_BIND_FLAG) {
  22752. data[2] = source[2];
  22753. // Set when currying a bound function.
  22754. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22755. }
  22756. // Compose partial arguments.
  22757. var value = source[3];
  22758. if (value) {
  22759. var partials = data[3];
  22760. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22761. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22762. }
  22763. // Compose partial right arguments.
  22764. value = source[5];
  22765. if (value) {
  22766. partials = data[5];
  22767. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22768. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22769. }
  22770. // Use source `argPos` if available.
  22771. value = source[7];
  22772. if (value) {
  22773. data[7] = value;
  22774. }
  22775. // Use source `ary` if it's smaller.
  22776. if (srcBitmask & WRAP_ARY_FLAG) {
  22777. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22778. }
  22779. // Use source `arity` if one is not provided.
  22780. if (data[9] == null) {
  22781. data[9] = source[9];
  22782. }
  22783. // Use source `func` and merge bitmasks.
  22784. data[0] = source[0];
  22785. data[1] = newBitmask;
  22786. return data;
  22787. }
  22788. /**
  22789. * This function is like
  22790. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22791. * except that it includes inherited enumerable properties.
  22792. *
  22793. * @private
  22794. * @param {Object} object The object to query.
  22795. * @returns {Array} Returns the array of property names.
  22796. */
  22797. function nativeKeysIn(object) {
  22798. var result = [];
  22799. if (object != null) {
  22800. for (var key in Object(object)) {
  22801. result.push(key);
  22802. }
  22803. }
  22804. return result;
  22805. }
  22806. /**
  22807. * Converts `value` to a string using `Object.prototype.toString`.
  22808. *
  22809. * @private
  22810. * @param {*} value The value to convert.
  22811. * @returns {string} Returns the converted string.
  22812. */
  22813. function objectToString(value) {
  22814. return nativeObjectToString.call(value);
  22815. }
  22816. /**
  22817. * A specialized version of `baseRest` which transforms the rest array.
  22818. *
  22819. * @private
  22820. * @param {Function} func The function to apply a rest parameter to.
  22821. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22822. * @param {Function} transform The rest array transform.
  22823. * @returns {Function} Returns the new function.
  22824. */
  22825. function overRest(func, start, transform) {
  22826. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22827. return function() {
  22828. var args = arguments,
  22829. index = -1,
  22830. length = nativeMax(args.length - start, 0),
  22831. array = Array(length);
  22832. while (++index < length) {
  22833. array[index] = args[start + index];
  22834. }
  22835. index = -1;
  22836. var otherArgs = Array(start + 1);
  22837. while (++index < start) {
  22838. otherArgs[index] = args[index];
  22839. }
  22840. otherArgs[start] = transform(array);
  22841. return apply(func, this, otherArgs);
  22842. };
  22843. }
  22844. /**
  22845. * Gets the parent value at `path` of `object`.
  22846. *
  22847. * @private
  22848. * @param {Object} object The object to query.
  22849. * @param {Array} path The path to get the parent value of.
  22850. * @returns {*} Returns the parent value.
  22851. */
  22852. function parent(object, path) {
  22853. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22854. }
  22855. /**
  22856. * Reorder `array` according to the specified indexes where the element at
  22857. * the first index is assigned as the first element, the element at
  22858. * the second index is assigned as the second element, and so on.
  22859. *
  22860. * @private
  22861. * @param {Array} array The array to reorder.
  22862. * @param {Array} indexes The arranged array indexes.
  22863. * @returns {Array} Returns `array`.
  22864. */
  22865. function reorder(array, indexes) {
  22866. var arrLength = array.length,
  22867. length = nativeMin(indexes.length, arrLength),
  22868. oldArray = copyArray(array);
  22869. while (length--) {
  22870. var index = indexes[length];
  22871. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22872. }
  22873. return array;
  22874. }
  22875. /**
  22876. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22877. *
  22878. * @private
  22879. * @param {Object} object The object to query.
  22880. * @param {string} key The key of the property to get.
  22881. * @returns {*} Returns the property value.
  22882. */
  22883. function safeGet(object, key) {
  22884. if (key === 'constructor' && typeof object[key] === 'function') {
  22885. return;
  22886. }
  22887. if (key == '__proto__') {
  22888. return;
  22889. }
  22890. return object[key];
  22891. }
  22892. /**
  22893. * Sets metadata for `func`.
  22894. *
  22895. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22896. * period of time, it will trip its breaker and transition to an identity
  22897. * function to avoid garbage collection pauses in V8. See
  22898. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22899. * for more details.
  22900. *
  22901. * @private
  22902. * @param {Function} func The function to associate metadata with.
  22903. * @param {*} data The metadata.
  22904. * @returns {Function} Returns `func`.
  22905. */
  22906. var setData = shortOut(baseSetData);
  22907. /**
  22908. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22909. *
  22910. * @private
  22911. * @param {Function} func The function to delay.
  22912. * @param {number} wait The number of milliseconds to delay invocation.
  22913. * @returns {number|Object} Returns the timer id or timeout object.
  22914. */
  22915. var setTimeout = ctxSetTimeout || function(func, wait) {
  22916. return root.setTimeout(func, wait);
  22917. };
  22918. /**
  22919. * Sets the `toString` method of `func` to return `string`.
  22920. *
  22921. * @private
  22922. * @param {Function} func The function to modify.
  22923. * @param {Function} string The `toString` result.
  22924. * @returns {Function} Returns `func`.
  22925. */
  22926. var setToString = shortOut(baseSetToString);
  22927. /**
  22928. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22929. * with wrapper details in a comment at the top of the source body.
  22930. *
  22931. * @private
  22932. * @param {Function} wrapper The function to modify.
  22933. * @param {Function} reference The reference function.
  22934. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22935. * @returns {Function} Returns `wrapper`.
  22936. */
  22937. function setWrapToString(wrapper, reference, bitmask) {
  22938. var source = (reference + '');
  22939. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22940. }
  22941. /**
  22942. * Creates a function that'll short out and invoke `identity` instead
  22943. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22944. * milliseconds.
  22945. *
  22946. * @private
  22947. * @param {Function} func The function to restrict.
  22948. * @returns {Function} Returns the new shortable function.
  22949. */
  22950. function shortOut(func) {
  22951. var count = 0,
  22952. lastCalled = 0;
  22953. return function() {
  22954. var stamp = nativeNow(),
  22955. remaining = HOT_SPAN - (stamp - lastCalled);
  22956. lastCalled = stamp;
  22957. if (remaining > 0) {
  22958. if (++count >= HOT_COUNT) {
  22959. return arguments[0];
  22960. }
  22961. } else {
  22962. count = 0;
  22963. }
  22964. return func.apply(undefined, arguments);
  22965. };
  22966. }
  22967. /**
  22968. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  22969. *
  22970. * @private
  22971. * @param {Array} array The array to shuffle.
  22972. * @param {number} [size=array.length] The size of `array`.
  22973. * @returns {Array} Returns `array`.
  22974. */
  22975. function shuffleSelf(array, size) {
  22976. var index = -1,
  22977. length = array.length,
  22978. lastIndex = length - 1;
  22979. size = size === undefined ? length : size;
  22980. while (++index < size) {
  22981. var rand = baseRandom(index, lastIndex),
  22982. value = array[rand];
  22983. array[rand] = array[index];
  22984. array[index] = value;
  22985. }
  22986. array.length = size;
  22987. return array;
  22988. }
  22989. /**
  22990. * Converts `string` to a property path array.
  22991. *
  22992. * @private
  22993. * @param {string} string The string to convert.
  22994. * @returns {Array} Returns the property path array.
  22995. */
  22996. var stringToPath = memoizeCapped(function(string) {
  22997. var result = [];
  22998. if (string.charCodeAt(0) === 46 /* . */) {
  22999. result.push('');
  23000. }
  23001. string.replace(rePropName, function(match, number, quote, subString) {
  23002. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23003. });
  23004. return result;
  23005. });
  23006. /**
  23007. * Converts `value` to a string key if it's not a string or symbol.
  23008. *
  23009. * @private
  23010. * @param {*} value The value to inspect.
  23011. * @returns {string|symbol} Returns the key.
  23012. */
  23013. function toKey(value) {
  23014. if (typeof value == 'string' || isSymbol(value)) {
  23015. return value;
  23016. }
  23017. var result = (value + '');
  23018. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23019. }
  23020. /**
  23021. * Converts `func` to its source code.
  23022. *
  23023. * @private
  23024. * @param {Function} func The function to convert.
  23025. * @returns {string} Returns the source code.
  23026. */
  23027. function toSource(func) {
  23028. if (func != null) {
  23029. try {
  23030. return funcToString.call(func);
  23031. } catch (e) {}
  23032. try {
  23033. return (func + '');
  23034. } catch (e) {}
  23035. }
  23036. return '';
  23037. }
  23038. /**
  23039. * Updates wrapper `details` based on `bitmask` flags.
  23040. *
  23041. * @private
  23042. * @returns {Array} details The details to modify.
  23043. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23044. * @returns {Array} Returns `details`.
  23045. */
  23046. function updateWrapDetails(details, bitmask) {
  23047. arrayEach(wrapFlags, function(pair) {
  23048. var value = '_.' + pair[0];
  23049. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23050. details.push(value);
  23051. }
  23052. });
  23053. return details.sort();
  23054. }
  23055. /**
  23056. * Creates a clone of `wrapper`.
  23057. *
  23058. * @private
  23059. * @param {Object} wrapper The wrapper to clone.
  23060. * @returns {Object} Returns the cloned wrapper.
  23061. */
  23062. function wrapperClone(wrapper) {
  23063. if (wrapper instanceof LazyWrapper) {
  23064. return wrapper.clone();
  23065. }
  23066. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23067. result.__actions__ = copyArray(wrapper.__actions__);
  23068. result.__index__ = wrapper.__index__;
  23069. result.__values__ = wrapper.__values__;
  23070. return result;
  23071. }
  23072. /*------------------------------------------------------------------------*/
  23073. /**
  23074. * Creates an array of elements split into groups the length of `size`.
  23075. * If `array` can't be split evenly, the final chunk will be the remaining
  23076. * elements.
  23077. *
  23078. * @static
  23079. * @memberOf _
  23080. * @since 3.0.0
  23081. * @category Array
  23082. * @param {Array} array The array to process.
  23083. * @param {number} [size=1] The length of each chunk
  23084. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23085. * @returns {Array} Returns the new array of chunks.
  23086. * @example
  23087. *
  23088. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23089. * // => [['a', 'b'], ['c', 'd']]
  23090. *
  23091. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23092. * // => [['a', 'b', 'c'], ['d']]
  23093. */
  23094. function chunk(array, size, guard) {
  23095. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23096. size = 1;
  23097. } else {
  23098. size = nativeMax(toInteger(size), 0);
  23099. }
  23100. var length = array == null ? 0 : array.length;
  23101. if (!length || size < 1) {
  23102. return [];
  23103. }
  23104. var index = 0,
  23105. resIndex = 0,
  23106. result = Array(nativeCeil(length / size));
  23107. while (index < length) {
  23108. result[resIndex++] = baseSlice(array, index, (index += size));
  23109. }
  23110. return result;
  23111. }
  23112. /**
  23113. * Creates an array with all falsey values removed. The values `false`, `null`,
  23114. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23115. *
  23116. * @static
  23117. * @memberOf _
  23118. * @since 0.1.0
  23119. * @category Array
  23120. * @param {Array} array The array to compact.
  23121. * @returns {Array} Returns the new array of filtered values.
  23122. * @example
  23123. *
  23124. * _.compact([0, 1, false, 2, '', 3]);
  23125. * // => [1, 2, 3]
  23126. */
  23127. function compact(array) {
  23128. var index = -1,
  23129. length = array == null ? 0 : array.length,
  23130. resIndex = 0,
  23131. result = [];
  23132. while (++index < length) {
  23133. var value = array[index];
  23134. if (value) {
  23135. result[resIndex++] = value;
  23136. }
  23137. }
  23138. return result;
  23139. }
  23140. /**
  23141. * Creates a new array concatenating `array` with any additional arrays
  23142. * and/or values.
  23143. *
  23144. * @static
  23145. * @memberOf _
  23146. * @since 4.0.0
  23147. * @category Array
  23148. * @param {Array} array The array to concatenate.
  23149. * @param {...*} [values] The values to concatenate.
  23150. * @returns {Array} Returns the new concatenated array.
  23151. * @example
  23152. *
  23153. * var array = [1];
  23154. * var other = _.concat(array, 2, [3], [[4]]);
  23155. *
  23156. * console.log(other);
  23157. * // => [1, 2, 3, [4]]
  23158. *
  23159. * console.log(array);
  23160. * // => [1]
  23161. */
  23162. function concat() {
  23163. var length = arguments.length;
  23164. if (!length) {
  23165. return [];
  23166. }
  23167. var args = Array(length - 1),
  23168. array = arguments[0],
  23169. index = length;
  23170. while (index--) {
  23171. args[index - 1] = arguments[index];
  23172. }
  23173. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23174. }
  23175. /**
  23176. * Creates an array of `array` values not included in the other given arrays
  23177. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23178. * for equality comparisons. The order and references of result values are
  23179. * determined by the first array.
  23180. *
  23181. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23182. *
  23183. * @static
  23184. * @memberOf _
  23185. * @since 0.1.0
  23186. * @category Array
  23187. * @param {Array} array The array to inspect.
  23188. * @param {...Array} [values] The values to exclude.
  23189. * @returns {Array} Returns the new array of filtered values.
  23190. * @see _.without, _.xor
  23191. * @example
  23192. *
  23193. * _.difference([2, 1], [2, 3]);
  23194. * // => [1]
  23195. */
  23196. var difference = baseRest(function(array, values) {
  23197. return isArrayLikeObject(array)
  23198. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23199. : [];
  23200. });
  23201. /**
  23202. * This method is like `_.difference` except that it accepts `iteratee` which
  23203. * is invoked for each element of `array` and `values` to generate the criterion
  23204. * by which they're compared. The order and references of result values are
  23205. * determined by the first array. The iteratee is invoked with one argument:
  23206. * (value).
  23207. *
  23208. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23209. *
  23210. * @static
  23211. * @memberOf _
  23212. * @since 4.0.0
  23213. * @category Array
  23214. * @param {Array} array The array to inspect.
  23215. * @param {...Array} [values] The values to exclude.
  23216. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23217. * @returns {Array} Returns the new array of filtered values.
  23218. * @example
  23219. *
  23220. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23221. * // => [1.2]
  23222. *
  23223. * // The `_.property` iteratee shorthand.
  23224. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23225. * // => [{ 'x': 2 }]
  23226. */
  23227. var differenceBy = baseRest(function(array, values) {
  23228. var iteratee = last(values);
  23229. if (isArrayLikeObject(iteratee)) {
  23230. iteratee = undefined;
  23231. }
  23232. return isArrayLikeObject(array)
  23233. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23234. : [];
  23235. });
  23236. /**
  23237. * This method is like `_.difference` except that it accepts `comparator`
  23238. * which is invoked to compare elements of `array` to `values`. The order and
  23239. * references of result values are determined by the first array. The comparator
  23240. * is invoked with two arguments: (arrVal, othVal).
  23241. *
  23242. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23243. *
  23244. * @static
  23245. * @memberOf _
  23246. * @since 4.0.0
  23247. * @category Array
  23248. * @param {Array} array The array to inspect.
  23249. * @param {...Array} [values] The values to exclude.
  23250. * @param {Function} [comparator] The comparator invoked per element.
  23251. * @returns {Array} Returns the new array of filtered values.
  23252. * @example
  23253. *
  23254. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23255. *
  23256. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23257. * // => [{ 'x': 2, 'y': 1 }]
  23258. */
  23259. var differenceWith = baseRest(function(array, values) {
  23260. var comparator = last(values);
  23261. if (isArrayLikeObject(comparator)) {
  23262. comparator = undefined;
  23263. }
  23264. return isArrayLikeObject(array)
  23265. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23266. : [];
  23267. });
  23268. /**
  23269. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23270. *
  23271. * @static
  23272. * @memberOf _
  23273. * @since 0.5.0
  23274. * @category Array
  23275. * @param {Array} array The array to query.
  23276. * @param {number} [n=1] The number of elements to drop.
  23277. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23278. * @returns {Array} Returns the slice of `array`.
  23279. * @example
  23280. *
  23281. * _.drop([1, 2, 3]);
  23282. * // => [2, 3]
  23283. *
  23284. * _.drop([1, 2, 3], 2);
  23285. * // => [3]
  23286. *
  23287. * _.drop([1, 2, 3], 5);
  23288. * // => []
  23289. *
  23290. * _.drop([1, 2, 3], 0);
  23291. * // => [1, 2, 3]
  23292. */
  23293. function drop(array, n, guard) {
  23294. var length = array == null ? 0 : array.length;
  23295. if (!length) {
  23296. return [];
  23297. }
  23298. n = (guard || n === undefined) ? 1 : toInteger(n);
  23299. return baseSlice(array, n < 0 ? 0 : n, length);
  23300. }
  23301. /**
  23302. * Creates a slice of `array` with `n` elements dropped from the end.
  23303. *
  23304. * @static
  23305. * @memberOf _
  23306. * @since 3.0.0
  23307. * @category Array
  23308. * @param {Array} array The array to query.
  23309. * @param {number} [n=1] The number of elements to drop.
  23310. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23311. * @returns {Array} Returns the slice of `array`.
  23312. * @example
  23313. *
  23314. * _.dropRight([1, 2, 3]);
  23315. * // => [1, 2]
  23316. *
  23317. * _.dropRight([1, 2, 3], 2);
  23318. * // => [1]
  23319. *
  23320. * _.dropRight([1, 2, 3], 5);
  23321. * // => []
  23322. *
  23323. * _.dropRight([1, 2, 3], 0);
  23324. * // => [1, 2, 3]
  23325. */
  23326. function dropRight(array, n, guard) {
  23327. var length = array == null ? 0 : array.length;
  23328. if (!length) {
  23329. return [];
  23330. }
  23331. n = (guard || n === undefined) ? 1 : toInteger(n);
  23332. n = length - n;
  23333. return baseSlice(array, 0, n < 0 ? 0 : n);
  23334. }
  23335. /**
  23336. * Creates a slice of `array` excluding elements dropped from the end.
  23337. * Elements are dropped until `predicate` returns falsey. The predicate is
  23338. * invoked with three arguments: (value, index, array).
  23339. *
  23340. * @static
  23341. * @memberOf _
  23342. * @since 3.0.0
  23343. * @category Array
  23344. * @param {Array} array The array to query.
  23345. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23346. * @returns {Array} Returns the slice of `array`.
  23347. * @example
  23348. *
  23349. * var users = [
  23350. * { 'user': 'barney', 'active': true },
  23351. * { 'user': 'fred', 'active': false },
  23352. * { 'user': 'pebbles', 'active': false }
  23353. * ];
  23354. *
  23355. * _.dropRightWhile(users, function(o) { return !o.active; });
  23356. * // => objects for ['barney']
  23357. *
  23358. * // The `_.matches` iteratee shorthand.
  23359. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23360. * // => objects for ['barney', 'fred']
  23361. *
  23362. * // The `_.matchesProperty` iteratee shorthand.
  23363. * _.dropRightWhile(users, ['active', false]);
  23364. * // => objects for ['barney']
  23365. *
  23366. * // The `_.property` iteratee shorthand.
  23367. * _.dropRightWhile(users, 'active');
  23368. * // => objects for ['barney', 'fred', 'pebbles']
  23369. */
  23370. function dropRightWhile(array, predicate) {
  23371. return (array && array.length)
  23372. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23373. : [];
  23374. }
  23375. /**
  23376. * Creates a slice of `array` excluding elements dropped from the beginning.
  23377. * Elements are dropped until `predicate` returns falsey. The predicate is
  23378. * invoked with three arguments: (value, index, array).
  23379. *
  23380. * @static
  23381. * @memberOf _
  23382. * @since 3.0.0
  23383. * @category Array
  23384. * @param {Array} array The array to query.
  23385. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23386. * @returns {Array} Returns the slice of `array`.
  23387. * @example
  23388. *
  23389. * var users = [
  23390. * { 'user': 'barney', 'active': false },
  23391. * { 'user': 'fred', 'active': false },
  23392. * { 'user': 'pebbles', 'active': true }
  23393. * ];
  23394. *
  23395. * _.dropWhile(users, function(o) { return !o.active; });
  23396. * // => objects for ['pebbles']
  23397. *
  23398. * // The `_.matches` iteratee shorthand.
  23399. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23400. * // => objects for ['fred', 'pebbles']
  23401. *
  23402. * // The `_.matchesProperty` iteratee shorthand.
  23403. * _.dropWhile(users, ['active', false]);
  23404. * // => objects for ['pebbles']
  23405. *
  23406. * // The `_.property` iteratee shorthand.
  23407. * _.dropWhile(users, 'active');
  23408. * // => objects for ['barney', 'fred', 'pebbles']
  23409. */
  23410. function dropWhile(array, predicate) {
  23411. return (array && array.length)
  23412. ? baseWhile(array, getIteratee(predicate, 3), true)
  23413. : [];
  23414. }
  23415. /**
  23416. * Fills elements of `array` with `value` from `start` up to, but not
  23417. * including, `end`.
  23418. *
  23419. * **Note:** This method mutates `array`.
  23420. *
  23421. * @static
  23422. * @memberOf _
  23423. * @since 3.2.0
  23424. * @category Array
  23425. * @param {Array} array The array to fill.
  23426. * @param {*} value The value to fill `array` with.
  23427. * @param {number} [start=0] The start position.
  23428. * @param {number} [end=array.length] The end position.
  23429. * @returns {Array} Returns `array`.
  23430. * @example
  23431. *
  23432. * var array = [1, 2, 3];
  23433. *
  23434. * _.fill(array, 'a');
  23435. * console.log(array);
  23436. * // => ['a', 'a', 'a']
  23437. *
  23438. * _.fill(Array(3), 2);
  23439. * // => [2, 2, 2]
  23440. *
  23441. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23442. * // => [4, '*', '*', 10]
  23443. */
  23444. function fill(array, value, start, end) {
  23445. var length = array == null ? 0 : array.length;
  23446. if (!length) {
  23447. return [];
  23448. }
  23449. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23450. start = 0;
  23451. end = length;
  23452. }
  23453. return baseFill(array, value, start, end);
  23454. }
  23455. /**
  23456. * This method is like `_.find` except that it returns the index of the first
  23457. * element `predicate` returns truthy for instead of the element itself.
  23458. *
  23459. * @static
  23460. * @memberOf _
  23461. * @since 1.1.0
  23462. * @category Array
  23463. * @param {Array} array The array to inspect.
  23464. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23465. * @param {number} [fromIndex=0] The index to search from.
  23466. * @returns {number} Returns the index of the found element, else `-1`.
  23467. * @example
  23468. *
  23469. * var users = [
  23470. * { 'user': 'barney', 'active': false },
  23471. * { 'user': 'fred', 'active': false },
  23472. * { 'user': 'pebbles', 'active': true }
  23473. * ];
  23474. *
  23475. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23476. * // => 0
  23477. *
  23478. * // The `_.matches` iteratee shorthand.
  23479. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23480. * // => 1
  23481. *
  23482. * // The `_.matchesProperty` iteratee shorthand.
  23483. * _.findIndex(users, ['active', false]);
  23484. * // => 0
  23485. *
  23486. * // The `_.property` iteratee shorthand.
  23487. * _.findIndex(users, 'active');
  23488. * // => 2
  23489. */
  23490. function findIndex(array, predicate, fromIndex) {
  23491. var length = array == null ? 0 : array.length;
  23492. if (!length) {
  23493. return -1;
  23494. }
  23495. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23496. if (index < 0) {
  23497. index = nativeMax(length + index, 0);
  23498. }
  23499. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23500. }
  23501. /**
  23502. * This method is like `_.findIndex` except that it iterates over elements
  23503. * of `collection` from right to left.
  23504. *
  23505. * @static
  23506. * @memberOf _
  23507. * @since 2.0.0
  23508. * @category Array
  23509. * @param {Array} array The array to inspect.
  23510. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23511. * @param {number} [fromIndex=array.length-1] The index to search from.
  23512. * @returns {number} Returns the index of the found element, else `-1`.
  23513. * @example
  23514. *
  23515. * var users = [
  23516. * { 'user': 'barney', 'active': true },
  23517. * { 'user': 'fred', 'active': false },
  23518. * { 'user': 'pebbles', 'active': false }
  23519. * ];
  23520. *
  23521. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23522. * // => 2
  23523. *
  23524. * // The `_.matches` iteratee shorthand.
  23525. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23526. * // => 0
  23527. *
  23528. * // The `_.matchesProperty` iteratee shorthand.
  23529. * _.findLastIndex(users, ['active', false]);
  23530. * // => 2
  23531. *
  23532. * // The `_.property` iteratee shorthand.
  23533. * _.findLastIndex(users, 'active');
  23534. * // => 0
  23535. */
  23536. function findLastIndex(array, predicate, fromIndex) {
  23537. var length = array == null ? 0 : array.length;
  23538. if (!length) {
  23539. return -1;
  23540. }
  23541. var index = length - 1;
  23542. if (fromIndex !== undefined) {
  23543. index = toInteger(fromIndex);
  23544. index = fromIndex < 0
  23545. ? nativeMax(length + index, 0)
  23546. : nativeMin(index, length - 1);
  23547. }
  23548. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23549. }
  23550. /**
  23551. * Flattens `array` a single level deep.
  23552. *
  23553. * @static
  23554. * @memberOf _
  23555. * @since 0.1.0
  23556. * @category Array
  23557. * @param {Array} array The array to flatten.
  23558. * @returns {Array} Returns the new flattened array.
  23559. * @example
  23560. *
  23561. * _.flatten([1, [2, [3, [4]], 5]]);
  23562. * // => [1, 2, [3, [4]], 5]
  23563. */
  23564. function flatten(array) {
  23565. var length = array == null ? 0 : array.length;
  23566. return length ? baseFlatten(array, 1) : [];
  23567. }
  23568. /**
  23569. * Recursively flattens `array`.
  23570. *
  23571. * @static
  23572. * @memberOf _
  23573. * @since 3.0.0
  23574. * @category Array
  23575. * @param {Array} array The array to flatten.
  23576. * @returns {Array} Returns the new flattened array.
  23577. * @example
  23578. *
  23579. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23580. * // => [1, 2, 3, 4, 5]
  23581. */
  23582. function flattenDeep(array) {
  23583. var length = array == null ? 0 : array.length;
  23584. return length ? baseFlatten(array, INFINITY) : [];
  23585. }
  23586. /**
  23587. * Recursively flatten `array` up to `depth` times.
  23588. *
  23589. * @static
  23590. * @memberOf _
  23591. * @since 4.4.0
  23592. * @category Array
  23593. * @param {Array} array The array to flatten.
  23594. * @param {number} [depth=1] The maximum recursion depth.
  23595. * @returns {Array} Returns the new flattened array.
  23596. * @example
  23597. *
  23598. * var array = [1, [2, [3, [4]], 5]];
  23599. *
  23600. * _.flattenDepth(array, 1);
  23601. * // => [1, 2, [3, [4]], 5]
  23602. *
  23603. * _.flattenDepth(array, 2);
  23604. * // => [1, 2, 3, [4], 5]
  23605. */
  23606. function flattenDepth(array, depth) {
  23607. var length = array == null ? 0 : array.length;
  23608. if (!length) {
  23609. return [];
  23610. }
  23611. depth = depth === undefined ? 1 : toInteger(depth);
  23612. return baseFlatten(array, depth);
  23613. }
  23614. /**
  23615. * The inverse of `_.toPairs`; this method returns an object composed
  23616. * from key-value `pairs`.
  23617. *
  23618. * @static
  23619. * @memberOf _
  23620. * @since 4.0.0
  23621. * @category Array
  23622. * @param {Array} pairs The key-value pairs.
  23623. * @returns {Object} Returns the new object.
  23624. * @example
  23625. *
  23626. * _.fromPairs([['a', 1], ['b', 2]]);
  23627. * // => { 'a': 1, 'b': 2 }
  23628. */
  23629. function fromPairs(pairs) {
  23630. var index = -1,
  23631. length = pairs == null ? 0 : pairs.length,
  23632. result = {};
  23633. while (++index < length) {
  23634. var pair = pairs[index];
  23635. result[pair[0]] = pair[1];
  23636. }
  23637. return result;
  23638. }
  23639. /**
  23640. * Gets the first element of `array`.
  23641. *
  23642. * @static
  23643. * @memberOf _
  23644. * @since 0.1.0
  23645. * @alias first
  23646. * @category Array
  23647. * @param {Array} array The array to query.
  23648. * @returns {*} Returns the first element of `array`.
  23649. * @example
  23650. *
  23651. * _.head([1, 2, 3]);
  23652. * // => 1
  23653. *
  23654. * _.head([]);
  23655. * // => undefined
  23656. */
  23657. function head(array) {
  23658. return (array && array.length) ? array[0] : undefined;
  23659. }
  23660. /**
  23661. * Gets the index at which the first occurrence of `value` is found in `array`
  23662. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23663. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23664. * offset from the end of `array`.
  23665. *
  23666. * @static
  23667. * @memberOf _
  23668. * @since 0.1.0
  23669. * @category Array
  23670. * @param {Array} array The array to inspect.
  23671. * @param {*} value The value to search for.
  23672. * @param {number} [fromIndex=0] The index to search from.
  23673. * @returns {number} Returns the index of the matched value, else `-1`.
  23674. * @example
  23675. *
  23676. * _.indexOf([1, 2, 1, 2], 2);
  23677. * // => 1
  23678. *
  23679. * // Search from the `fromIndex`.
  23680. * _.indexOf([1, 2, 1, 2], 2, 2);
  23681. * // => 3
  23682. */
  23683. function indexOf(array, value, fromIndex) {
  23684. var length = array == null ? 0 : array.length;
  23685. if (!length) {
  23686. return -1;
  23687. }
  23688. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23689. if (index < 0) {
  23690. index = nativeMax(length + index, 0);
  23691. }
  23692. return baseIndexOf(array, value, index);
  23693. }
  23694. /**
  23695. * Gets all but the last element of `array`.
  23696. *
  23697. * @static
  23698. * @memberOf _
  23699. * @since 0.1.0
  23700. * @category Array
  23701. * @param {Array} array The array to query.
  23702. * @returns {Array} Returns the slice of `array`.
  23703. * @example
  23704. *
  23705. * _.initial([1, 2, 3]);
  23706. * // => [1, 2]
  23707. */
  23708. function initial(array) {
  23709. var length = array == null ? 0 : array.length;
  23710. return length ? baseSlice(array, 0, -1) : [];
  23711. }
  23712. /**
  23713. * Creates an array of unique values that are included in all given arrays
  23714. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23715. * for equality comparisons. The order and references of result values are
  23716. * determined by the first array.
  23717. *
  23718. * @static
  23719. * @memberOf _
  23720. * @since 0.1.0
  23721. * @category Array
  23722. * @param {...Array} [arrays] The arrays to inspect.
  23723. * @returns {Array} Returns the new array of intersecting values.
  23724. * @example
  23725. *
  23726. * _.intersection([2, 1], [2, 3]);
  23727. * // => [2]
  23728. */
  23729. var intersection = baseRest(function(arrays) {
  23730. var mapped = arrayMap(arrays, castArrayLikeObject);
  23731. return (mapped.length && mapped[0] === arrays[0])
  23732. ? baseIntersection(mapped)
  23733. : [];
  23734. });
  23735. /**
  23736. * This method is like `_.intersection` except that it accepts `iteratee`
  23737. * which is invoked for each element of each `arrays` to generate the criterion
  23738. * by which they're compared. The order and references of result values are
  23739. * determined by the first array. The iteratee is invoked with one argument:
  23740. * (value).
  23741. *
  23742. * @static
  23743. * @memberOf _
  23744. * @since 4.0.0
  23745. * @category Array
  23746. * @param {...Array} [arrays] The arrays to inspect.
  23747. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23748. * @returns {Array} Returns the new array of intersecting values.
  23749. * @example
  23750. *
  23751. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23752. * // => [2.1]
  23753. *
  23754. * // The `_.property` iteratee shorthand.
  23755. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23756. * // => [{ 'x': 1 }]
  23757. */
  23758. var intersectionBy = baseRest(function(arrays) {
  23759. var iteratee = last(arrays),
  23760. mapped = arrayMap(arrays, castArrayLikeObject);
  23761. if (iteratee === last(mapped)) {
  23762. iteratee = undefined;
  23763. } else {
  23764. mapped.pop();
  23765. }
  23766. return (mapped.length && mapped[0] === arrays[0])
  23767. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23768. : [];
  23769. });
  23770. /**
  23771. * This method is like `_.intersection` except that it accepts `comparator`
  23772. * which is invoked to compare elements of `arrays`. The order and references
  23773. * of result values are determined by the first array. The comparator is
  23774. * invoked with two arguments: (arrVal, othVal).
  23775. *
  23776. * @static
  23777. * @memberOf _
  23778. * @since 4.0.0
  23779. * @category Array
  23780. * @param {...Array} [arrays] The arrays to inspect.
  23781. * @param {Function} [comparator] The comparator invoked per element.
  23782. * @returns {Array} Returns the new array of intersecting values.
  23783. * @example
  23784. *
  23785. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23786. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23787. *
  23788. * _.intersectionWith(objects, others, _.isEqual);
  23789. * // => [{ 'x': 1, 'y': 2 }]
  23790. */
  23791. var intersectionWith = baseRest(function(arrays) {
  23792. var comparator = last(arrays),
  23793. mapped = arrayMap(arrays, castArrayLikeObject);
  23794. comparator = typeof comparator == 'function' ? comparator : undefined;
  23795. if (comparator) {
  23796. mapped.pop();
  23797. }
  23798. return (mapped.length && mapped[0] === arrays[0])
  23799. ? baseIntersection(mapped, undefined, comparator)
  23800. : [];
  23801. });
  23802. /**
  23803. * Converts all elements in `array` into a string separated by `separator`.
  23804. *
  23805. * @static
  23806. * @memberOf _
  23807. * @since 4.0.0
  23808. * @category Array
  23809. * @param {Array} array The array to convert.
  23810. * @param {string} [separator=','] The element separator.
  23811. * @returns {string} Returns the joined string.
  23812. * @example
  23813. *
  23814. * _.join(['a', 'b', 'c'], '~');
  23815. * // => 'a~b~c'
  23816. */
  23817. function join(array, separator) {
  23818. return array == null ? '' : nativeJoin.call(array, separator);
  23819. }
  23820. /**
  23821. * Gets the last element of `array`.
  23822. *
  23823. * @static
  23824. * @memberOf _
  23825. * @since 0.1.0
  23826. * @category Array
  23827. * @param {Array} array The array to query.
  23828. * @returns {*} Returns the last element of `array`.
  23829. * @example
  23830. *
  23831. * _.last([1, 2, 3]);
  23832. * // => 3
  23833. */
  23834. function last(array) {
  23835. var length = array == null ? 0 : array.length;
  23836. return length ? array[length - 1] : undefined;
  23837. }
  23838. /**
  23839. * This method is like `_.indexOf` except that it iterates over elements of
  23840. * `array` from right to left.
  23841. *
  23842. * @static
  23843. * @memberOf _
  23844. * @since 0.1.0
  23845. * @category Array
  23846. * @param {Array} array The array to inspect.
  23847. * @param {*} value The value to search for.
  23848. * @param {number} [fromIndex=array.length-1] The index to search from.
  23849. * @returns {number} Returns the index of the matched value, else `-1`.
  23850. * @example
  23851. *
  23852. * _.lastIndexOf([1, 2, 1, 2], 2);
  23853. * // => 3
  23854. *
  23855. * // Search from the `fromIndex`.
  23856. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23857. * // => 1
  23858. */
  23859. function lastIndexOf(array, value, fromIndex) {
  23860. var length = array == null ? 0 : array.length;
  23861. if (!length) {
  23862. return -1;
  23863. }
  23864. var index = length;
  23865. if (fromIndex !== undefined) {
  23866. index = toInteger(fromIndex);
  23867. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23868. }
  23869. return value === value
  23870. ? strictLastIndexOf(array, value, index)
  23871. : baseFindIndex(array, baseIsNaN, index, true);
  23872. }
  23873. /**
  23874. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23875. * element from the end is returned.
  23876. *
  23877. * @static
  23878. * @memberOf _
  23879. * @since 4.11.0
  23880. * @category Array
  23881. * @param {Array} array The array to query.
  23882. * @param {number} [n=0] The index of the element to return.
  23883. * @returns {*} Returns the nth element of `array`.
  23884. * @example
  23885. *
  23886. * var array = ['a', 'b', 'c', 'd'];
  23887. *
  23888. * _.nth(array, 1);
  23889. * // => 'b'
  23890. *
  23891. * _.nth(array, -2);
  23892. * // => 'c';
  23893. */
  23894. function nth(array, n) {
  23895. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23896. }
  23897. /**
  23898. * Removes all given values from `array` using
  23899. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23900. * for equality comparisons.
  23901. *
  23902. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23903. * to remove elements from an array by predicate.
  23904. *
  23905. * @static
  23906. * @memberOf _
  23907. * @since 2.0.0
  23908. * @category Array
  23909. * @param {Array} array The array to modify.
  23910. * @param {...*} [values] The values to remove.
  23911. * @returns {Array} Returns `array`.
  23912. * @example
  23913. *
  23914. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23915. *
  23916. * _.pull(array, 'a', 'c');
  23917. * console.log(array);
  23918. * // => ['b', 'b']
  23919. */
  23920. var pull = baseRest(pullAll);
  23921. /**
  23922. * This method is like `_.pull` except that it accepts an array of values to remove.
  23923. *
  23924. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23925. *
  23926. * @static
  23927. * @memberOf _
  23928. * @since 4.0.0
  23929. * @category Array
  23930. * @param {Array} array The array to modify.
  23931. * @param {Array} values The values to remove.
  23932. * @returns {Array} Returns `array`.
  23933. * @example
  23934. *
  23935. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23936. *
  23937. * _.pullAll(array, ['a', 'c']);
  23938. * console.log(array);
  23939. * // => ['b', 'b']
  23940. */
  23941. function pullAll(array, values) {
  23942. return (array && array.length && values && values.length)
  23943. ? basePullAll(array, values)
  23944. : array;
  23945. }
  23946. /**
  23947. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23948. * invoked for each element of `array` and `values` to generate the criterion
  23949. * by which they're compared. The iteratee is invoked with one argument: (value).
  23950. *
  23951. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23952. *
  23953. * @static
  23954. * @memberOf _
  23955. * @since 4.0.0
  23956. * @category Array
  23957. * @param {Array} array The array to modify.
  23958. * @param {Array} values The values to remove.
  23959. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23960. * @returns {Array} Returns `array`.
  23961. * @example
  23962. *
  23963. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23964. *
  23965. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  23966. * console.log(array);
  23967. * // => [{ 'x': 2 }]
  23968. */
  23969. function pullAllBy(array, values, iteratee) {
  23970. return (array && array.length && values && values.length)
  23971. ? basePullAll(array, values, getIteratee(iteratee, 2))
  23972. : array;
  23973. }
  23974. /**
  23975. * This method is like `_.pullAll` except that it accepts `comparator` which
  23976. * is invoked to compare elements of `array` to `values`. The comparator is
  23977. * invoked with two arguments: (arrVal, othVal).
  23978. *
  23979. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  23980. *
  23981. * @static
  23982. * @memberOf _
  23983. * @since 4.6.0
  23984. * @category Array
  23985. * @param {Array} array The array to modify.
  23986. * @param {Array} values The values to remove.
  23987. * @param {Function} [comparator] The comparator invoked per element.
  23988. * @returns {Array} Returns `array`.
  23989. * @example
  23990. *
  23991. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  23992. *
  23993. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  23994. * console.log(array);
  23995. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  23996. */
  23997. function pullAllWith(array, values, comparator) {
  23998. return (array && array.length && values && values.length)
  23999. ? basePullAll(array, values, undefined, comparator)
  24000. : array;
  24001. }
  24002. /**
  24003. * Removes elements from `array` corresponding to `indexes` and returns an
  24004. * array of removed elements.
  24005. *
  24006. * **Note:** Unlike `_.at`, this method mutates `array`.
  24007. *
  24008. * @static
  24009. * @memberOf _
  24010. * @since 3.0.0
  24011. * @category Array
  24012. * @param {Array} array The array to modify.
  24013. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24014. * @returns {Array} Returns the new array of removed elements.
  24015. * @example
  24016. *
  24017. * var array = ['a', 'b', 'c', 'd'];
  24018. * var pulled = _.pullAt(array, [1, 3]);
  24019. *
  24020. * console.log(array);
  24021. * // => ['a', 'c']
  24022. *
  24023. * console.log(pulled);
  24024. * // => ['b', 'd']
  24025. */
  24026. var pullAt = flatRest(function(array, indexes) {
  24027. var length = array == null ? 0 : array.length,
  24028. result = baseAt(array, indexes);
  24029. basePullAt(array, arrayMap(indexes, function(index) {
  24030. return isIndex(index, length) ? +index : index;
  24031. }).sort(compareAscending));
  24032. return result;
  24033. });
  24034. /**
  24035. * Removes all elements from `array` that `predicate` returns truthy for
  24036. * and returns an array of the removed elements. The predicate is invoked
  24037. * with three arguments: (value, index, array).
  24038. *
  24039. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24040. * to pull elements from an array by value.
  24041. *
  24042. * @static
  24043. * @memberOf _
  24044. * @since 2.0.0
  24045. * @category Array
  24046. * @param {Array} array The array to modify.
  24047. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24048. * @returns {Array} Returns the new array of removed elements.
  24049. * @example
  24050. *
  24051. * var array = [1, 2, 3, 4];
  24052. * var evens = _.remove(array, function(n) {
  24053. * return n % 2 == 0;
  24054. * });
  24055. *
  24056. * console.log(array);
  24057. * // => [1, 3]
  24058. *
  24059. * console.log(evens);
  24060. * // => [2, 4]
  24061. */
  24062. function remove(array, predicate) {
  24063. var result = [];
  24064. if (!(array && array.length)) {
  24065. return result;
  24066. }
  24067. var index = -1,
  24068. indexes = [],
  24069. length = array.length;
  24070. predicate = getIteratee(predicate, 3);
  24071. while (++index < length) {
  24072. var value = array[index];
  24073. if (predicate(value, index, array)) {
  24074. result.push(value);
  24075. indexes.push(index);
  24076. }
  24077. }
  24078. basePullAt(array, indexes);
  24079. return result;
  24080. }
  24081. /**
  24082. * Reverses `array` so that the first element becomes the last, the second
  24083. * element becomes the second to last, and so on.
  24084. *
  24085. * **Note:** This method mutates `array` and is based on
  24086. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24087. *
  24088. * @static
  24089. * @memberOf _
  24090. * @since 4.0.0
  24091. * @category Array
  24092. * @param {Array} array The array to modify.
  24093. * @returns {Array} Returns `array`.
  24094. * @example
  24095. *
  24096. * var array = [1, 2, 3];
  24097. *
  24098. * _.reverse(array);
  24099. * // => [3, 2, 1]
  24100. *
  24101. * console.log(array);
  24102. * // => [3, 2, 1]
  24103. */
  24104. function reverse(array) {
  24105. return array == null ? array : nativeReverse.call(array);
  24106. }
  24107. /**
  24108. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24109. *
  24110. * **Note:** This method is used instead of
  24111. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24112. * returned.
  24113. *
  24114. * @static
  24115. * @memberOf _
  24116. * @since 3.0.0
  24117. * @category Array
  24118. * @param {Array} array The array to slice.
  24119. * @param {number} [start=0] The start position.
  24120. * @param {number} [end=array.length] The end position.
  24121. * @returns {Array} Returns the slice of `array`.
  24122. */
  24123. function slice(array, start, end) {
  24124. var length = array == null ? 0 : array.length;
  24125. if (!length) {
  24126. return [];
  24127. }
  24128. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24129. start = 0;
  24130. end = length;
  24131. }
  24132. else {
  24133. start = start == null ? 0 : toInteger(start);
  24134. end = end === undefined ? length : toInteger(end);
  24135. }
  24136. return baseSlice(array, start, end);
  24137. }
  24138. /**
  24139. * Uses a binary search to determine the lowest index at which `value`
  24140. * should be inserted into `array` in order to maintain its sort order.
  24141. *
  24142. * @static
  24143. * @memberOf _
  24144. * @since 0.1.0
  24145. * @category Array
  24146. * @param {Array} array The sorted array to inspect.
  24147. * @param {*} value The value to evaluate.
  24148. * @returns {number} Returns the index at which `value` should be inserted
  24149. * into `array`.
  24150. * @example
  24151. *
  24152. * _.sortedIndex([30, 50], 40);
  24153. * // => 1
  24154. */
  24155. function sortedIndex(array, value) {
  24156. return baseSortedIndex(array, value);
  24157. }
  24158. /**
  24159. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24160. * which is invoked for `value` and each element of `array` to compute their
  24161. * sort ranking. The iteratee is invoked with one argument: (value).
  24162. *
  24163. * @static
  24164. * @memberOf _
  24165. * @since 4.0.0
  24166. * @category Array
  24167. * @param {Array} array The sorted array to inspect.
  24168. * @param {*} value The value to evaluate.
  24169. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24170. * @returns {number} Returns the index at which `value` should be inserted
  24171. * into `array`.
  24172. * @example
  24173. *
  24174. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24175. *
  24176. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24177. * // => 0
  24178. *
  24179. * // The `_.property` iteratee shorthand.
  24180. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24181. * // => 0
  24182. */
  24183. function sortedIndexBy(array, value, iteratee) {
  24184. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24185. }
  24186. /**
  24187. * This method is like `_.indexOf` except that it performs a binary
  24188. * search on a sorted `array`.
  24189. *
  24190. * @static
  24191. * @memberOf _
  24192. * @since 4.0.0
  24193. * @category Array
  24194. * @param {Array} array The array to inspect.
  24195. * @param {*} value The value to search for.
  24196. * @returns {number} Returns the index of the matched value, else `-1`.
  24197. * @example
  24198. *
  24199. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24200. * // => 1
  24201. */
  24202. function sortedIndexOf(array, value) {
  24203. var length = array == null ? 0 : array.length;
  24204. if (length) {
  24205. var index = baseSortedIndex(array, value);
  24206. if (index < length && eq(array[index], value)) {
  24207. return index;
  24208. }
  24209. }
  24210. return -1;
  24211. }
  24212. /**
  24213. * This method is like `_.sortedIndex` except that it returns the highest
  24214. * index at which `value` should be inserted into `array` in order to
  24215. * maintain its sort order.
  24216. *
  24217. * @static
  24218. * @memberOf _
  24219. * @since 3.0.0
  24220. * @category Array
  24221. * @param {Array} array The sorted array to inspect.
  24222. * @param {*} value The value to evaluate.
  24223. * @returns {number} Returns the index at which `value` should be inserted
  24224. * into `array`.
  24225. * @example
  24226. *
  24227. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24228. * // => 4
  24229. */
  24230. function sortedLastIndex(array, value) {
  24231. return baseSortedIndex(array, value, true);
  24232. }
  24233. /**
  24234. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24235. * which is invoked for `value` and each element of `array` to compute their
  24236. * sort ranking. The iteratee is invoked with one argument: (value).
  24237. *
  24238. * @static
  24239. * @memberOf _
  24240. * @since 4.0.0
  24241. * @category Array
  24242. * @param {Array} array The sorted array to inspect.
  24243. * @param {*} value The value to evaluate.
  24244. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24245. * @returns {number} Returns the index at which `value` should be inserted
  24246. * into `array`.
  24247. * @example
  24248. *
  24249. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24250. *
  24251. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24252. * // => 1
  24253. *
  24254. * // The `_.property` iteratee shorthand.
  24255. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24256. * // => 1
  24257. */
  24258. function sortedLastIndexBy(array, value, iteratee) {
  24259. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24260. }
  24261. /**
  24262. * This method is like `_.lastIndexOf` except that it performs a binary
  24263. * search on a sorted `array`.
  24264. *
  24265. * @static
  24266. * @memberOf _
  24267. * @since 4.0.0
  24268. * @category Array
  24269. * @param {Array} array The array to inspect.
  24270. * @param {*} value The value to search for.
  24271. * @returns {number} Returns the index of the matched value, else `-1`.
  24272. * @example
  24273. *
  24274. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24275. * // => 3
  24276. */
  24277. function sortedLastIndexOf(array, value) {
  24278. var length = array == null ? 0 : array.length;
  24279. if (length) {
  24280. var index = baseSortedIndex(array, value, true) - 1;
  24281. if (eq(array[index], value)) {
  24282. return index;
  24283. }
  24284. }
  24285. return -1;
  24286. }
  24287. /**
  24288. * This method is like `_.uniq` except that it's designed and optimized
  24289. * for sorted arrays.
  24290. *
  24291. * @static
  24292. * @memberOf _
  24293. * @since 4.0.0
  24294. * @category Array
  24295. * @param {Array} array The array to inspect.
  24296. * @returns {Array} Returns the new duplicate free array.
  24297. * @example
  24298. *
  24299. * _.sortedUniq([1, 1, 2]);
  24300. * // => [1, 2]
  24301. */
  24302. function sortedUniq(array) {
  24303. return (array && array.length)
  24304. ? baseSortedUniq(array)
  24305. : [];
  24306. }
  24307. /**
  24308. * This method is like `_.uniqBy` except that it's designed and optimized
  24309. * for sorted arrays.
  24310. *
  24311. * @static
  24312. * @memberOf _
  24313. * @since 4.0.0
  24314. * @category Array
  24315. * @param {Array} array The array to inspect.
  24316. * @param {Function} [iteratee] The iteratee invoked per element.
  24317. * @returns {Array} Returns the new duplicate free array.
  24318. * @example
  24319. *
  24320. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24321. * // => [1.1, 2.3]
  24322. */
  24323. function sortedUniqBy(array, iteratee) {
  24324. return (array && array.length)
  24325. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24326. : [];
  24327. }
  24328. /**
  24329. * Gets all but the first element of `array`.
  24330. *
  24331. * @static
  24332. * @memberOf _
  24333. * @since 4.0.0
  24334. * @category Array
  24335. * @param {Array} array The array to query.
  24336. * @returns {Array} Returns the slice of `array`.
  24337. * @example
  24338. *
  24339. * _.tail([1, 2, 3]);
  24340. * // => [2, 3]
  24341. */
  24342. function tail(array) {
  24343. var length = array == null ? 0 : array.length;
  24344. return length ? baseSlice(array, 1, length) : [];
  24345. }
  24346. /**
  24347. * Creates a slice of `array` with `n` elements taken from the beginning.
  24348. *
  24349. * @static
  24350. * @memberOf _
  24351. * @since 0.1.0
  24352. * @category Array
  24353. * @param {Array} array The array to query.
  24354. * @param {number} [n=1] The number of elements to take.
  24355. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24356. * @returns {Array} Returns the slice of `array`.
  24357. * @example
  24358. *
  24359. * _.take([1, 2, 3]);
  24360. * // => [1]
  24361. *
  24362. * _.take([1, 2, 3], 2);
  24363. * // => [1, 2]
  24364. *
  24365. * _.take([1, 2, 3], 5);
  24366. * // => [1, 2, 3]
  24367. *
  24368. * _.take([1, 2, 3], 0);
  24369. * // => []
  24370. */
  24371. function take(array, n, guard) {
  24372. if (!(array && array.length)) {
  24373. return [];
  24374. }
  24375. n = (guard || n === undefined) ? 1 : toInteger(n);
  24376. return baseSlice(array, 0, n < 0 ? 0 : n);
  24377. }
  24378. /**
  24379. * Creates a slice of `array` with `n` elements taken from the end.
  24380. *
  24381. * @static
  24382. * @memberOf _
  24383. * @since 3.0.0
  24384. * @category Array
  24385. * @param {Array} array The array to query.
  24386. * @param {number} [n=1] The number of elements to take.
  24387. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24388. * @returns {Array} Returns the slice of `array`.
  24389. * @example
  24390. *
  24391. * _.takeRight([1, 2, 3]);
  24392. * // => [3]
  24393. *
  24394. * _.takeRight([1, 2, 3], 2);
  24395. * // => [2, 3]
  24396. *
  24397. * _.takeRight([1, 2, 3], 5);
  24398. * // => [1, 2, 3]
  24399. *
  24400. * _.takeRight([1, 2, 3], 0);
  24401. * // => []
  24402. */
  24403. function takeRight(array, n, guard) {
  24404. var length = array == null ? 0 : array.length;
  24405. if (!length) {
  24406. return [];
  24407. }
  24408. n = (guard || n === undefined) ? 1 : toInteger(n);
  24409. n = length - n;
  24410. return baseSlice(array, n < 0 ? 0 : n, length);
  24411. }
  24412. /**
  24413. * Creates a slice of `array` with elements taken from the end. Elements are
  24414. * taken until `predicate` returns falsey. The predicate is invoked with
  24415. * three arguments: (value, index, array).
  24416. *
  24417. * @static
  24418. * @memberOf _
  24419. * @since 3.0.0
  24420. * @category Array
  24421. * @param {Array} array The array to query.
  24422. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24423. * @returns {Array} Returns the slice of `array`.
  24424. * @example
  24425. *
  24426. * var users = [
  24427. * { 'user': 'barney', 'active': true },
  24428. * { 'user': 'fred', 'active': false },
  24429. * { 'user': 'pebbles', 'active': false }
  24430. * ];
  24431. *
  24432. * _.takeRightWhile(users, function(o) { return !o.active; });
  24433. * // => objects for ['fred', 'pebbles']
  24434. *
  24435. * // The `_.matches` iteratee shorthand.
  24436. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24437. * // => objects for ['pebbles']
  24438. *
  24439. * // The `_.matchesProperty` iteratee shorthand.
  24440. * _.takeRightWhile(users, ['active', false]);
  24441. * // => objects for ['fred', 'pebbles']
  24442. *
  24443. * // The `_.property` iteratee shorthand.
  24444. * _.takeRightWhile(users, 'active');
  24445. * // => []
  24446. */
  24447. function takeRightWhile(array, predicate) {
  24448. return (array && array.length)
  24449. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24450. : [];
  24451. }
  24452. /**
  24453. * Creates a slice of `array` with elements taken from the beginning. Elements
  24454. * are taken until `predicate` returns falsey. The predicate is invoked with
  24455. * three arguments: (value, index, array).
  24456. *
  24457. * @static
  24458. * @memberOf _
  24459. * @since 3.0.0
  24460. * @category Array
  24461. * @param {Array} array The array to query.
  24462. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24463. * @returns {Array} Returns the slice of `array`.
  24464. * @example
  24465. *
  24466. * var users = [
  24467. * { 'user': 'barney', 'active': false },
  24468. * { 'user': 'fred', 'active': false },
  24469. * { 'user': 'pebbles', 'active': true }
  24470. * ];
  24471. *
  24472. * _.takeWhile(users, function(o) { return !o.active; });
  24473. * // => objects for ['barney', 'fred']
  24474. *
  24475. * // The `_.matches` iteratee shorthand.
  24476. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24477. * // => objects for ['barney']
  24478. *
  24479. * // The `_.matchesProperty` iteratee shorthand.
  24480. * _.takeWhile(users, ['active', false]);
  24481. * // => objects for ['barney', 'fred']
  24482. *
  24483. * // The `_.property` iteratee shorthand.
  24484. * _.takeWhile(users, 'active');
  24485. * // => []
  24486. */
  24487. function takeWhile(array, predicate) {
  24488. return (array && array.length)
  24489. ? baseWhile(array, getIteratee(predicate, 3))
  24490. : [];
  24491. }
  24492. /**
  24493. * Creates an array of unique values, in order, from all given arrays using
  24494. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24495. * for equality comparisons.
  24496. *
  24497. * @static
  24498. * @memberOf _
  24499. * @since 0.1.0
  24500. * @category Array
  24501. * @param {...Array} [arrays] The arrays to inspect.
  24502. * @returns {Array} Returns the new array of combined values.
  24503. * @example
  24504. *
  24505. * _.union([2], [1, 2]);
  24506. * // => [2, 1]
  24507. */
  24508. var union = baseRest(function(arrays) {
  24509. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24510. });
  24511. /**
  24512. * This method is like `_.union` except that it accepts `iteratee` which is
  24513. * invoked for each element of each `arrays` to generate the criterion by
  24514. * which uniqueness is computed. Result values are chosen from the first
  24515. * array in which the value occurs. The iteratee is invoked with one argument:
  24516. * (value).
  24517. *
  24518. * @static
  24519. * @memberOf _
  24520. * @since 4.0.0
  24521. * @category Array
  24522. * @param {...Array} [arrays] The arrays to inspect.
  24523. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24524. * @returns {Array} Returns the new array of combined values.
  24525. * @example
  24526. *
  24527. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24528. * // => [2.1, 1.2]
  24529. *
  24530. * // The `_.property` iteratee shorthand.
  24531. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24532. * // => [{ 'x': 1 }, { 'x': 2 }]
  24533. */
  24534. var unionBy = baseRest(function(arrays) {
  24535. var iteratee = last(arrays);
  24536. if (isArrayLikeObject(iteratee)) {
  24537. iteratee = undefined;
  24538. }
  24539. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24540. });
  24541. /**
  24542. * This method is like `_.union` except that it accepts `comparator` which
  24543. * is invoked to compare elements of `arrays`. Result values are chosen from
  24544. * the first array in which the value occurs. The comparator is invoked
  24545. * with two arguments: (arrVal, othVal).
  24546. *
  24547. * @static
  24548. * @memberOf _
  24549. * @since 4.0.0
  24550. * @category Array
  24551. * @param {...Array} [arrays] The arrays to inspect.
  24552. * @param {Function} [comparator] The comparator invoked per element.
  24553. * @returns {Array} Returns the new array of combined values.
  24554. * @example
  24555. *
  24556. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24557. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24558. *
  24559. * _.unionWith(objects, others, _.isEqual);
  24560. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24561. */
  24562. var unionWith = baseRest(function(arrays) {
  24563. var comparator = last(arrays);
  24564. comparator = typeof comparator == 'function' ? comparator : undefined;
  24565. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24566. });
  24567. /**
  24568. * Creates a duplicate-free version of an array, using
  24569. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24570. * for equality comparisons, in which only the first occurrence of each element
  24571. * is kept. The order of result values is determined by the order they occur
  24572. * in the array.
  24573. *
  24574. * @static
  24575. * @memberOf _
  24576. * @since 0.1.0
  24577. * @category Array
  24578. * @param {Array} array The array to inspect.
  24579. * @returns {Array} Returns the new duplicate free array.
  24580. * @example
  24581. *
  24582. * _.uniq([2, 1, 2]);
  24583. * // => [2, 1]
  24584. */
  24585. function uniq(array) {
  24586. return (array && array.length) ? baseUniq(array) : [];
  24587. }
  24588. /**
  24589. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24590. * invoked for each element in `array` to generate the criterion by which
  24591. * uniqueness is computed. The order of result values is determined by the
  24592. * order they occur in the array. The iteratee is invoked with one argument:
  24593. * (value).
  24594. *
  24595. * @static
  24596. * @memberOf _
  24597. * @since 4.0.0
  24598. * @category Array
  24599. * @param {Array} array The array to inspect.
  24600. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24601. * @returns {Array} Returns the new duplicate free array.
  24602. * @example
  24603. *
  24604. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24605. * // => [2.1, 1.2]
  24606. *
  24607. * // The `_.property` iteratee shorthand.
  24608. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24609. * // => [{ 'x': 1 }, { 'x': 2 }]
  24610. */
  24611. function uniqBy(array, iteratee) {
  24612. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24613. }
  24614. /**
  24615. * This method is like `_.uniq` except that it accepts `comparator` which
  24616. * is invoked to compare elements of `array`. The order of result values is
  24617. * determined by the order they occur in the array.The comparator is invoked
  24618. * with two arguments: (arrVal, othVal).
  24619. *
  24620. * @static
  24621. * @memberOf _
  24622. * @since 4.0.0
  24623. * @category Array
  24624. * @param {Array} array The array to inspect.
  24625. * @param {Function} [comparator] The comparator invoked per element.
  24626. * @returns {Array} Returns the new duplicate free array.
  24627. * @example
  24628. *
  24629. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24630. *
  24631. * _.uniqWith(objects, _.isEqual);
  24632. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24633. */
  24634. function uniqWith(array, comparator) {
  24635. comparator = typeof comparator == 'function' ? comparator : undefined;
  24636. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24637. }
  24638. /**
  24639. * This method is like `_.zip` except that it accepts an array of grouped
  24640. * elements and creates an array regrouping the elements to their pre-zip
  24641. * configuration.
  24642. *
  24643. * @static
  24644. * @memberOf _
  24645. * @since 1.2.0
  24646. * @category Array
  24647. * @param {Array} array The array of grouped elements to process.
  24648. * @returns {Array} Returns the new array of regrouped elements.
  24649. * @example
  24650. *
  24651. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24652. * // => [['a', 1, true], ['b', 2, false]]
  24653. *
  24654. * _.unzip(zipped);
  24655. * // => [['a', 'b'], [1, 2], [true, false]]
  24656. */
  24657. function unzip(array) {
  24658. if (!(array && array.length)) {
  24659. return [];
  24660. }
  24661. var length = 0;
  24662. array = arrayFilter(array, function(group) {
  24663. if (isArrayLikeObject(group)) {
  24664. length = nativeMax(group.length, length);
  24665. return true;
  24666. }
  24667. });
  24668. return baseTimes(length, function(index) {
  24669. return arrayMap(array, baseProperty(index));
  24670. });
  24671. }
  24672. /**
  24673. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24674. * how regrouped values should be combined. The iteratee is invoked with the
  24675. * elements of each group: (...group).
  24676. *
  24677. * @static
  24678. * @memberOf _
  24679. * @since 3.8.0
  24680. * @category Array
  24681. * @param {Array} array The array of grouped elements to process.
  24682. * @param {Function} [iteratee=_.identity] The function to combine
  24683. * regrouped values.
  24684. * @returns {Array} Returns the new array of regrouped elements.
  24685. * @example
  24686. *
  24687. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24688. * // => [[1, 10, 100], [2, 20, 200]]
  24689. *
  24690. * _.unzipWith(zipped, _.add);
  24691. * // => [3, 30, 300]
  24692. */
  24693. function unzipWith(array, iteratee) {
  24694. if (!(array && array.length)) {
  24695. return [];
  24696. }
  24697. var result = unzip(array);
  24698. if (iteratee == null) {
  24699. return result;
  24700. }
  24701. return arrayMap(result, function(group) {
  24702. return apply(iteratee, undefined, group);
  24703. });
  24704. }
  24705. /**
  24706. * Creates an array excluding all given values using
  24707. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24708. * for equality comparisons.
  24709. *
  24710. * **Note:** Unlike `_.pull`, this method returns a new array.
  24711. *
  24712. * @static
  24713. * @memberOf _
  24714. * @since 0.1.0
  24715. * @category Array
  24716. * @param {Array} array The array to inspect.
  24717. * @param {...*} [values] The values to exclude.
  24718. * @returns {Array} Returns the new array of filtered values.
  24719. * @see _.difference, _.xor
  24720. * @example
  24721. *
  24722. * _.without([2, 1, 2, 3], 1, 2);
  24723. * // => [3]
  24724. */
  24725. var without = baseRest(function(array, values) {
  24726. return isArrayLikeObject(array)
  24727. ? baseDifference(array, values)
  24728. : [];
  24729. });
  24730. /**
  24731. * Creates an array of unique values that is the
  24732. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24733. * of the given arrays. The order of result values is determined by the order
  24734. * they occur in the arrays.
  24735. *
  24736. * @static
  24737. * @memberOf _
  24738. * @since 2.4.0
  24739. * @category Array
  24740. * @param {...Array} [arrays] The arrays to inspect.
  24741. * @returns {Array} Returns the new array of filtered values.
  24742. * @see _.difference, _.without
  24743. * @example
  24744. *
  24745. * _.xor([2, 1], [2, 3]);
  24746. * // => [1, 3]
  24747. */
  24748. var xor = baseRest(function(arrays) {
  24749. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24750. });
  24751. /**
  24752. * This method is like `_.xor` except that it accepts `iteratee` which is
  24753. * invoked for each element of each `arrays` to generate the criterion by
  24754. * which by which they're compared. The order of result values is determined
  24755. * by the order they occur in the arrays. The iteratee is invoked with one
  24756. * argument: (value).
  24757. *
  24758. * @static
  24759. * @memberOf _
  24760. * @since 4.0.0
  24761. * @category Array
  24762. * @param {...Array} [arrays] The arrays to inspect.
  24763. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24764. * @returns {Array} Returns the new array of filtered values.
  24765. * @example
  24766. *
  24767. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24768. * // => [1.2, 3.4]
  24769. *
  24770. * // The `_.property` iteratee shorthand.
  24771. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24772. * // => [{ 'x': 2 }]
  24773. */
  24774. var xorBy = baseRest(function(arrays) {
  24775. var iteratee = last(arrays);
  24776. if (isArrayLikeObject(iteratee)) {
  24777. iteratee = undefined;
  24778. }
  24779. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24780. });
  24781. /**
  24782. * This method is like `_.xor` except that it accepts `comparator` which is
  24783. * invoked to compare elements of `arrays`. The order of result values is
  24784. * determined by the order they occur in the arrays. The comparator is invoked
  24785. * with two arguments: (arrVal, othVal).
  24786. *
  24787. * @static
  24788. * @memberOf _
  24789. * @since 4.0.0
  24790. * @category Array
  24791. * @param {...Array} [arrays] The arrays to inspect.
  24792. * @param {Function} [comparator] The comparator invoked per element.
  24793. * @returns {Array} Returns the new array of filtered values.
  24794. * @example
  24795. *
  24796. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24797. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24798. *
  24799. * _.xorWith(objects, others, _.isEqual);
  24800. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24801. */
  24802. var xorWith = baseRest(function(arrays) {
  24803. var comparator = last(arrays);
  24804. comparator = typeof comparator == 'function' ? comparator : undefined;
  24805. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24806. });
  24807. /**
  24808. * Creates an array of grouped elements, the first of which contains the
  24809. * first elements of the given arrays, the second of which contains the
  24810. * second elements of the given arrays, and so on.
  24811. *
  24812. * @static
  24813. * @memberOf _
  24814. * @since 0.1.0
  24815. * @category Array
  24816. * @param {...Array} [arrays] The arrays to process.
  24817. * @returns {Array} Returns the new array of grouped elements.
  24818. * @example
  24819. *
  24820. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24821. * // => [['a', 1, true], ['b', 2, false]]
  24822. */
  24823. var zip = baseRest(unzip);
  24824. /**
  24825. * This method is like `_.fromPairs` except that it accepts two arrays,
  24826. * one of property identifiers and one of corresponding values.
  24827. *
  24828. * @static
  24829. * @memberOf _
  24830. * @since 0.4.0
  24831. * @category Array
  24832. * @param {Array} [props=[]] The property identifiers.
  24833. * @param {Array} [values=[]] The property values.
  24834. * @returns {Object} Returns the new object.
  24835. * @example
  24836. *
  24837. * _.zipObject(['a', 'b'], [1, 2]);
  24838. * // => { 'a': 1, 'b': 2 }
  24839. */
  24840. function zipObject(props, values) {
  24841. return baseZipObject(props || [], values || [], assignValue);
  24842. }
  24843. /**
  24844. * This method is like `_.zipObject` except that it supports property paths.
  24845. *
  24846. * @static
  24847. * @memberOf _
  24848. * @since 4.1.0
  24849. * @category Array
  24850. * @param {Array} [props=[]] The property identifiers.
  24851. * @param {Array} [values=[]] The property values.
  24852. * @returns {Object} Returns the new object.
  24853. * @example
  24854. *
  24855. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24856. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24857. */
  24858. function zipObjectDeep(props, values) {
  24859. return baseZipObject(props || [], values || [], baseSet);
  24860. }
  24861. /**
  24862. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24863. * how grouped values should be combined. The iteratee is invoked with the
  24864. * elements of each group: (...group).
  24865. *
  24866. * @static
  24867. * @memberOf _
  24868. * @since 3.8.0
  24869. * @category Array
  24870. * @param {...Array} [arrays] The arrays to process.
  24871. * @param {Function} [iteratee=_.identity] The function to combine
  24872. * grouped values.
  24873. * @returns {Array} Returns the new array of grouped elements.
  24874. * @example
  24875. *
  24876. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24877. * return a + b + c;
  24878. * });
  24879. * // => [111, 222]
  24880. */
  24881. var zipWith = baseRest(function(arrays) {
  24882. var length = arrays.length,
  24883. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24884. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24885. return unzipWith(arrays, iteratee);
  24886. });
  24887. /*------------------------------------------------------------------------*/
  24888. /**
  24889. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24890. * chain sequences enabled. The result of such sequences must be unwrapped
  24891. * with `_#value`.
  24892. *
  24893. * @static
  24894. * @memberOf _
  24895. * @since 1.3.0
  24896. * @category Seq
  24897. * @param {*} value The value to wrap.
  24898. * @returns {Object} Returns the new `lodash` wrapper instance.
  24899. * @example
  24900. *
  24901. * var users = [
  24902. * { 'user': 'barney', 'age': 36 },
  24903. * { 'user': 'fred', 'age': 40 },
  24904. * { 'user': 'pebbles', 'age': 1 }
  24905. * ];
  24906. *
  24907. * var youngest = _
  24908. * .chain(users)
  24909. * .sortBy('age')
  24910. * .map(function(o) {
  24911. * return o.user + ' is ' + o.age;
  24912. * })
  24913. * .head()
  24914. * .value();
  24915. * // => 'pebbles is 1'
  24916. */
  24917. function chain(value) {
  24918. var result = lodash(value);
  24919. result.__chain__ = true;
  24920. return result;
  24921. }
  24922. /**
  24923. * This method invokes `interceptor` and returns `value`. The interceptor
  24924. * is invoked with one argument; (value). The purpose of this method is to
  24925. * "tap into" a method chain sequence in order to modify intermediate results.
  24926. *
  24927. * @static
  24928. * @memberOf _
  24929. * @since 0.1.0
  24930. * @category Seq
  24931. * @param {*} value The value to provide to `interceptor`.
  24932. * @param {Function} interceptor The function to invoke.
  24933. * @returns {*} Returns `value`.
  24934. * @example
  24935. *
  24936. * _([1, 2, 3])
  24937. * .tap(function(array) {
  24938. * // Mutate input array.
  24939. * array.pop();
  24940. * })
  24941. * .reverse()
  24942. * .value();
  24943. * // => [2, 1]
  24944. */
  24945. function tap(value, interceptor) {
  24946. interceptor(value);
  24947. return value;
  24948. }
  24949. /**
  24950. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24951. * The purpose of this method is to "pass thru" values replacing intermediate
  24952. * results in a method chain sequence.
  24953. *
  24954. * @static
  24955. * @memberOf _
  24956. * @since 3.0.0
  24957. * @category Seq
  24958. * @param {*} value The value to provide to `interceptor`.
  24959. * @param {Function} interceptor The function to invoke.
  24960. * @returns {*} Returns the result of `interceptor`.
  24961. * @example
  24962. *
  24963. * _(' abc ')
  24964. * .chain()
  24965. * .trim()
  24966. * .thru(function(value) {
  24967. * return [value];
  24968. * })
  24969. * .value();
  24970. * // => ['abc']
  24971. */
  24972. function thru(value, interceptor) {
  24973. return interceptor(value);
  24974. }
  24975. /**
  24976. * This method is the wrapper version of `_.at`.
  24977. *
  24978. * @name at
  24979. * @memberOf _
  24980. * @since 1.0.0
  24981. * @category Seq
  24982. * @param {...(string|string[])} [paths] The property paths to pick.
  24983. * @returns {Object} Returns the new `lodash` wrapper instance.
  24984. * @example
  24985. *
  24986. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  24987. *
  24988. * _(object).at(['a[0].b.c', 'a[1]']).value();
  24989. * // => [3, 4]
  24990. */
  24991. var wrapperAt = flatRest(function(paths) {
  24992. var length = paths.length,
  24993. start = length ? paths[0] : 0,
  24994. value = this.__wrapped__,
  24995. interceptor = function(object) { return baseAt(object, paths); };
  24996. if (length > 1 || this.__actions__.length ||
  24997. !(value instanceof LazyWrapper) || !isIndex(start)) {
  24998. return this.thru(interceptor);
  24999. }
  25000. value = value.slice(start, +start + (length ? 1 : 0));
  25001. value.__actions__.push({
  25002. 'func': thru,
  25003. 'args': [interceptor],
  25004. 'thisArg': undefined
  25005. });
  25006. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25007. if (length && !array.length) {
  25008. array.push(undefined);
  25009. }
  25010. return array;
  25011. });
  25012. });
  25013. /**
  25014. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25015. *
  25016. * @name chain
  25017. * @memberOf _
  25018. * @since 0.1.0
  25019. * @category Seq
  25020. * @returns {Object} Returns the new `lodash` wrapper instance.
  25021. * @example
  25022. *
  25023. * var users = [
  25024. * { 'user': 'barney', 'age': 36 },
  25025. * { 'user': 'fred', 'age': 40 }
  25026. * ];
  25027. *
  25028. * // A sequence without explicit chaining.
  25029. * _(users).head();
  25030. * // => { 'user': 'barney', 'age': 36 }
  25031. *
  25032. * // A sequence with explicit chaining.
  25033. * _(users)
  25034. * .chain()
  25035. * .head()
  25036. * .pick('user')
  25037. * .value();
  25038. * // => { 'user': 'barney' }
  25039. */
  25040. function wrapperChain() {
  25041. return chain(this);
  25042. }
  25043. /**
  25044. * Executes the chain sequence and returns the wrapped result.
  25045. *
  25046. * @name commit
  25047. * @memberOf _
  25048. * @since 3.2.0
  25049. * @category Seq
  25050. * @returns {Object} Returns the new `lodash` wrapper instance.
  25051. * @example
  25052. *
  25053. * var array = [1, 2];
  25054. * var wrapped = _(array).push(3);
  25055. *
  25056. * console.log(array);
  25057. * // => [1, 2]
  25058. *
  25059. * wrapped = wrapped.commit();
  25060. * console.log(array);
  25061. * // => [1, 2, 3]
  25062. *
  25063. * wrapped.last();
  25064. * // => 3
  25065. *
  25066. * console.log(array);
  25067. * // => [1, 2, 3]
  25068. */
  25069. function wrapperCommit() {
  25070. return new LodashWrapper(this.value(), this.__chain__);
  25071. }
  25072. /**
  25073. * Gets the next value on a wrapped object following the
  25074. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25075. *
  25076. * @name next
  25077. * @memberOf _
  25078. * @since 4.0.0
  25079. * @category Seq
  25080. * @returns {Object} Returns the next iterator value.
  25081. * @example
  25082. *
  25083. * var wrapped = _([1, 2]);
  25084. *
  25085. * wrapped.next();
  25086. * // => { 'done': false, 'value': 1 }
  25087. *
  25088. * wrapped.next();
  25089. * // => { 'done': false, 'value': 2 }
  25090. *
  25091. * wrapped.next();
  25092. * // => { 'done': true, 'value': undefined }
  25093. */
  25094. function wrapperNext() {
  25095. if (this.__values__ === undefined) {
  25096. this.__values__ = toArray(this.value());
  25097. }
  25098. var done = this.__index__ >= this.__values__.length,
  25099. value = done ? undefined : this.__values__[this.__index__++];
  25100. return { 'done': done, 'value': value };
  25101. }
  25102. /**
  25103. * Enables the wrapper to be iterable.
  25104. *
  25105. * @name Symbol.iterator
  25106. * @memberOf _
  25107. * @since 4.0.0
  25108. * @category Seq
  25109. * @returns {Object} Returns the wrapper object.
  25110. * @example
  25111. *
  25112. * var wrapped = _([1, 2]);
  25113. *
  25114. * wrapped[Symbol.iterator]() === wrapped;
  25115. * // => true
  25116. *
  25117. * Array.from(wrapped);
  25118. * // => [1, 2]
  25119. */
  25120. function wrapperToIterator() {
  25121. return this;
  25122. }
  25123. /**
  25124. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25125. *
  25126. * @name plant
  25127. * @memberOf _
  25128. * @since 3.2.0
  25129. * @category Seq
  25130. * @param {*} value The value to plant.
  25131. * @returns {Object} Returns the new `lodash` wrapper instance.
  25132. * @example
  25133. *
  25134. * function square(n) {
  25135. * return n * n;
  25136. * }
  25137. *
  25138. * var wrapped = _([1, 2]).map(square);
  25139. * var other = wrapped.plant([3, 4]);
  25140. *
  25141. * other.value();
  25142. * // => [9, 16]
  25143. *
  25144. * wrapped.value();
  25145. * // => [1, 4]
  25146. */
  25147. function wrapperPlant(value) {
  25148. var result,
  25149. parent = this;
  25150. while (parent instanceof baseLodash) {
  25151. var clone = wrapperClone(parent);
  25152. clone.__index__ = 0;
  25153. clone.__values__ = undefined;
  25154. if (result) {
  25155. previous.__wrapped__ = clone;
  25156. } else {
  25157. result = clone;
  25158. }
  25159. var previous = clone;
  25160. parent = parent.__wrapped__;
  25161. }
  25162. previous.__wrapped__ = value;
  25163. return result;
  25164. }
  25165. /**
  25166. * This method is the wrapper version of `_.reverse`.
  25167. *
  25168. * **Note:** This method mutates the wrapped array.
  25169. *
  25170. * @name reverse
  25171. * @memberOf _
  25172. * @since 0.1.0
  25173. * @category Seq
  25174. * @returns {Object} Returns the new `lodash` wrapper instance.
  25175. * @example
  25176. *
  25177. * var array = [1, 2, 3];
  25178. *
  25179. * _(array).reverse().value()
  25180. * // => [3, 2, 1]
  25181. *
  25182. * console.log(array);
  25183. * // => [3, 2, 1]
  25184. */
  25185. function wrapperReverse() {
  25186. var value = this.__wrapped__;
  25187. if (value instanceof LazyWrapper) {
  25188. var wrapped = value;
  25189. if (this.__actions__.length) {
  25190. wrapped = new LazyWrapper(this);
  25191. }
  25192. wrapped = wrapped.reverse();
  25193. wrapped.__actions__.push({
  25194. 'func': thru,
  25195. 'args': [reverse],
  25196. 'thisArg': undefined
  25197. });
  25198. return new LodashWrapper(wrapped, this.__chain__);
  25199. }
  25200. return this.thru(reverse);
  25201. }
  25202. /**
  25203. * Executes the chain sequence to resolve the unwrapped value.
  25204. *
  25205. * @name value
  25206. * @memberOf _
  25207. * @since 0.1.0
  25208. * @alias toJSON, valueOf
  25209. * @category Seq
  25210. * @returns {*} Returns the resolved unwrapped value.
  25211. * @example
  25212. *
  25213. * _([1, 2, 3]).value();
  25214. * // => [1, 2, 3]
  25215. */
  25216. function wrapperValue() {
  25217. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25218. }
  25219. /*------------------------------------------------------------------------*/
  25220. /**
  25221. * Creates an object composed of keys generated from the results of running
  25222. * each element of `collection` thru `iteratee`. The corresponding value of
  25223. * each key is the number of times the key was returned by `iteratee`. The
  25224. * iteratee is invoked with one argument: (value).
  25225. *
  25226. * @static
  25227. * @memberOf _
  25228. * @since 0.5.0
  25229. * @category Collection
  25230. * @param {Array|Object} collection The collection to iterate over.
  25231. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25232. * @returns {Object} Returns the composed aggregate object.
  25233. * @example
  25234. *
  25235. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25236. * // => { '4': 1, '6': 2 }
  25237. *
  25238. * // The `_.property` iteratee shorthand.
  25239. * _.countBy(['one', 'two', 'three'], 'length');
  25240. * // => { '3': 2, '5': 1 }
  25241. */
  25242. var countBy = createAggregator(function(result, value, key) {
  25243. if (hasOwnProperty.call(result, key)) {
  25244. ++result[key];
  25245. } else {
  25246. baseAssignValue(result, key, 1);
  25247. }
  25248. });
  25249. /**
  25250. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25251. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25252. * invoked with three arguments: (value, index|key, collection).
  25253. *
  25254. * **Note:** This method returns `true` for
  25255. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25256. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25257. * elements of empty collections.
  25258. *
  25259. * @static
  25260. * @memberOf _
  25261. * @since 0.1.0
  25262. * @category Collection
  25263. * @param {Array|Object} collection The collection to iterate over.
  25264. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25265. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25266. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25267. * else `false`.
  25268. * @example
  25269. *
  25270. * _.every([true, 1, null, 'yes'], Boolean);
  25271. * // => false
  25272. *
  25273. * var users = [
  25274. * { 'user': 'barney', 'age': 36, 'active': false },
  25275. * { 'user': 'fred', 'age': 40, 'active': false }
  25276. * ];
  25277. *
  25278. * // The `_.matches` iteratee shorthand.
  25279. * _.every(users, { 'user': 'barney', 'active': false });
  25280. * // => false
  25281. *
  25282. * // The `_.matchesProperty` iteratee shorthand.
  25283. * _.every(users, ['active', false]);
  25284. * // => true
  25285. *
  25286. * // The `_.property` iteratee shorthand.
  25287. * _.every(users, 'active');
  25288. * // => false
  25289. */
  25290. function every(collection, predicate, guard) {
  25291. var func = isArray(collection) ? arrayEvery : baseEvery;
  25292. if (guard && isIterateeCall(collection, predicate, guard)) {
  25293. predicate = undefined;
  25294. }
  25295. return func(collection, getIteratee(predicate, 3));
  25296. }
  25297. /**
  25298. * Iterates over elements of `collection`, returning an array of all elements
  25299. * `predicate` returns truthy for. The predicate is invoked with three
  25300. * arguments: (value, index|key, collection).
  25301. *
  25302. * **Note:** Unlike `_.remove`, this method returns a new array.
  25303. *
  25304. * @static
  25305. * @memberOf _
  25306. * @since 0.1.0
  25307. * @category Collection
  25308. * @param {Array|Object} collection The collection to iterate over.
  25309. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25310. * @returns {Array} Returns the new filtered array.
  25311. * @see _.reject
  25312. * @example
  25313. *
  25314. * var users = [
  25315. * { 'user': 'barney', 'age': 36, 'active': true },
  25316. * { 'user': 'fred', 'age': 40, 'active': false }
  25317. * ];
  25318. *
  25319. * _.filter(users, function(o) { return !o.active; });
  25320. * // => objects for ['fred']
  25321. *
  25322. * // The `_.matches` iteratee shorthand.
  25323. * _.filter(users, { 'age': 36, 'active': true });
  25324. * // => objects for ['barney']
  25325. *
  25326. * // The `_.matchesProperty` iteratee shorthand.
  25327. * _.filter(users, ['active', false]);
  25328. * // => objects for ['fred']
  25329. *
  25330. * // The `_.property` iteratee shorthand.
  25331. * _.filter(users, 'active');
  25332. * // => objects for ['barney']
  25333. */
  25334. function filter(collection, predicate) {
  25335. var func = isArray(collection) ? arrayFilter : baseFilter;
  25336. return func(collection, getIteratee(predicate, 3));
  25337. }
  25338. /**
  25339. * Iterates over elements of `collection`, returning the first element
  25340. * `predicate` returns truthy for. The predicate is invoked with three
  25341. * arguments: (value, index|key, collection).
  25342. *
  25343. * @static
  25344. * @memberOf _
  25345. * @since 0.1.0
  25346. * @category Collection
  25347. * @param {Array|Object} collection The collection to inspect.
  25348. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25349. * @param {number} [fromIndex=0] The index to search from.
  25350. * @returns {*} Returns the matched element, else `undefined`.
  25351. * @example
  25352. *
  25353. * var users = [
  25354. * { 'user': 'barney', 'age': 36, 'active': true },
  25355. * { 'user': 'fred', 'age': 40, 'active': false },
  25356. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25357. * ];
  25358. *
  25359. * _.find(users, function(o) { return o.age < 40; });
  25360. * // => object for 'barney'
  25361. *
  25362. * // The `_.matches` iteratee shorthand.
  25363. * _.find(users, { 'age': 1, 'active': true });
  25364. * // => object for 'pebbles'
  25365. *
  25366. * // The `_.matchesProperty` iteratee shorthand.
  25367. * _.find(users, ['active', false]);
  25368. * // => object for 'fred'
  25369. *
  25370. * // The `_.property` iteratee shorthand.
  25371. * _.find(users, 'active');
  25372. * // => object for 'barney'
  25373. */
  25374. var find = createFind(findIndex);
  25375. /**
  25376. * This method is like `_.find` except that it iterates over elements of
  25377. * `collection` from right to left.
  25378. *
  25379. * @static
  25380. * @memberOf _
  25381. * @since 2.0.0
  25382. * @category Collection
  25383. * @param {Array|Object} collection The collection to inspect.
  25384. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25385. * @param {number} [fromIndex=collection.length-1] The index to search from.
  25386. * @returns {*} Returns the matched element, else `undefined`.
  25387. * @example
  25388. *
  25389. * _.findLast([1, 2, 3, 4], function(n) {
  25390. * return n % 2 == 1;
  25391. * });
  25392. * // => 3
  25393. */
  25394. var findLast = createFind(findLastIndex);
  25395. /**
  25396. * Creates a flattened array of values by running each element in `collection`
  25397. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25398. * with three arguments: (value, index|key, collection).
  25399. *
  25400. * @static
  25401. * @memberOf _
  25402. * @since 4.0.0
  25403. * @category Collection
  25404. * @param {Array|Object} collection The collection to iterate over.
  25405. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25406. * @returns {Array} Returns the new flattened array.
  25407. * @example
  25408. *
  25409. * function duplicate(n) {
  25410. * return [n, n];
  25411. * }
  25412. *
  25413. * _.flatMap([1, 2], duplicate);
  25414. * // => [1, 1, 2, 2]
  25415. */
  25416. function flatMap(collection, iteratee) {
  25417. return baseFlatten(map(collection, iteratee), 1);
  25418. }
  25419. /**
  25420. * This method is like `_.flatMap` except that it recursively flattens the
  25421. * mapped results.
  25422. *
  25423. * @static
  25424. * @memberOf _
  25425. * @since 4.7.0
  25426. * @category Collection
  25427. * @param {Array|Object} collection The collection to iterate over.
  25428. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25429. * @returns {Array} Returns the new flattened array.
  25430. * @example
  25431. *
  25432. * function duplicate(n) {
  25433. * return [[[n, n]]];
  25434. * }
  25435. *
  25436. * _.flatMapDeep([1, 2], duplicate);
  25437. * // => [1, 1, 2, 2]
  25438. */
  25439. function flatMapDeep(collection, iteratee) {
  25440. return baseFlatten(map(collection, iteratee), INFINITY);
  25441. }
  25442. /**
  25443. * This method is like `_.flatMap` except that it recursively flattens the
  25444. * mapped results up to `depth` times.
  25445. *
  25446. * @static
  25447. * @memberOf _
  25448. * @since 4.7.0
  25449. * @category Collection
  25450. * @param {Array|Object} collection The collection to iterate over.
  25451. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25452. * @param {number} [depth=1] The maximum recursion depth.
  25453. * @returns {Array} Returns the new flattened array.
  25454. * @example
  25455. *
  25456. * function duplicate(n) {
  25457. * return [[[n, n]]];
  25458. * }
  25459. *
  25460. * _.flatMapDepth([1, 2], duplicate, 2);
  25461. * // => [[1, 1], [2, 2]]
  25462. */
  25463. function flatMapDepth(collection, iteratee, depth) {
  25464. depth = depth === undefined ? 1 : toInteger(depth);
  25465. return baseFlatten(map(collection, iteratee), depth);
  25466. }
  25467. /**
  25468. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25469. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25470. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25471. *
  25472. * **Note:** As with other "Collections" methods, objects with a "length"
  25473. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25474. * or `_.forOwn` for object iteration.
  25475. *
  25476. * @static
  25477. * @memberOf _
  25478. * @since 0.1.0
  25479. * @alias each
  25480. * @category Collection
  25481. * @param {Array|Object} collection The collection to iterate over.
  25482. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25483. * @returns {Array|Object} Returns `collection`.
  25484. * @see _.forEachRight
  25485. * @example
  25486. *
  25487. * _.forEach([1, 2], function(value) {
  25488. * console.log(value);
  25489. * });
  25490. * // => Logs `1` then `2`.
  25491. *
  25492. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25493. * console.log(key);
  25494. * });
  25495. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25496. */
  25497. function forEach(collection, iteratee) {
  25498. var func = isArray(collection) ? arrayEach : baseEach;
  25499. return func(collection, getIteratee(iteratee, 3));
  25500. }
  25501. /**
  25502. * This method is like `_.forEach` except that it iterates over elements of
  25503. * `collection` from right to left.
  25504. *
  25505. * @static
  25506. * @memberOf _
  25507. * @since 2.0.0
  25508. * @alias eachRight
  25509. * @category Collection
  25510. * @param {Array|Object} collection The collection to iterate over.
  25511. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25512. * @returns {Array|Object} Returns `collection`.
  25513. * @see _.forEach
  25514. * @example
  25515. *
  25516. * _.forEachRight([1, 2], function(value) {
  25517. * console.log(value);
  25518. * });
  25519. * // => Logs `2` then `1`.
  25520. */
  25521. function forEachRight(collection, iteratee) {
  25522. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25523. return func(collection, getIteratee(iteratee, 3));
  25524. }
  25525. /**
  25526. * Creates an object composed of keys generated from the results of running
  25527. * each element of `collection` thru `iteratee`. The order of grouped values
  25528. * is determined by the order they occur in `collection`. The corresponding
  25529. * value of each key is an array of elements responsible for generating the
  25530. * key. The iteratee is invoked with one argument: (value).
  25531. *
  25532. * @static
  25533. * @memberOf _
  25534. * @since 0.1.0
  25535. * @category Collection
  25536. * @param {Array|Object} collection The collection to iterate over.
  25537. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25538. * @returns {Object} Returns the composed aggregate object.
  25539. * @example
  25540. *
  25541. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25542. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25543. *
  25544. * // The `_.property` iteratee shorthand.
  25545. * _.groupBy(['one', 'two', 'three'], 'length');
  25546. * // => { '3': ['one', 'two'], '5': ['three'] }
  25547. */
  25548. var groupBy = createAggregator(function(result, value, key) {
  25549. if (hasOwnProperty.call(result, key)) {
  25550. result[key].push(value);
  25551. } else {
  25552. baseAssignValue(result, key, [value]);
  25553. }
  25554. });
  25555. /**
  25556. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25557. * checked for a substring of `value`, otherwise
  25558. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25559. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25560. * the offset from the end of `collection`.
  25561. *
  25562. * @static
  25563. * @memberOf _
  25564. * @since 0.1.0
  25565. * @category Collection
  25566. * @param {Array|Object|string} collection The collection to inspect.
  25567. * @param {*} value The value to search for.
  25568. * @param {number} [fromIndex=0] The index to search from.
  25569. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25570. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25571. * @example
  25572. *
  25573. * _.includes([1, 2, 3], 1);
  25574. * // => true
  25575. *
  25576. * _.includes([1, 2, 3], 1, 2);
  25577. * // => false
  25578. *
  25579. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25580. * // => true
  25581. *
  25582. * _.includes('abcd', 'bc');
  25583. * // => true
  25584. */
  25585. function includes(collection, value, fromIndex, guard) {
  25586. collection = isArrayLike(collection) ? collection : values(collection);
  25587. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25588. var length = collection.length;
  25589. if (fromIndex < 0) {
  25590. fromIndex = nativeMax(length + fromIndex, 0);
  25591. }
  25592. return isString(collection)
  25593. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25594. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25595. }
  25596. /**
  25597. * Invokes the method at `path` of each element in `collection`, returning
  25598. * an array of the results of each invoked method. Any additional arguments
  25599. * are provided to each invoked method. If `path` is a function, it's invoked
  25600. * for, and `this` bound to, each element in `collection`.
  25601. *
  25602. * @static
  25603. * @memberOf _
  25604. * @since 4.0.0
  25605. * @category Collection
  25606. * @param {Array|Object} collection The collection to iterate over.
  25607. * @param {Array|Function|string} path The path of the method to invoke or
  25608. * the function invoked per iteration.
  25609. * @param {...*} [args] The arguments to invoke each method with.
  25610. * @returns {Array} Returns the array of results.
  25611. * @example
  25612. *
  25613. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25614. * // => [[1, 5, 7], [1, 2, 3]]
  25615. *
  25616. * _.invokeMap([123, 456], String.prototype.split, '');
  25617. * // => [['1', '2', '3'], ['4', '5', '6']]
  25618. */
  25619. var invokeMap = baseRest(function(collection, path, args) {
  25620. var index = -1,
  25621. isFunc = typeof path == 'function',
  25622. result = isArrayLike(collection) ? Array(collection.length) : [];
  25623. baseEach(collection, function(value) {
  25624. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25625. });
  25626. return result;
  25627. });
  25628. /**
  25629. * Creates an object composed of keys generated from the results of running
  25630. * each element of `collection` thru `iteratee`. The corresponding value of
  25631. * each key is the last element responsible for generating the key. The
  25632. * iteratee is invoked with one argument: (value).
  25633. *
  25634. * @static
  25635. * @memberOf _
  25636. * @since 4.0.0
  25637. * @category Collection
  25638. * @param {Array|Object} collection The collection to iterate over.
  25639. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25640. * @returns {Object} Returns the composed aggregate object.
  25641. * @example
  25642. *
  25643. * var array = [
  25644. * { 'dir': 'left', 'code': 97 },
  25645. * { 'dir': 'right', 'code': 100 }
  25646. * ];
  25647. *
  25648. * _.keyBy(array, function(o) {
  25649. * return String.fromCharCode(o.code);
  25650. * });
  25651. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25652. *
  25653. * _.keyBy(array, 'dir');
  25654. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25655. */
  25656. var keyBy = createAggregator(function(result, value, key) {
  25657. baseAssignValue(result, key, value);
  25658. });
  25659. /**
  25660. * Creates an array of values by running each element in `collection` thru
  25661. * `iteratee`. The iteratee is invoked with three arguments:
  25662. * (value, index|key, collection).
  25663. *
  25664. * Many lodash methods are guarded to work as iteratees for methods like
  25665. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25666. *
  25667. * The guarded methods are:
  25668. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25669. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25670. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25671. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25672. *
  25673. * @static
  25674. * @memberOf _
  25675. * @since 0.1.0
  25676. * @category Collection
  25677. * @param {Array|Object} collection The collection to iterate over.
  25678. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25679. * @returns {Array} Returns the new mapped array.
  25680. * @example
  25681. *
  25682. * function square(n) {
  25683. * return n * n;
  25684. * }
  25685. *
  25686. * _.map([4, 8], square);
  25687. * // => [16, 64]
  25688. *
  25689. * _.map({ 'a': 4, 'b': 8 }, square);
  25690. * // => [16, 64] (iteration order is not guaranteed)
  25691. *
  25692. * var users = [
  25693. * { 'user': 'barney' },
  25694. * { 'user': 'fred' }
  25695. * ];
  25696. *
  25697. * // The `_.property` iteratee shorthand.
  25698. * _.map(users, 'user');
  25699. * // => ['barney', 'fred']
  25700. */
  25701. function map(collection, iteratee) {
  25702. var func = isArray(collection) ? arrayMap : baseMap;
  25703. return func(collection, getIteratee(iteratee, 3));
  25704. }
  25705. /**
  25706. * This method is like `_.sortBy` except that it allows specifying the sort
  25707. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25708. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25709. * descending or "asc" for ascending sort order of corresponding values.
  25710. *
  25711. * @static
  25712. * @memberOf _
  25713. * @since 4.0.0
  25714. * @category Collection
  25715. * @param {Array|Object} collection The collection to iterate over.
  25716. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25717. * The iteratees to sort by.
  25718. * @param {string[]} [orders] The sort orders of `iteratees`.
  25719. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25720. * @returns {Array} Returns the new sorted array.
  25721. * @example
  25722. *
  25723. * var users = [
  25724. * { 'user': 'fred', 'age': 48 },
  25725. * { 'user': 'barney', 'age': 34 },
  25726. * { 'user': 'fred', 'age': 40 },
  25727. * { 'user': 'barney', 'age': 36 }
  25728. * ];
  25729. *
  25730. * // Sort by `user` in ascending order and by `age` in descending order.
  25731. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25732. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25733. */
  25734. function orderBy(collection, iteratees, orders, guard) {
  25735. if (collection == null) {
  25736. return [];
  25737. }
  25738. if (!isArray(iteratees)) {
  25739. iteratees = iteratees == null ? [] : [iteratees];
  25740. }
  25741. orders = guard ? undefined : orders;
  25742. if (!isArray(orders)) {
  25743. orders = orders == null ? [] : [orders];
  25744. }
  25745. return baseOrderBy(collection, iteratees, orders);
  25746. }
  25747. /**
  25748. * Creates an array of elements split into two groups, the first of which
  25749. * contains elements `predicate` returns truthy for, the second of which
  25750. * contains elements `predicate` returns falsey for. The predicate is
  25751. * invoked with one argument: (value).
  25752. *
  25753. * @static
  25754. * @memberOf _
  25755. * @since 3.0.0
  25756. * @category Collection
  25757. * @param {Array|Object} collection The collection to iterate over.
  25758. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25759. * @returns {Array} Returns the array of grouped elements.
  25760. * @example
  25761. *
  25762. * var users = [
  25763. * { 'user': 'barney', 'age': 36, 'active': false },
  25764. * { 'user': 'fred', 'age': 40, 'active': true },
  25765. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25766. * ];
  25767. *
  25768. * _.partition(users, function(o) { return o.active; });
  25769. * // => objects for [['fred'], ['barney', 'pebbles']]
  25770. *
  25771. * // The `_.matches` iteratee shorthand.
  25772. * _.partition(users, { 'age': 1, 'active': false });
  25773. * // => objects for [['pebbles'], ['barney', 'fred']]
  25774. *
  25775. * // The `_.matchesProperty` iteratee shorthand.
  25776. * _.partition(users, ['active', false]);
  25777. * // => objects for [['barney', 'pebbles'], ['fred']]
  25778. *
  25779. * // The `_.property` iteratee shorthand.
  25780. * _.partition(users, 'active');
  25781. * // => objects for [['fred'], ['barney', 'pebbles']]
  25782. */
  25783. var partition = createAggregator(function(result, value, key) {
  25784. result[key ? 0 : 1].push(value);
  25785. }, function() { return [[], []]; });
  25786. /**
  25787. * Reduces `collection` to a value which is the accumulated result of running
  25788. * each element in `collection` thru `iteratee`, where each successive
  25789. * invocation is supplied the return value of the previous. If `accumulator`
  25790. * is not given, the first element of `collection` is used as the initial
  25791. * value. The iteratee is invoked with four arguments:
  25792. * (accumulator, value, index|key, collection).
  25793. *
  25794. * Many lodash methods are guarded to work as iteratees for methods like
  25795. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25796. *
  25797. * The guarded methods are:
  25798. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25799. * and `sortBy`
  25800. *
  25801. * @static
  25802. * @memberOf _
  25803. * @since 0.1.0
  25804. * @category Collection
  25805. * @param {Array|Object} collection The collection to iterate over.
  25806. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25807. * @param {*} [accumulator] The initial value.
  25808. * @returns {*} Returns the accumulated value.
  25809. * @see _.reduceRight
  25810. * @example
  25811. *
  25812. * _.reduce([1, 2], function(sum, n) {
  25813. * return sum + n;
  25814. * }, 0);
  25815. * // => 3
  25816. *
  25817. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25818. * (result[value] || (result[value] = [])).push(key);
  25819. * return result;
  25820. * }, {});
  25821. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25822. */
  25823. function reduce(collection, iteratee, accumulator) {
  25824. var func = isArray(collection) ? arrayReduce : baseReduce,
  25825. initAccum = arguments.length < 3;
  25826. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25827. }
  25828. /**
  25829. * This method is like `_.reduce` except that it iterates over elements of
  25830. * `collection` from right to left.
  25831. *
  25832. * @static
  25833. * @memberOf _
  25834. * @since 0.1.0
  25835. * @category Collection
  25836. * @param {Array|Object} collection The collection to iterate over.
  25837. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25838. * @param {*} [accumulator] The initial value.
  25839. * @returns {*} Returns the accumulated value.
  25840. * @see _.reduce
  25841. * @example
  25842. *
  25843. * var array = [[0, 1], [2, 3], [4, 5]];
  25844. *
  25845. * _.reduceRight(array, function(flattened, other) {
  25846. * return flattened.concat(other);
  25847. * }, []);
  25848. * // => [4, 5, 2, 3, 0, 1]
  25849. */
  25850. function reduceRight(collection, iteratee, accumulator) {
  25851. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25852. initAccum = arguments.length < 3;
  25853. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25854. }
  25855. /**
  25856. * The opposite of `_.filter`; this method returns the elements of `collection`
  25857. * that `predicate` does **not** return truthy for.
  25858. *
  25859. * @static
  25860. * @memberOf _
  25861. * @since 0.1.0
  25862. * @category Collection
  25863. * @param {Array|Object} collection The collection to iterate over.
  25864. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25865. * @returns {Array} Returns the new filtered array.
  25866. * @see _.filter
  25867. * @example
  25868. *
  25869. * var users = [
  25870. * { 'user': 'barney', 'age': 36, 'active': false },
  25871. * { 'user': 'fred', 'age': 40, 'active': true }
  25872. * ];
  25873. *
  25874. * _.reject(users, function(o) { return !o.active; });
  25875. * // => objects for ['fred']
  25876. *
  25877. * // The `_.matches` iteratee shorthand.
  25878. * _.reject(users, { 'age': 40, 'active': true });
  25879. * // => objects for ['barney']
  25880. *
  25881. * // The `_.matchesProperty` iteratee shorthand.
  25882. * _.reject(users, ['active', false]);
  25883. * // => objects for ['fred']
  25884. *
  25885. * // The `_.property` iteratee shorthand.
  25886. * _.reject(users, 'active');
  25887. * // => objects for ['barney']
  25888. */
  25889. function reject(collection, predicate) {
  25890. var func = isArray(collection) ? arrayFilter : baseFilter;
  25891. return func(collection, negate(getIteratee(predicate, 3)));
  25892. }
  25893. /**
  25894. * Gets a random element from `collection`.
  25895. *
  25896. * @static
  25897. * @memberOf _
  25898. * @since 2.0.0
  25899. * @category Collection
  25900. * @param {Array|Object} collection The collection to sample.
  25901. * @returns {*} Returns the random element.
  25902. * @example
  25903. *
  25904. * _.sample([1, 2, 3, 4]);
  25905. * // => 2
  25906. */
  25907. function sample(collection) {
  25908. var func = isArray(collection) ? arraySample : baseSample;
  25909. return func(collection);
  25910. }
  25911. /**
  25912. * Gets `n` random elements at unique keys from `collection` up to the
  25913. * size of `collection`.
  25914. *
  25915. * @static
  25916. * @memberOf _
  25917. * @since 4.0.0
  25918. * @category Collection
  25919. * @param {Array|Object} collection The collection to sample.
  25920. * @param {number} [n=1] The number of elements to sample.
  25921. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25922. * @returns {Array} Returns the random elements.
  25923. * @example
  25924. *
  25925. * _.sampleSize([1, 2, 3], 2);
  25926. * // => [3, 1]
  25927. *
  25928. * _.sampleSize([1, 2, 3], 4);
  25929. * // => [2, 3, 1]
  25930. */
  25931. function sampleSize(collection, n, guard) {
  25932. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25933. n = 1;
  25934. } else {
  25935. n = toInteger(n);
  25936. }
  25937. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25938. return func(collection, n);
  25939. }
  25940. /**
  25941. * Creates an array of shuffled values, using a version of the
  25942. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25943. *
  25944. * @static
  25945. * @memberOf _
  25946. * @since 0.1.0
  25947. * @category Collection
  25948. * @param {Array|Object} collection The collection to shuffle.
  25949. * @returns {Array} Returns the new shuffled array.
  25950. * @example
  25951. *
  25952. * _.shuffle([1, 2, 3, 4]);
  25953. * // => [4, 1, 3, 2]
  25954. */
  25955. function shuffle(collection) {
  25956. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25957. return func(collection);
  25958. }
  25959. /**
  25960. * Gets the size of `collection` by returning its length for array-like
  25961. * values or the number of own enumerable string keyed properties for objects.
  25962. *
  25963. * @static
  25964. * @memberOf _
  25965. * @since 0.1.0
  25966. * @category Collection
  25967. * @param {Array|Object|string} collection The collection to inspect.
  25968. * @returns {number} Returns the collection size.
  25969. * @example
  25970. *
  25971. * _.size([1, 2, 3]);
  25972. * // => 3
  25973. *
  25974. * _.size({ 'a': 1, 'b': 2 });
  25975. * // => 2
  25976. *
  25977. * _.size('pebbles');
  25978. * // => 7
  25979. */
  25980. function size(collection) {
  25981. if (collection == null) {
  25982. return 0;
  25983. }
  25984. if (isArrayLike(collection)) {
  25985. return isString(collection) ? stringSize(collection) : collection.length;
  25986. }
  25987. var tag = getTag(collection);
  25988. if (tag == mapTag || tag == setTag) {
  25989. return collection.size;
  25990. }
  25991. return baseKeys(collection).length;
  25992. }
  25993. /**
  25994. * Checks if `predicate` returns truthy for **any** element of `collection`.
  25995. * Iteration is stopped once `predicate` returns truthy. The predicate is
  25996. * invoked with three arguments: (value, index|key, collection).
  25997. *
  25998. * @static
  25999. * @memberOf _
  26000. * @since 0.1.0
  26001. * @category Collection
  26002. * @param {Array|Object} collection The collection to iterate over.
  26003. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26004. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26005. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26006. * else `false`.
  26007. * @example
  26008. *
  26009. * _.some([null, 0, 'yes', false], Boolean);
  26010. * // => true
  26011. *
  26012. * var users = [
  26013. * { 'user': 'barney', 'active': true },
  26014. * { 'user': 'fred', 'active': false }
  26015. * ];
  26016. *
  26017. * // The `_.matches` iteratee shorthand.
  26018. * _.some(users, { 'user': 'barney', 'active': false });
  26019. * // => false
  26020. *
  26021. * // The `_.matchesProperty` iteratee shorthand.
  26022. * _.some(users, ['active', false]);
  26023. * // => true
  26024. *
  26025. * // The `_.property` iteratee shorthand.
  26026. * _.some(users, 'active');
  26027. * // => true
  26028. */
  26029. function some(collection, predicate, guard) {
  26030. var func = isArray(collection) ? arraySome : baseSome;
  26031. if (guard && isIterateeCall(collection, predicate, guard)) {
  26032. predicate = undefined;
  26033. }
  26034. return func(collection, getIteratee(predicate, 3));
  26035. }
  26036. /**
  26037. * Creates an array of elements, sorted in ascending order by the results of
  26038. * running each element in a collection thru each iteratee. This method
  26039. * performs a stable sort, that is, it preserves the original sort order of
  26040. * equal elements. The iteratees are invoked with one argument: (value).
  26041. *
  26042. * @static
  26043. * @memberOf _
  26044. * @since 0.1.0
  26045. * @category Collection
  26046. * @param {Array|Object} collection The collection to iterate over.
  26047. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26048. * The iteratees to sort by.
  26049. * @returns {Array} Returns the new sorted array.
  26050. * @example
  26051. *
  26052. * var users = [
  26053. * { 'user': 'fred', 'age': 48 },
  26054. * { 'user': 'barney', 'age': 36 },
  26055. * { 'user': 'fred', 'age': 40 },
  26056. * { 'user': 'barney', 'age': 34 }
  26057. * ];
  26058. *
  26059. * _.sortBy(users, [function(o) { return o.user; }]);
  26060. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26061. *
  26062. * _.sortBy(users, ['user', 'age']);
  26063. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26064. */
  26065. var sortBy = baseRest(function(collection, iteratees) {
  26066. if (collection == null) {
  26067. return [];
  26068. }
  26069. var length = iteratees.length;
  26070. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26071. iteratees = [];
  26072. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26073. iteratees = [iteratees[0]];
  26074. }
  26075. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26076. });
  26077. /*------------------------------------------------------------------------*/
  26078. /**
  26079. * Gets the timestamp of the number of milliseconds that have elapsed since
  26080. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26081. *
  26082. * @static
  26083. * @memberOf _
  26084. * @since 2.4.0
  26085. * @category Date
  26086. * @returns {number} Returns the timestamp.
  26087. * @example
  26088. *
  26089. * _.defer(function(stamp) {
  26090. * console.log(_.now() - stamp);
  26091. * }, _.now());
  26092. * // => Logs the number of milliseconds it took for the deferred invocation.
  26093. */
  26094. var now = ctxNow || function() {
  26095. return root.Date.now();
  26096. };
  26097. /*------------------------------------------------------------------------*/
  26098. /**
  26099. * The opposite of `_.before`; this method creates a function that invokes
  26100. * `func` once it's called `n` or more times.
  26101. *
  26102. * @static
  26103. * @memberOf _
  26104. * @since 0.1.0
  26105. * @category Function
  26106. * @param {number} n The number of calls before `func` is invoked.
  26107. * @param {Function} func The function to restrict.
  26108. * @returns {Function} Returns the new restricted function.
  26109. * @example
  26110. *
  26111. * var saves = ['profile', 'settings'];
  26112. *
  26113. * var done = _.after(saves.length, function() {
  26114. * console.log('done saving!');
  26115. * });
  26116. *
  26117. * _.forEach(saves, function(type) {
  26118. * asyncSave({ 'type': type, 'complete': done });
  26119. * });
  26120. * // => Logs 'done saving!' after the two async saves have completed.
  26121. */
  26122. function after(n, func) {
  26123. if (typeof func != 'function') {
  26124. throw new TypeError(FUNC_ERROR_TEXT);
  26125. }
  26126. n = toInteger(n);
  26127. return function() {
  26128. if (--n < 1) {
  26129. return func.apply(this, arguments);
  26130. }
  26131. };
  26132. }
  26133. /**
  26134. * Creates a function that invokes `func`, with up to `n` arguments,
  26135. * ignoring any additional arguments.
  26136. *
  26137. * @static
  26138. * @memberOf _
  26139. * @since 3.0.0
  26140. * @category Function
  26141. * @param {Function} func The function to cap arguments for.
  26142. * @param {number} [n=func.length] The arity cap.
  26143. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26144. * @returns {Function} Returns the new capped function.
  26145. * @example
  26146. *
  26147. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26148. * // => [6, 8, 10]
  26149. */
  26150. function ary(func, n, guard) {
  26151. n = guard ? undefined : n;
  26152. n = (func && n == null) ? func.length : n;
  26153. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26154. }
  26155. /**
  26156. * Creates a function that invokes `func`, with the `this` binding and arguments
  26157. * of the created function, while it's called less than `n` times. Subsequent
  26158. * calls to the created function return the result of the last `func` invocation.
  26159. *
  26160. * @static
  26161. * @memberOf _
  26162. * @since 3.0.0
  26163. * @category Function
  26164. * @param {number} n The number of calls at which `func` is no longer invoked.
  26165. * @param {Function} func The function to restrict.
  26166. * @returns {Function} Returns the new restricted function.
  26167. * @example
  26168. *
  26169. * jQuery(element).on('click', _.before(5, addContactToList));
  26170. * // => Allows adding up to 4 contacts to the list.
  26171. */
  26172. function before(n, func) {
  26173. var result;
  26174. if (typeof func != 'function') {
  26175. throw new TypeError(FUNC_ERROR_TEXT);
  26176. }
  26177. n = toInteger(n);
  26178. return function() {
  26179. if (--n > 0) {
  26180. result = func.apply(this, arguments);
  26181. }
  26182. if (n <= 1) {
  26183. func = undefined;
  26184. }
  26185. return result;
  26186. };
  26187. }
  26188. /**
  26189. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26190. * and `partials` prepended to the arguments it receives.
  26191. *
  26192. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26193. * may be used as a placeholder for partially applied arguments.
  26194. *
  26195. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26196. * property of bound functions.
  26197. *
  26198. * @static
  26199. * @memberOf _
  26200. * @since 0.1.0
  26201. * @category Function
  26202. * @param {Function} func The function to bind.
  26203. * @param {*} thisArg The `this` binding of `func`.
  26204. * @param {...*} [partials] The arguments to be partially applied.
  26205. * @returns {Function} Returns the new bound function.
  26206. * @example
  26207. *
  26208. * function greet(greeting, punctuation) {
  26209. * return greeting + ' ' + this.user + punctuation;
  26210. * }
  26211. *
  26212. * var object = { 'user': 'fred' };
  26213. *
  26214. * var bound = _.bind(greet, object, 'hi');
  26215. * bound('!');
  26216. * // => 'hi fred!'
  26217. *
  26218. * // Bound with placeholders.
  26219. * var bound = _.bind(greet, object, _, '!');
  26220. * bound('hi');
  26221. * // => 'hi fred!'
  26222. */
  26223. var bind = baseRest(function(func, thisArg, partials) {
  26224. var bitmask = WRAP_BIND_FLAG;
  26225. if (partials.length) {
  26226. var holders = replaceHolders(partials, getHolder(bind));
  26227. bitmask |= WRAP_PARTIAL_FLAG;
  26228. }
  26229. return createWrap(func, bitmask, thisArg, partials, holders);
  26230. });
  26231. /**
  26232. * Creates a function that invokes the method at `object[key]` with `partials`
  26233. * prepended to the arguments it receives.
  26234. *
  26235. * This method differs from `_.bind` by allowing bound functions to reference
  26236. * methods that may be redefined or don't yet exist. See
  26237. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26238. * for more details.
  26239. *
  26240. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26241. * builds, may be used as a placeholder for partially applied arguments.
  26242. *
  26243. * @static
  26244. * @memberOf _
  26245. * @since 0.10.0
  26246. * @category Function
  26247. * @param {Object} object The object to invoke the method on.
  26248. * @param {string} key The key of the method.
  26249. * @param {...*} [partials] The arguments to be partially applied.
  26250. * @returns {Function} Returns the new bound function.
  26251. * @example
  26252. *
  26253. * var object = {
  26254. * 'user': 'fred',
  26255. * 'greet': function(greeting, punctuation) {
  26256. * return greeting + ' ' + this.user + punctuation;
  26257. * }
  26258. * };
  26259. *
  26260. * var bound = _.bindKey(object, 'greet', 'hi');
  26261. * bound('!');
  26262. * // => 'hi fred!'
  26263. *
  26264. * object.greet = function(greeting, punctuation) {
  26265. * return greeting + 'ya ' + this.user + punctuation;
  26266. * };
  26267. *
  26268. * bound('!');
  26269. * // => 'hiya fred!'
  26270. *
  26271. * // Bound with placeholders.
  26272. * var bound = _.bindKey(object, 'greet', _, '!');
  26273. * bound('hi');
  26274. * // => 'hiya fred!'
  26275. */
  26276. var bindKey = baseRest(function(object, key, partials) {
  26277. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26278. if (partials.length) {
  26279. var holders = replaceHolders(partials, getHolder(bindKey));
  26280. bitmask |= WRAP_PARTIAL_FLAG;
  26281. }
  26282. return createWrap(key, bitmask, object, partials, holders);
  26283. });
  26284. /**
  26285. * Creates a function that accepts arguments of `func` and either invokes
  26286. * `func` returning its result, if at least `arity` number of arguments have
  26287. * been provided, or returns a function that accepts the remaining `func`
  26288. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26289. * is not sufficient.
  26290. *
  26291. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26292. * may be used as a placeholder for provided arguments.
  26293. *
  26294. * **Note:** This method doesn't set the "length" property of curried functions.
  26295. *
  26296. * @static
  26297. * @memberOf _
  26298. * @since 2.0.0
  26299. * @category Function
  26300. * @param {Function} func The function to curry.
  26301. * @param {number} [arity=func.length] The arity of `func`.
  26302. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26303. * @returns {Function} Returns the new curried function.
  26304. * @example
  26305. *
  26306. * var abc = function(a, b, c) {
  26307. * return [a, b, c];
  26308. * };
  26309. *
  26310. * var curried = _.curry(abc);
  26311. *
  26312. * curried(1)(2)(3);
  26313. * // => [1, 2, 3]
  26314. *
  26315. * curried(1, 2)(3);
  26316. * // => [1, 2, 3]
  26317. *
  26318. * curried(1, 2, 3);
  26319. * // => [1, 2, 3]
  26320. *
  26321. * // Curried with placeholders.
  26322. * curried(1)(_, 3)(2);
  26323. * // => [1, 2, 3]
  26324. */
  26325. function curry(func, arity, guard) {
  26326. arity = guard ? undefined : arity;
  26327. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26328. result.placeholder = curry.placeholder;
  26329. return result;
  26330. }
  26331. /**
  26332. * This method is like `_.curry` except that arguments are applied to `func`
  26333. * in the manner of `_.partialRight` instead of `_.partial`.
  26334. *
  26335. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26336. * builds, may be used as a placeholder for provided arguments.
  26337. *
  26338. * **Note:** This method doesn't set the "length" property of curried functions.
  26339. *
  26340. * @static
  26341. * @memberOf _
  26342. * @since 3.0.0
  26343. * @category Function
  26344. * @param {Function} func The function to curry.
  26345. * @param {number} [arity=func.length] The arity of `func`.
  26346. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26347. * @returns {Function} Returns the new curried function.
  26348. * @example
  26349. *
  26350. * var abc = function(a, b, c) {
  26351. * return [a, b, c];
  26352. * };
  26353. *
  26354. * var curried = _.curryRight(abc);
  26355. *
  26356. * curried(3)(2)(1);
  26357. * // => [1, 2, 3]
  26358. *
  26359. * curried(2, 3)(1);
  26360. * // => [1, 2, 3]
  26361. *
  26362. * curried(1, 2, 3);
  26363. * // => [1, 2, 3]
  26364. *
  26365. * // Curried with placeholders.
  26366. * curried(3)(1, _)(2);
  26367. * // => [1, 2, 3]
  26368. */
  26369. function curryRight(func, arity, guard) {
  26370. arity = guard ? undefined : arity;
  26371. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26372. result.placeholder = curryRight.placeholder;
  26373. return result;
  26374. }
  26375. /**
  26376. * Creates a debounced function that delays invoking `func` until after `wait`
  26377. * milliseconds have elapsed since the last time the debounced function was
  26378. * invoked. The debounced function comes with a `cancel` method to cancel
  26379. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26380. * Provide `options` to indicate whether `func` should be invoked on the
  26381. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26382. * with the last arguments provided to the debounced function. Subsequent
  26383. * calls to the debounced function return the result of the last `func`
  26384. * invocation.
  26385. *
  26386. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26387. * invoked on the trailing edge of the timeout only if the debounced function
  26388. * is invoked more than once during the `wait` timeout.
  26389. *
  26390. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26391. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26392. *
  26393. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26394. * for details over the differences between `_.debounce` and `_.throttle`.
  26395. *
  26396. * @static
  26397. * @memberOf _
  26398. * @since 0.1.0
  26399. * @category Function
  26400. * @param {Function} func The function to debounce.
  26401. * @param {number} [wait=0] The number of milliseconds to delay.
  26402. * @param {Object} [options={}] The options object.
  26403. * @param {boolean} [options.leading=false]
  26404. * Specify invoking on the leading edge of the timeout.
  26405. * @param {number} [options.maxWait]
  26406. * The maximum time `func` is allowed to be delayed before it's invoked.
  26407. * @param {boolean} [options.trailing=true]
  26408. * Specify invoking on the trailing edge of the timeout.
  26409. * @returns {Function} Returns the new debounced function.
  26410. * @example
  26411. *
  26412. * // Avoid costly calculations while the window size is in flux.
  26413. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26414. *
  26415. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26416. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26417. * 'leading': true,
  26418. * 'trailing': false
  26419. * }));
  26420. *
  26421. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26422. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26423. * var source = new EventSource('/stream');
  26424. * jQuery(source).on('message', debounced);
  26425. *
  26426. * // Cancel the trailing debounced invocation.
  26427. * jQuery(window).on('popstate', debounced.cancel);
  26428. */
  26429. function debounce(func, wait, options) {
  26430. var lastArgs,
  26431. lastThis,
  26432. maxWait,
  26433. result,
  26434. timerId,
  26435. lastCallTime,
  26436. lastInvokeTime = 0,
  26437. leading = false,
  26438. maxing = false,
  26439. trailing = true;
  26440. if (typeof func != 'function') {
  26441. throw new TypeError(FUNC_ERROR_TEXT);
  26442. }
  26443. wait = toNumber(wait) || 0;
  26444. if (isObject(options)) {
  26445. leading = !!options.leading;
  26446. maxing = 'maxWait' in options;
  26447. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26448. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26449. }
  26450. function invokeFunc(time) {
  26451. var args = lastArgs,
  26452. thisArg = lastThis;
  26453. lastArgs = lastThis = undefined;
  26454. lastInvokeTime = time;
  26455. result = func.apply(thisArg, args);
  26456. return result;
  26457. }
  26458. function leadingEdge(time) {
  26459. // Reset any `maxWait` timer.
  26460. lastInvokeTime = time;
  26461. // Start the timer for the trailing edge.
  26462. timerId = setTimeout(timerExpired, wait);
  26463. // Invoke the leading edge.
  26464. return leading ? invokeFunc(time) : result;
  26465. }
  26466. function remainingWait(time) {
  26467. var timeSinceLastCall = time - lastCallTime,
  26468. timeSinceLastInvoke = time - lastInvokeTime,
  26469. timeWaiting = wait - timeSinceLastCall;
  26470. return maxing
  26471. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26472. : timeWaiting;
  26473. }
  26474. function shouldInvoke(time) {
  26475. var timeSinceLastCall = time - lastCallTime,
  26476. timeSinceLastInvoke = time - lastInvokeTime;
  26477. // Either this is the first call, activity has stopped and we're at the
  26478. // trailing edge, the system time has gone backwards and we're treating
  26479. // it as the trailing edge, or we've hit the `maxWait` limit.
  26480. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26481. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26482. }
  26483. function timerExpired() {
  26484. var time = now();
  26485. if (shouldInvoke(time)) {
  26486. return trailingEdge(time);
  26487. }
  26488. // Restart the timer.
  26489. timerId = setTimeout(timerExpired, remainingWait(time));
  26490. }
  26491. function trailingEdge(time) {
  26492. timerId = undefined;
  26493. // Only invoke if we have `lastArgs` which means `func` has been
  26494. // debounced at least once.
  26495. if (trailing && lastArgs) {
  26496. return invokeFunc(time);
  26497. }
  26498. lastArgs = lastThis = undefined;
  26499. return result;
  26500. }
  26501. function cancel() {
  26502. if (timerId !== undefined) {
  26503. clearTimeout(timerId);
  26504. }
  26505. lastInvokeTime = 0;
  26506. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26507. }
  26508. function flush() {
  26509. return timerId === undefined ? result : trailingEdge(now());
  26510. }
  26511. function debounced() {
  26512. var time = now(),
  26513. isInvoking = shouldInvoke(time);
  26514. lastArgs = arguments;
  26515. lastThis = this;
  26516. lastCallTime = time;
  26517. if (isInvoking) {
  26518. if (timerId === undefined) {
  26519. return leadingEdge(lastCallTime);
  26520. }
  26521. if (maxing) {
  26522. // Handle invocations in a tight loop.
  26523. clearTimeout(timerId);
  26524. timerId = setTimeout(timerExpired, wait);
  26525. return invokeFunc(lastCallTime);
  26526. }
  26527. }
  26528. if (timerId === undefined) {
  26529. timerId = setTimeout(timerExpired, wait);
  26530. }
  26531. return result;
  26532. }
  26533. debounced.cancel = cancel;
  26534. debounced.flush = flush;
  26535. return debounced;
  26536. }
  26537. /**
  26538. * Defers invoking the `func` until the current call stack has cleared. Any
  26539. * additional arguments are provided to `func` when it's invoked.
  26540. *
  26541. * @static
  26542. * @memberOf _
  26543. * @since 0.1.0
  26544. * @category Function
  26545. * @param {Function} func The function to defer.
  26546. * @param {...*} [args] The arguments to invoke `func` with.
  26547. * @returns {number} Returns the timer id.
  26548. * @example
  26549. *
  26550. * _.defer(function(text) {
  26551. * console.log(text);
  26552. * }, 'deferred');
  26553. * // => Logs 'deferred' after one millisecond.
  26554. */
  26555. var defer = baseRest(function(func, args) {
  26556. return baseDelay(func, 1, args);
  26557. });
  26558. /**
  26559. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26560. * provided to `func` when it's invoked.
  26561. *
  26562. * @static
  26563. * @memberOf _
  26564. * @since 0.1.0
  26565. * @category Function
  26566. * @param {Function} func The function to delay.
  26567. * @param {number} wait The number of milliseconds to delay invocation.
  26568. * @param {...*} [args] The arguments to invoke `func` with.
  26569. * @returns {number} Returns the timer id.
  26570. * @example
  26571. *
  26572. * _.delay(function(text) {
  26573. * console.log(text);
  26574. * }, 1000, 'later');
  26575. * // => Logs 'later' after one second.
  26576. */
  26577. var delay = baseRest(function(func, wait, args) {
  26578. return baseDelay(func, toNumber(wait) || 0, args);
  26579. });
  26580. /**
  26581. * Creates a function that invokes `func` with arguments reversed.
  26582. *
  26583. * @static
  26584. * @memberOf _
  26585. * @since 4.0.0
  26586. * @category Function
  26587. * @param {Function} func The function to flip arguments for.
  26588. * @returns {Function} Returns the new flipped function.
  26589. * @example
  26590. *
  26591. * var flipped = _.flip(function() {
  26592. * return _.toArray(arguments);
  26593. * });
  26594. *
  26595. * flipped('a', 'b', 'c', 'd');
  26596. * // => ['d', 'c', 'b', 'a']
  26597. */
  26598. function flip(func) {
  26599. return createWrap(func, WRAP_FLIP_FLAG);
  26600. }
  26601. /**
  26602. * Creates a function that memoizes the result of `func`. If `resolver` is
  26603. * provided, it determines the cache key for storing the result based on the
  26604. * arguments provided to the memoized function. By default, the first argument
  26605. * provided to the memoized function is used as the map cache key. The `func`
  26606. * is invoked with the `this` binding of the memoized function.
  26607. *
  26608. * **Note:** The cache is exposed as the `cache` property on the memoized
  26609. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26610. * constructor with one whose instances implement the
  26611. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26612. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26613. *
  26614. * @static
  26615. * @memberOf _
  26616. * @since 0.1.0
  26617. * @category Function
  26618. * @param {Function} func The function to have its output memoized.
  26619. * @param {Function} [resolver] The function to resolve the cache key.
  26620. * @returns {Function} Returns the new memoized function.
  26621. * @example
  26622. *
  26623. * var object = { 'a': 1, 'b': 2 };
  26624. * var other = { 'c': 3, 'd': 4 };
  26625. *
  26626. * var values = _.memoize(_.values);
  26627. * values(object);
  26628. * // => [1, 2]
  26629. *
  26630. * values(other);
  26631. * // => [3, 4]
  26632. *
  26633. * object.a = 2;
  26634. * values(object);
  26635. * // => [1, 2]
  26636. *
  26637. * // Modify the result cache.
  26638. * values.cache.set(object, ['a', 'b']);
  26639. * values(object);
  26640. * // => ['a', 'b']
  26641. *
  26642. * // Replace `_.memoize.Cache`.
  26643. * _.memoize.Cache = WeakMap;
  26644. */
  26645. function memoize(func, resolver) {
  26646. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26647. throw new TypeError(FUNC_ERROR_TEXT);
  26648. }
  26649. var memoized = function() {
  26650. var args = arguments,
  26651. key = resolver ? resolver.apply(this, args) : args[0],
  26652. cache = memoized.cache;
  26653. if (cache.has(key)) {
  26654. return cache.get(key);
  26655. }
  26656. var result = func.apply(this, args);
  26657. memoized.cache = cache.set(key, result) || cache;
  26658. return result;
  26659. };
  26660. memoized.cache = new (memoize.Cache || MapCache);
  26661. return memoized;
  26662. }
  26663. // Expose `MapCache`.
  26664. memoize.Cache = MapCache;
  26665. /**
  26666. * Creates a function that negates the result of the predicate `func`. The
  26667. * `func` predicate is invoked with the `this` binding and arguments of the
  26668. * created function.
  26669. *
  26670. * @static
  26671. * @memberOf _
  26672. * @since 3.0.0
  26673. * @category Function
  26674. * @param {Function} predicate The predicate to negate.
  26675. * @returns {Function} Returns the new negated function.
  26676. * @example
  26677. *
  26678. * function isEven(n) {
  26679. * return n % 2 == 0;
  26680. * }
  26681. *
  26682. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26683. * // => [1, 3, 5]
  26684. */
  26685. function negate(predicate) {
  26686. if (typeof predicate != 'function') {
  26687. throw new TypeError(FUNC_ERROR_TEXT);
  26688. }
  26689. return function() {
  26690. var args = arguments;
  26691. switch (args.length) {
  26692. case 0: return !predicate.call(this);
  26693. case 1: return !predicate.call(this, args[0]);
  26694. case 2: return !predicate.call(this, args[0], args[1]);
  26695. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26696. }
  26697. return !predicate.apply(this, args);
  26698. };
  26699. }
  26700. /**
  26701. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26702. * to the function return the value of the first invocation. The `func` is
  26703. * invoked with the `this` binding and arguments of the created function.
  26704. *
  26705. * @static
  26706. * @memberOf _
  26707. * @since 0.1.0
  26708. * @category Function
  26709. * @param {Function} func The function to restrict.
  26710. * @returns {Function} Returns the new restricted function.
  26711. * @example
  26712. *
  26713. * var initialize = _.once(createApplication);
  26714. * initialize();
  26715. * initialize();
  26716. * // => `createApplication` is invoked once
  26717. */
  26718. function once(func) {
  26719. return before(2, func);
  26720. }
  26721. /**
  26722. * Creates a function that invokes `func` with its arguments transformed.
  26723. *
  26724. * @static
  26725. * @since 4.0.0
  26726. * @memberOf _
  26727. * @category Function
  26728. * @param {Function} func The function to wrap.
  26729. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26730. * The argument transforms.
  26731. * @returns {Function} Returns the new function.
  26732. * @example
  26733. *
  26734. * function doubled(n) {
  26735. * return n * 2;
  26736. * }
  26737. *
  26738. * function square(n) {
  26739. * return n * n;
  26740. * }
  26741. *
  26742. * var func = _.overArgs(function(x, y) {
  26743. * return [x, y];
  26744. * }, [square, doubled]);
  26745. *
  26746. * func(9, 3);
  26747. * // => [81, 6]
  26748. *
  26749. * func(10, 5);
  26750. * // => [100, 10]
  26751. */
  26752. var overArgs = castRest(function(func, transforms) {
  26753. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26754. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26755. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26756. var funcsLength = transforms.length;
  26757. return baseRest(function(args) {
  26758. var index = -1,
  26759. length = nativeMin(args.length, funcsLength);
  26760. while (++index < length) {
  26761. args[index] = transforms[index].call(this, args[index]);
  26762. }
  26763. return apply(func, this, args);
  26764. });
  26765. });
  26766. /**
  26767. * Creates a function that invokes `func` with `partials` prepended to the
  26768. * arguments it receives. This method is like `_.bind` except it does **not**
  26769. * alter the `this` binding.
  26770. *
  26771. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26772. * builds, may be used as a placeholder for partially applied arguments.
  26773. *
  26774. * **Note:** This method doesn't set the "length" property of partially
  26775. * applied functions.
  26776. *
  26777. * @static
  26778. * @memberOf _
  26779. * @since 0.2.0
  26780. * @category Function
  26781. * @param {Function} func The function to partially apply arguments to.
  26782. * @param {...*} [partials] The arguments to be partially applied.
  26783. * @returns {Function} Returns the new partially applied function.
  26784. * @example
  26785. *
  26786. * function greet(greeting, name) {
  26787. * return greeting + ' ' + name;
  26788. * }
  26789. *
  26790. * var sayHelloTo = _.partial(greet, 'hello');
  26791. * sayHelloTo('fred');
  26792. * // => 'hello fred'
  26793. *
  26794. * // Partially applied with placeholders.
  26795. * var greetFred = _.partial(greet, _, 'fred');
  26796. * greetFred('hi');
  26797. * // => 'hi fred'
  26798. */
  26799. var partial = baseRest(function(func, partials) {
  26800. var holders = replaceHolders(partials, getHolder(partial));
  26801. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26802. });
  26803. /**
  26804. * This method is like `_.partial` except that partially applied arguments
  26805. * are appended to the arguments it receives.
  26806. *
  26807. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  26808. * builds, may be used as a placeholder for partially applied arguments.
  26809. *
  26810. * **Note:** This method doesn't set the "length" property of partially
  26811. * applied functions.
  26812. *
  26813. * @static
  26814. * @memberOf _
  26815. * @since 1.0.0
  26816. * @category Function
  26817. * @param {Function} func The function to partially apply arguments to.
  26818. * @param {...*} [partials] The arguments to be partially applied.
  26819. * @returns {Function} Returns the new partially applied function.
  26820. * @example
  26821. *
  26822. * function greet(greeting, name) {
  26823. * return greeting + ' ' + name;
  26824. * }
  26825. *
  26826. * var greetFred = _.partialRight(greet, 'fred');
  26827. * greetFred('hi');
  26828. * // => 'hi fred'
  26829. *
  26830. * // Partially applied with placeholders.
  26831. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26832. * sayHelloTo('fred');
  26833. * // => 'hello fred'
  26834. */
  26835. var partialRight = baseRest(function(func, partials) {
  26836. var holders = replaceHolders(partials, getHolder(partialRight));
  26837. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26838. });
  26839. /**
  26840. * Creates a function that invokes `func` with arguments arranged according
  26841. * to the specified `indexes` where the argument value at the first index is
  26842. * provided as the first argument, the argument value at the second index is
  26843. * provided as the second argument, and so on.
  26844. *
  26845. * @static
  26846. * @memberOf _
  26847. * @since 3.0.0
  26848. * @category Function
  26849. * @param {Function} func The function to rearrange arguments for.
  26850. * @param {...(number|number[])} indexes The arranged argument indexes.
  26851. * @returns {Function} Returns the new function.
  26852. * @example
  26853. *
  26854. * var rearged = _.rearg(function(a, b, c) {
  26855. * return [a, b, c];
  26856. * }, [2, 0, 1]);
  26857. *
  26858. * rearged('b', 'c', 'a')
  26859. * // => ['a', 'b', 'c']
  26860. */
  26861. var rearg = flatRest(function(func, indexes) {
  26862. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26863. });
  26864. /**
  26865. * Creates a function that invokes `func` with the `this` binding of the
  26866. * created function and arguments from `start` and beyond provided as
  26867. * an array.
  26868. *
  26869. * **Note:** This method is based on the
  26870. * [rest parameter](https://mdn.io/rest_parameters).
  26871. *
  26872. * @static
  26873. * @memberOf _
  26874. * @since 4.0.0
  26875. * @category Function
  26876. * @param {Function} func The function to apply a rest parameter to.
  26877. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26878. * @returns {Function} Returns the new function.
  26879. * @example
  26880. *
  26881. * var say = _.rest(function(what, names) {
  26882. * return what + ' ' + _.initial(names).join(', ') +
  26883. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26884. * });
  26885. *
  26886. * say('hello', 'fred', 'barney', 'pebbles');
  26887. * // => 'hello fred, barney, & pebbles'
  26888. */
  26889. function rest(func, start) {
  26890. if (typeof func != 'function') {
  26891. throw new TypeError(FUNC_ERROR_TEXT);
  26892. }
  26893. start = start === undefined ? start : toInteger(start);
  26894. return baseRest(func, start);
  26895. }
  26896. /**
  26897. * Creates a function that invokes `func` with the `this` binding of the
  26898. * create function and an array of arguments much like
  26899. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26900. *
  26901. * **Note:** This method is based on the
  26902. * [spread operator](https://mdn.io/spread_operator).
  26903. *
  26904. * @static
  26905. * @memberOf _
  26906. * @since 3.2.0
  26907. * @category Function
  26908. * @param {Function} func The function to spread arguments over.
  26909. * @param {number} [start=0] The start position of the spread.
  26910. * @returns {Function} Returns the new function.
  26911. * @example
  26912. *
  26913. * var say = _.spread(function(who, what) {
  26914. * return who + ' says ' + what;
  26915. * });
  26916. *
  26917. * say(['fred', 'hello']);
  26918. * // => 'fred says hello'
  26919. *
  26920. * var numbers = Promise.all([
  26921. * Promise.resolve(40),
  26922. * Promise.resolve(36)
  26923. * ]);
  26924. *
  26925. * numbers.then(_.spread(function(x, y) {
  26926. * return x + y;
  26927. * }));
  26928. * // => a Promise of 76
  26929. */
  26930. function spread(func, start) {
  26931. if (typeof func != 'function') {
  26932. throw new TypeError(FUNC_ERROR_TEXT);
  26933. }
  26934. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26935. return baseRest(function(args) {
  26936. var array = args[start],
  26937. otherArgs = castSlice(args, 0, start);
  26938. if (array) {
  26939. arrayPush(otherArgs, array);
  26940. }
  26941. return apply(func, this, otherArgs);
  26942. });
  26943. }
  26944. /**
  26945. * Creates a throttled function that only invokes `func` at most once per
  26946. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26947. * method to cancel delayed `func` invocations and a `flush` method to
  26948. * immediately invoke them. Provide `options` to indicate whether `func`
  26949. * should be invoked on the leading and/or trailing edge of the `wait`
  26950. * timeout. The `func` is invoked with the last arguments provided to the
  26951. * throttled function. Subsequent calls to the throttled function return the
  26952. * result of the last `func` invocation.
  26953. *
  26954. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26955. * invoked on the trailing edge of the timeout only if the throttled function
  26956. * is invoked more than once during the `wait` timeout.
  26957. *
  26958. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26959. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26960. *
  26961. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26962. * for details over the differences between `_.throttle` and `_.debounce`.
  26963. *
  26964. * @static
  26965. * @memberOf _
  26966. * @since 0.1.0
  26967. * @category Function
  26968. * @param {Function} func The function to throttle.
  26969. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  26970. * @param {Object} [options={}] The options object.
  26971. * @param {boolean} [options.leading=true]
  26972. * Specify invoking on the leading edge of the timeout.
  26973. * @param {boolean} [options.trailing=true]
  26974. * Specify invoking on the trailing edge of the timeout.
  26975. * @returns {Function} Returns the new throttled function.
  26976. * @example
  26977. *
  26978. * // Avoid excessively updating the position while scrolling.
  26979. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  26980. *
  26981. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  26982. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  26983. * jQuery(element).on('click', throttled);
  26984. *
  26985. * // Cancel the trailing throttled invocation.
  26986. * jQuery(window).on('popstate', throttled.cancel);
  26987. */
  26988. function throttle(func, wait, options) {
  26989. var leading = true,
  26990. trailing = true;
  26991. if (typeof func != 'function') {
  26992. throw new TypeError(FUNC_ERROR_TEXT);
  26993. }
  26994. if (isObject(options)) {
  26995. leading = 'leading' in options ? !!options.leading : leading;
  26996. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26997. }
  26998. return debounce(func, wait, {
  26999. 'leading': leading,
  27000. 'maxWait': wait,
  27001. 'trailing': trailing
  27002. });
  27003. }
  27004. /**
  27005. * Creates a function that accepts up to one argument, ignoring any
  27006. * additional arguments.
  27007. *
  27008. * @static
  27009. * @memberOf _
  27010. * @since 4.0.0
  27011. * @category Function
  27012. * @param {Function} func The function to cap arguments for.
  27013. * @returns {Function} Returns the new capped function.
  27014. * @example
  27015. *
  27016. * _.map(['6', '8', '10'], _.unary(parseInt));
  27017. * // => [6, 8, 10]
  27018. */
  27019. function unary(func) {
  27020. return ary(func, 1);
  27021. }
  27022. /**
  27023. * Creates a function that provides `value` to `wrapper` as its first
  27024. * argument. Any additional arguments provided to the function are appended
  27025. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27026. * binding of the created function.
  27027. *
  27028. * @static
  27029. * @memberOf _
  27030. * @since 0.1.0
  27031. * @category Function
  27032. * @param {*} value The value to wrap.
  27033. * @param {Function} [wrapper=identity] The wrapper function.
  27034. * @returns {Function} Returns the new function.
  27035. * @example
  27036. *
  27037. * var p = _.wrap(_.escape, function(func, text) {
  27038. * return '<p>' + func(text) + '</p>';
  27039. * });
  27040. *
  27041. * p('fred, barney, & pebbles');
  27042. * // => '<p>fred, barney, &amp; pebbles</p>'
  27043. */
  27044. function wrap(value, wrapper) {
  27045. return partial(castFunction(wrapper), value);
  27046. }
  27047. /*------------------------------------------------------------------------*/
  27048. /**
  27049. * Casts `value` as an array if it's not one.
  27050. *
  27051. * @static
  27052. * @memberOf _
  27053. * @since 4.4.0
  27054. * @category Lang
  27055. * @param {*} value The value to inspect.
  27056. * @returns {Array} Returns the cast array.
  27057. * @example
  27058. *
  27059. * _.castArray(1);
  27060. * // => [1]
  27061. *
  27062. * _.castArray({ 'a': 1 });
  27063. * // => [{ 'a': 1 }]
  27064. *
  27065. * _.castArray('abc');
  27066. * // => ['abc']
  27067. *
  27068. * _.castArray(null);
  27069. * // => [null]
  27070. *
  27071. * _.castArray(undefined);
  27072. * // => [undefined]
  27073. *
  27074. * _.castArray();
  27075. * // => []
  27076. *
  27077. * var array = [1, 2, 3];
  27078. * console.log(_.castArray(array) === array);
  27079. * // => true
  27080. */
  27081. function castArray() {
  27082. if (!arguments.length) {
  27083. return [];
  27084. }
  27085. var value = arguments[0];
  27086. return isArray(value) ? value : [value];
  27087. }
  27088. /**
  27089. * Creates a shallow clone of `value`.
  27090. *
  27091. * **Note:** This method is loosely based on the
  27092. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27093. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27094. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27095. * arrays. The own enumerable properties of `arguments` objects are cloned
  27096. * as plain objects. An empty object is returned for uncloneable values such
  27097. * as error objects, functions, DOM nodes, and WeakMaps.
  27098. *
  27099. * @static
  27100. * @memberOf _
  27101. * @since 0.1.0
  27102. * @category Lang
  27103. * @param {*} value The value to clone.
  27104. * @returns {*} Returns the cloned value.
  27105. * @see _.cloneDeep
  27106. * @example
  27107. *
  27108. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27109. *
  27110. * var shallow = _.clone(objects);
  27111. * console.log(shallow[0] === objects[0]);
  27112. * // => true
  27113. */
  27114. function clone(value) {
  27115. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27116. }
  27117. /**
  27118. * This method is like `_.clone` except that it accepts `customizer` which
  27119. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27120. * cloning is handled by the method instead. The `customizer` is invoked with
  27121. * up to four arguments; (value [, index|key, object, stack]).
  27122. *
  27123. * @static
  27124. * @memberOf _
  27125. * @since 4.0.0
  27126. * @category Lang
  27127. * @param {*} value The value to clone.
  27128. * @param {Function} [customizer] The function to customize cloning.
  27129. * @returns {*} Returns the cloned value.
  27130. * @see _.cloneDeepWith
  27131. * @example
  27132. *
  27133. * function customizer(value) {
  27134. * if (_.isElement(value)) {
  27135. * return value.cloneNode(false);
  27136. * }
  27137. * }
  27138. *
  27139. * var el = _.cloneWith(document.body, customizer);
  27140. *
  27141. * console.log(el === document.body);
  27142. * // => false
  27143. * console.log(el.nodeName);
  27144. * // => 'BODY'
  27145. * console.log(el.childNodes.length);
  27146. * // => 0
  27147. */
  27148. function cloneWith(value, customizer) {
  27149. customizer = typeof customizer == 'function' ? customizer : undefined;
  27150. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27151. }
  27152. /**
  27153. * This method is like `_.clone` except that it recursively clones `value`.
  27154. *
  27155. * @static
  27156. * @memberOf _
  27157. * @since 1.0.0
  27158. * @category Lang
  27159. * @param {*} value The value to recursively clone.
  27160. * @returns {*} Returns the deep cloned value.
  27161. * @see _.clone
  27162. * @example
  27163. *
  27164. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27165. *
  27166. * var deep = _.cloneDeep(objects);
  27167. * console.log(deep[0] === objects[0]);
  27168. * // => false
  27169. */
  27170. function cloneDeep(value) {
  27171. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27172. }
  27173. /**
  27174. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27175. *
  27176. * @static
  27177. * @memberOf _
  27178. * @since 4.0.0
  27179. * @category Lang
  27180. * @param {*} value The value to recursively clone.
  27181. * @param {Function} [customizer] The function to customize cloning.
  27182. * @returns {*} Returns the deep cloned value.
  27183. * @see _.cloneWith
  27184. * @example
  27185. *
  27186. * function customizer(value) {
  27187. * if (_.isElement(value)) {
  27188. * return value.cloneNode(true);
  27189. * }
  27190. * }
  27191. *
  27192. * var el = _.cloneDeepWith(document.body, customizer);
  27193. *
  27194. * console.log(el === document.body);
  27195. * // => false
  27196. * console.log(el.nodeName);
  27197. * // => 'BODY'
  27198. * console.log(el.childNodes.length);
  27199. * // => 20
  27200. */
  27201. function cloneDeepWith(value, customizer) {
  27202. customizer = typeof customizer == 'function' ? customizer : undefined;
  27203. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27204. }
  27205. /**
  27206. * Checks if `object` conforms to `source` by invoking the predicate
  27207. * properties of `source` with the corresponding property values of `object`.
  27208. *
  27209. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27210. * partially applied.
  27211. *
  27212. * @static
  27213. * @memberOf _
  27214. * @since 4.14.0
  27215. * @category Lang
  27216. * @param {Object} object The object to inspect.
  27217. * @param {Object} source The object of property predicates to conform to.
  27218. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27219. * @example
  27220. *
  27221. * var object = { 'a': 1, 'b': 2 };
  27222. *
  27223. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27224. * // => true
  27225. *
  27226. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27227. * // => false
  27228. */
  27229. function conformsTo(object, source) {
  27230. return source == null || baseConformsTo(object, source, keys(source));
  27231. }
  27232. /**
  27233. * Performs a
  27234. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27235. * comparison between two values to determine if they are equivalent.
  27236. *
  27237. * @static
  27238. * @memberOf _
  27239. * @since 4.0.0
  27240. * @category Lang
  27241. * @param {*} value The value to compare.
  27242. * @param {*} other The other value to compare.
  27243. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27244. * @example
  27245. *
  27246. * var object = { 'a': 1 };
  27247. * var other = { 'a': 1 };
  27248. *
  27249. * _.eq(object, object);
  27250. * // => true
  27251. *
  27252. * _.eq(object, other);
  27253. * // => false
  27254. *
  27255. * _.eq('a', 'a');
  27256. * // => true
  27257. *
  27258. * _.eq('a', Object('a'));
  27259. * // => false
  27260. *
  27261. * _.eq(NaN, NaN);
  27262. * // => true
  27263. */
  27264. function eq(value, other) {
  27265. return value === other || (value !== value && other !== other);
  27266. }
  27267. /**
  27268. * Checks if `value` is greater than `other`.
  27269. *
  27270. * @static
  27271. * @memberOf _
  27272. * @since 3.9.0
  27273. * @category Lang
  27274. * @param {*} value The value to compare.
  27275. * @param {*} other The other value to compare.
  27276. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27277. * else `false`.
  27278. * @see _.lt
  27279. * @example
  27280. *
  27281. * _.gt(3, 1);
  27282. * // => true
  27283. *
  27284. * _.gt(3, 3);
  27285. * // => false
  27286. *
  27287. * _.gt(1, 3);
  27288. * // => false
  27289. */
  27290. var gt = createRelationalOperation(baseGt);
  27291. /**
  27292. * Checks if `value` is greater than or equal to `other`.
  27293. *
  27294. * @static
  27295. * @memberOf _
  27296. * @since 3.9.0
  27297. * @category Lang
  27298. * @param {*} value The value to compare.
  27299. * @param {*} other The other value to compare.
  27300. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27301. * `other`, else `false`.
  27302. * @see _.lte
  27303. * @example
  27304. *
  27305. * _.gte(3, 1);
  27306. * // => true
  27307. *
  27308. * _.gte(3, 3);
  27309. * // => true
  27310. *
  27311. * _.gte(1, 3);
  27312. * // => false
  27313. */
  27314. var gte = createRelationalOperation(function(value, other) {
  27315. return value >= other;
  27316. });
  27317. /**
  27318. * Checks if `value` is likely an `arguments` object.
  27319. *
  27320. * @static
  27321. * @memberOf _
  27322. * @since 0.1.0
  27323. * @category Lang
  27324. * @param {*} value The value to check.
  27325. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27326. * else `false`.
  27327. * @example
  27328. *
  27329. * _.isArguments(function() { return arguments; }());
  27330. * // => true
  27331. *
  27332. * _.isArguments([1, 2, 3]);
  27333. * // => false
  27334. */
  27335. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27336. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27337. !propertyIsEnumerable.call(value, 'callee');
  27338. };
  27339. /**
  27340. * Checks if `value` is classified as an `Array` object.
  27341. *
  27342. * @static
  27343. * @memberOf _
  27344. * @since 0.1.0
  27345. * @category Lang
  27346. * @param {*} value The value to check.
  27347. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27348. * @example
  27349. *
  27350. * _.isArray([1, 2, 3]);
  27351. * // => true
  27352. *
  27353. * _.isArray(document.body.children);
  27354. * // => false
  27355. *
  27356. * _.isArray('abc');
  27357. * // => false
  27358. *
  27359. * _.isArray(_.noop);
  27360. * // => false
  27361. */
  27362. var isArray = Array.isArray;
  27363. /**
  27364. * Checks if `value` is classified as an `ArrayBuffer` object.
  27365. *
  27366. * @static
  27367. * @memberOf _
  27368. * @since 4.3.0
  27369. * @category Lang
  27370. * @param {*} value The value to check.
  27371. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27372. * @example
  27373. *
  27374. * _.isArrayBuffer(new ArrayBuffer(2));
  27375. * // => true
  27376. *
  27377. * _.isArrayBuffer(new Array(2));
  27378. * // => false
  27379. */
  27380. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27381. /**
  27382. * Checks if `value` is array-like. A value is considered array-like if it's
  27383. * not a function and has a `value.length` that's an integer greater than or
  27384. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27385. *
  27386. * @static
  27387. * @memberOf _
  27388. * @since 4.0.0
  27389. * @category Lang
  27390. * @param {*} value The value to check.
  27391. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27392. * @example
  27393. *
  27394. * _.isArrayLike([1, 2, 3]);
  27395. * // => true
  27396. *
  27397. * _.isArrayLike(document.body.children);
  27398. * // => true
  27399. *
  27400. * _.isArrayLike('abc');
  27401. * // => true
  27402. *
  27403. * _.isArrayLike(_.noop);
  27404. * // => false
  27405. */
  27406. function isArrayLike(value) {
  27407. return value != null && isLength(value.length) && !isFunction(value);
  27408. }
  27409. /**
  27410. * This method is like `_.isArrayLike` except that it also checks if `value`
  27411. * is an object.
  27412. *
  27413. * @static
  27414. * @memberOf _
  27415. * @since 4.0.0
  27416. * @category Lang
  27417. * @param {*} value The value to check.
  27418. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27419. * else `false`.
  27420. * @example
  27421. *
  27422. * _.isArrayLikeObject([1, 2, 3]);
  27423. * // => true
  27424. *
  27425. * _.isArrayLikeObject(document.body.children);
  27426. * // => true
  27427. *
  27428. * _.isArrayLikeObject('abc');
  27429. * // => false
  27430. *
  27431. * _.isArrayLikeObject(_.noop);
  27432. * // => false
  27433. */
  27434. function isArrayLikeObject(value) {
  27435. return isObjectLike(value) && isArrayLike(value);
  27436. }
  27437. /**
  27438. * Checks if `value` is classified as a boolean primitive or object.
  27439. *
  27440. * @static
  27441. * @memberOf _
  27442. * @since 0.1.0
  27443. * @category Lang
  27444. * @param {*} value The value to check.
  27445. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27446. * @example
  27447. *
  27448. * _.isBoolean(false);
  27449. * // => true
  27450. *
  27451. * _.isBoolean(null);
  27452. * // => false
  27453. */
  27454. function isBoolean(value) {
  27455. return value === true || value === false ||
  27456. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27457. }
  27458. /**
  27459. * Checks if `value` is a buffer.
  27460. *
  27461. * @static
  27462. * @memberOf _
  27463. * @since 4.3.0
  27464. * @category Lang
  27465. * @param {*} value The value to check.
  27466. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27467. * @example
  27468. *
  27469. * _.isBuffer(new Buffer(2));
  27470. * // => true
  27471. *
  27472. * _.isBuffer(new Uint8Array(2));
  27473. * // => false
  27474. */
  27475. var isBuffer = nativeIsBuffer || stubFalse;
  27476. /**
  27477. * Checks if `value` is classified as a `Date` object.
  27478. *
  27479. * @static
  27480. * @memberOf _
  27481. * @since 0.1.0
  27482. * @category Lang
  27483. * @param {*} value The value to check.
  27484. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27485. * @example
  27486. *
  27487. * _.isDate(new Date);
  27488. * // => true
  27489. *
  27490. * _.isDate('Mon April 23 2012');
  27491. * // => false
  27492. */
  27493. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27494. /**
  27495. * Checks if `value` is likely a DOM element.
  27496. *
  27497. * @static
  27498. * @memberOf _
  27499. * @since 0.1.0
  27500. * @category Lang
  27501. * @param {*} value The value to check.
  27502. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27503. * @example
  27504. *
  27505. * _.isElement(document.body);
  27506. * // => true
  27507. *
  27508. * _.isElement('<body>');
  27509. * // => false
  27510. */
  27511. function isElement(value) {
  27512. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27513. }
  27514. /**
  27515. * Checks if `value` is an empty object, collection, map, or set.
  27516. *
  27517. * Objects are considered empty if they have no own enumerable string keyed
  27518. * properties.
  27519. *
  27520. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27521. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27522. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27523. *
  27524. * @static
  27525. * @memberOf _
  27526. * @since 0.1.0
  27527. * @category Lang
  27528. * @param {*} value The value to check.
  27529. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27530. * @example
  27531. *
  27532. * _.isEmpty(null);
  27533. * // => true
  27534. *
  27535. * _.isEmpty(true);
  27536. * // => true
  27537. *
  27538. * _.isEmpty(1);
  27539. * // => true
  27540. *
  27541. * _.isEmpty([1, 2, 3]);
  27542. * // => false
  27543. *
  27544. * _.isEmpty({ 'a': 1 });
  27545. * // => false
  27546. */
  27547. function isEmpty(value) {
  27548. if (value == null) {
  27549. return true;
  27550. }
  27551. if (isArrayLike(value) &&
  27552. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27553. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27554. return !value.length;
  27555. }
  27556. var tag = getTag(value);
  27557. if (tag == mapTag || tag == setTag) {
  27558. return !value.size;
  27559. }
  27560. if (isPrototype(value)) {
  27561. return !baseKeys(value).length;
  27562. }
  27563. for (var key in value) {
  27564. if (hasOwnProperty.call(value, key)) {
  27565. return false;
  27566. }
  27567. }
  27568. return true;
  27569. }
  27570. /**
  27571. * Performs a deep comparison between two values to determine if they are
  27572. * equivalent.
  27573. *
  27574. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27575. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27576. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27577. * by their own, not inherited, enumerable properties. Functions and DOM
  27578. * nodes are compared by strict equality, i.e. `===`.
  27579. *
  27580. * @static
  27581. * @memberOf _
  27582. * @since 0.1.0
  27583. * @category Lang
  27584. * @param {*} value The value to compare.
  27585. * @param {*} other The other value to compare.
  27586. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27587. * @example
  27588. *
  27589. * var object = { 'a': 1 };
  27590. * var other = { 'a': 1 };
  27591. *
  27592. * _.isEqual(object, other);
  27593. * // => true
  27594. *
  27595. * object === other;
  27596. * // => false
  27597. */
  27598. function isEqual(value, other) {
  27599. return baseIsEqual(value, other);
  27600. }
  27601. /**
  27602. * This method is like `_.isEqual` except that it accepts `customizer` which
  27603. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27604. * are handled by the method instead. The `customizer` is invoked with up to
  27605. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27606. *
  27607. * @static
  27608. * @memberOf _
  27609. * @since 4.0.0
  27610. * @category Lang
  27611. * @param {*} value The value to compare.
  27612. * @param {*} other The other value to compare.
  27613. * @param {Function} [customizer] The function to customize comparisons.
  27614. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27615. * @example
  27616. *
  27617. * function isGreeting(value) {
  27618. * return /^h(?:i|ello)$/.test(value);
  27619. * }
  27620. *
  27621. * function customizer(objValue, othValue) {
  27622. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27623. * return true;
  27624. * }
  27625. * }
  27626. *
  27627. * var array = ['hello', 'goodbye'];
  27628. * var other = ['hi', 'goodbye'];
  27629. *
  27630. * _.isEqualWith(array, other, customizer);
  27631. * // => true
  27632. */
  27633. function isEqualWith(value, other, customizer) {
  27634. customizer = typeof customizer == 'function' ? customizer : undefined;
  27635. var result = customizer ? customizer(value, other) : undefined;
  27636. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27637. }
  27638. /**
  27639. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27640. * `SyntaxError`, `TypeError`, or `URIError` object.
  27641. *
  27642. * @static
  27643. * @memberOf _
  27644. * @since 3.0.0
  27645. * @category Lang
  27646. * @param {*} value The value to check.
  27647. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27648. * @example
  27649. *
  27650. * _.isError(new Error);
  27651. * // => true
  27652. *
  27653. * _.isError(Error);
  27654. * // => false
  27655. */
  27656. function isError(value) {
  27657. if (!isObjectLike(value)) {
  27658. return false;
  27659. }
  27660. var tag = baseGetTag(value);
  27661. return tag == errorTag || tag == domExcTag ||
  27662. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27663. }
  27664. /**
  27665. * Checks if `value` is a finite primitive number.
  27666. *
  27667. * **Note:** This method is based on
  27668. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27669. *
  27670. * @static
  27671. * @memberOf _
  27672. * @since 0.1.0
  27673. * @category Lang
  27674. * @param {*} value The value to check.
  27675. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27676. * @example
  27677. *
  27678. * _.isFinite(3);
  27679. * // => true
  27680. *
  27681. * _.isFinite(Number.MIN_VALUE);
  27682. * // => true
  27683. *
  27684. * _.isFinite(Infinity);
  27685. * // => false
  27686. *
  27687. * _.isFinite('3');
  27688. * // => false
  27689. */
  27690. function isFinite(value) {
  27691. return typeof value == 'number' && nativeIsFinite(value);
  27692. }
  27693. /**
  27694. * Checks if `value` is classified as a `Function` object.
  27695. *
  27696. * @static
  27697. * @memberOf _
  27698. * @since 0.1.0
  27699. * @category Lang
  27700. * @param {*} value The value to check.
  27701. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27702. * @example
  27703. *
  27704. * _.isFunction(_);
  27705. * // => true
  27706. *
  27707. * _.isFunction(/abc/);
  27708. * // => false
  27709. */
  27710. function isFunction(value) {
  27711. if (!isObject(value)) {
  27712. return false;
  27713. }
  27714. // The use of `Object#toString` avoids issues with the `typeof` operator
  27715. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27716. var tag = baseGetTag(value);
  27717. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27718. }
  27719. /**
  27720. * Checks if `value` is an integer.
  27721. *
  27722. * **Note:** This method is based on
  27723. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27724. *
  27725. * @static
  27726. * @memberOf _
  27727. * @since 4.0.0
  27728. * @category Lang
  27729. * @param {*} value The value to check.
  27730. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27731. * @example
  27732. *
  27733. * _.isInteger(3);
  27734. * // => true
  27735. *
  27736. * _.isInteger(Number.MIN_VALUE);
  27737. * // => false
  27738. *
  27739. * _.isInteger(Infinity);
  27740. * // => false
  27741. *
  27742. * _.isInteger('3');
  27743. * // => false
  27744. */
  27745. function isInteger(value) {
  27746. return typeof value == 'number' && value == toInteger(value);
  27747. }
  27748. /**
  27749. * Checks if `value` is a valid array-like length.
  27750. *
  27751. * **Note:** This method is loosely based on
  27752. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27753. *
  27754. * @static
  27755. * @memberOf _
  27756. * @since 4.0.0
  27757. * @category Lang
  27758. * @param {*} value The value to check.
  27759. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27760. * @example
  27761. *
  27762. * _.isLength(3);
  27763. * // => true
  27764. *
  27765. * _.isLength(Number.MIN_VALUE);
  27766. * // => false
  27767. *
  27768. * _.isLength(Infinity);
  27769. * // => false
  27770. *
  27771. * _.isLength('3');
  27772. * // => false
  27773. */
  27774. function isLength(value) {
  27775. return typeof value == 'number' &&
  27776. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27777. }
  27778. /**
  27779. * Checks if `value` is the
  27780. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27781. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27782. *
  27783. * @static
  27784. * @memberOf _
  27785. * @since 0.1.0
  27786. * @category Lang
  27787. * @param {*} value The value to check.
  27788. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27789. * @example
  27790. *
  27791. * _.isObject({});
  27792. * // => true
  27793. *
  27794. * _.isObject([1, 2, 3]);
  27795. * // => true
  27796. *
  27797. * _.isObject(_.noop);
  27798. * // => true
  27799. *
  27800. * _.isObject(null);
  27801. * // => false
  27802. */
  27803. function isObject(value) {
  27804. var type = typeof value;
  27805. return value != null && (type == 'object' || type == 'function');
  27806. }
  27807. /**
  27808. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27809. * and has a `typeof` result of "object".
  27810. *
  27811. * @static
  27812. * @memberOf _
  27813. * @since 4.0.0
  27814. * @category Lang
  27815. * @param {*} value The value to check.
  27816. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27817. * @example
  27818. *
  27819. * _.isObjectLike({});
  27820. * // => true
  27821. *
  27822. * _.isObjectLike([1, 2, 3]);
  27823. * // => true
  27824. *
  27825. * _.isObjectLike(_.noop);
  27826. * // => false
  27827. *
  27828. * _.isObjectLike(null);
  27829. * // => false
  27830. */
  27831. function isObjectLike(value) {
  27832. return value != null && typeof value == 'object';
  27833. }
  27834. /**
  27835. * Checks if `value` is classified as a `Map` object.
  27836. *
  27837. * @static
  27838. * @memberOf _
  27839. * @since 4.3.0
  27840. * @category Lang
  27841. * @param {*} value The value to check.
  27842. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27843. * @example
  27844. *
  27845. * _.isMap(new Map);
  27846. * // => true
  27847. *
  27848. * _.isMap(new WeakMap);
  27849. * // => false
  27850. */
  27851. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27852. /**
  27853. * Performs a partial deep comparison between `object` and `source` to
  27854. * determine if `object` contains equivalent property values.
  27855. *
  27856. * **Note:** This method is equivalent to `_.matches` when `source` is
  27857. * partially applied.
  27858. *
  27859. * Partial comparisons will match empty array and empty object `source`
  27860. * values against any array or object value, respectively. See `_.isEqual`
  27861. * for a list of supported value comparisons.
  27862. *
  27863. * @static
  27864. * @memberOf _
  27865. * @since 3.0.0
  27866. * @category Lang
  27867. * @param {Object} object The object to inspect.
  27868. * @param {Object} source The object of property values to match.
  27869. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27870. * @example
  27871. *
  27872. * var object = { 'a': 1, 'b': 2 };
  27873. *
  27874. * _.isMatch(object, { 'b': 2 });
  27875. * // => true
  27876. *
  27877. * _.isMatch(object, { 'b': 1 });
  27878. * // => false
  27879. */
  27880. function isMatch(object, source) {
  27881. return object === source || baseIsMatch(object, source, getMatchData(source));
  27882. }
  27883. /**
  27884. * This method is like `_.isMatch` except that it accepts `customizer` which
  27885. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27886. * are handled by the method instead. The `customizer` is invoked with five
  27887. * arguments: (objValue, srcValue, index|key, object, source).
  27888. *
  27889. * @static
  27890. * @memberOf _
  27891. * @since 4.0.0
  27892. * @category Lang
  27893. * @param {Object} object The object to inspect.
  27894. * @param {Object} source The object of property values to match.
  27895. * @param {Function} [customizer] The function to customize comparisons.
  27896. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27897. * @example
  27898. *
  27899. * function isGreeting(value) {
  27900. * return /^h(?:i|ello)$/.test(value);
  27901. * }
  27902. *
  27903. * function customizer(objValue, srcValue) {
  27904. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27905. * return true;
  27906. * }
  27907. * }
  27908. *
  27909. * var object = { 'greeting': 'hello' };
  27910. * var source = { 'greeting': 'hi' };
  27911. *
  27912. * _.isMatchWith(object, source, customizer);
  27913. * // => true
  27914. */
  27915. function isMatchWith(object, source, customizer) {
  27916. customizer = typeof customizer == 'function' ? customizer : undefined;
  27917. return baseIsMatch(object, source, getMatchData(source), customizer);
  27918. }
  27919. /**
  27920. * Checks if `value` is `NaN`.
  27921. *
  27922. * **Note:** This method is based on
  27923. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27924. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27925. * `undefined` and other non-number values.
  27926. *
  27927. * @static
  27928. * @memberOf _
  27929. * @since 0.1.0
  27930. * @category Lang
  27931. * @param {*} value The value to check.
  27932. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27933. * @example
  27934. *
  27935. * _.isNaN(NaN);
  27936. * // => true
  27937. *
  27938. * _.isNaN(new Number(NaN));
  27939. * // => true
  27940. *
  27941. * isNaN(undefined);
  27942. * // => true
  27943. *
  27944. * _.isNaN(undefined);
  27945. * // => false
  27946. */
  27947. function isNaN(value) {
  27948. // An `NaN` primitive is the only value that is not equal to itself.
  27949. // Perform the `toStringTag` check first to avoid errors with some
  27950. // ActiveX objects in IE.
  27951. return isNumber(value) && value != +value;
  27952. }
  27953. /**
  27954. * Checks if `value` is a pristine native function.
  27955. *
  27956. * **Note:** This method can't reliably detect native functions in the presence
  27957. * of the core-js package because core-js circumvents this kind of detection.
  27958. * Despite multiple requests, the core-js maintainer has made it clear: any
  27959. * attempt to fix the detection will be obstructed. As a result, we're left
  27960. * with little choice but to throw an error. Unfortunately, this also affects
  27961. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27962. * which rely on core-js.
  27963. *
  27964. * @static
  27965. * @memberOf _
  27966. * @since 3.0.0
  27967. * @category Lang
  27968. * @param {*} value The value to check.
  27969. * @returns {boolean} Returns `true` if `value` is a native function,
  27970. * else `false`.
  27971. * @example
  27972. *
  27973. * _.isNative(Array.prototype.push);
  27974. * // => true
  27975. *
  27976. * _.isNative(_);
  27977. * // => false
  27978. */
  27979. function isNative(value) {
  27980. if (isMaskable(value)) {
  27981. throw new Error(CORE_ERROR_TEXT);
  27982. }
  27983. return baseIsNative(value);
  27984. }
  27985. /**
  27986. * Checks if `value` is `null`.
  27987. *
  27988. * @static
  27989. * @memberOf _
  27990. * @since 0.1.0
  27991. * @category Lang
  27992. * @param {*} value The value to check.
  27993. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  27994. * @example
  27995. *
  27996. * _.isNull(null);
  27997. * // => true
  27998. *
  27999. * _.isNull(void 0);
  28000. * // => false
  28001. */
  28002. function isNull(value) {
  28003. return value === null;
  28004. }
  28005. /**
  28006. * Checks if `value` is `null` or `undefined`.
  28007. *
  28008. * @static
  28009. * @memberOf _
  28010. * @since 4.0.0
  28011. * @category Lang
  28012. * @param {*} value The value to check.
  28013. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28014. * @example
  28015. *
  28016. * _.isNil(null);
  28017. * // => true
  28018. *
  28019. * _.isNil(void 0);
  28020. * // => true
  28021. *
  28022. * _.isNil(NaN);
  28023. * // => false
  28024. */
  28025. function isNil(value) {
  28026. return value == null;
  28027. }
  28028. /**
  28029. * Checks if `value` is classified as a `Number` primitive or object.
  28030. *
  28031. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28032. * classified as numbers, use the `_.isFinite` method.
  28033. *
  28034. * @static
  28035. * @memberOf _
  28036. * @since 0.1.0
  28037. * @category Lang
  28038. * @param {*} value The value to check.
  28039. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28040. * @example
  28041. *
  28042. * _.isNumber(3);
  28043. * // => true
  28044. *
  28045. * _.isNumber(Number.MIN_VALUE);
  28046. * // => true
  28047. *
  28048. * _.isNumber(Infinity);
  28049. * // => true
  28050. *
  28051. * _.isNumber('3');
  28052. * // => false
  28053. */
  28054. function isNumber(value) {
  28055. return typeof value == 'number' ||
  28056. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28057. }
  28058. /**
  28059. * Checks if `value` is a plain object, that is, an object created by the
  28060. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28061. *
  28062. * @static
  28063. * @memberOf _
  28064. * @since 0.8.0
  28065. * @category Lang
  28066. * @param {*} value The value to check.
  28067. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28068. * @example
  28069. *
  28070. * function Foo() {
  28071. * this.a = 1;
  28072. * }
  28073. *
  28074. * _.isPlainObject(new Foo);
  28075. * // => false
  28076. *
  28077. * _.isPlainObject([1, 2, 3]);
  28078. * // => false
  28079. *
  28080. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28081. * // => true
  28082. *
  28083. * _.isPlainObject(Object.create(null));
  28084. * // => true
  28085. */
  28086. function isPlainObject(value) {
  28087. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28088. return false;
  28089. }
  28090. var proto = getPrototype(value);
  28091. if (proto === null) {
  28092. return true;
  28093. }
  28094. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28095. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28096. funcToString.call(Ctor) == objectCtorString;
  28097. }
  28098. /**
  28099. * Checks if `value` is classified as a `RegExp` object.
  28100. *
  28101. * @static
  28102. * @memberOf _
  28103. * @since 0.1.0
  28104. * @category Lang
  28105. * @param {*} value The value to check.
  28106. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28107. * @example
  28108. *
  28109. * _.isRegExp(/abc/);
  28110. * // => true
  28111. *
  28112. * _.isRegExp('/abc/');
  28113. * // => false
  28114. */
  28115. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28116. /**
  28117. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28118. * double precision number which isn't the result of a rounded unsafe integer.
  28119. *
  28120. * **Note:** This method is based on
  28121. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28122. *
  28123. * @static
  28124. * @memberOf _
  28125. * @since 4.0.0
  28126. * @category Lang
  28127. * @param {*} value The value to check.
  28128. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28129. * @example
  28130. *
  28131. * _.isSafeInteger(3);
  28132. * // => true
  28133. *
  28134. * _.isSafeInteger(Number.MIN_VALUE);
  28135. * // => false
  28136. *
  28137. * _.isSafeInteger(Infinity);
  28138. * // => false
  28139. *
  28140. * _.isSafeInteger('3');
  28141. * // => false
  28142. */
  28143. function isSafeInteger(value) {
  28144. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28145. }
  28146. /**
  28147. * Checks if `value` is classified as a `Set` object.
  28148. *
  28149. * @static
  28150. * @memberOf _
  28151. * @since 4.3.0
  28152. * @category Lang
  28153. * @param {*} value The value to check.
  28154. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28155. * @example
  28156. *
  28157. * _.isSet(new Set);
  28158. * // => true
  28159. *
  28160. * _.isSet(new WeakSet);
  28161. * // => false
  28162. */
  28163. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28164. /**
  28165. * Checks if `value` is classified as a `String` primitive or object.
  28166. *
  28167. * @static
  28168. * @since 0.1.0
  28169. * @memberOf _
  28170. * @category Lang
  28171. * @param {*} value The value to check.
  28172. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28173. * @example
  28174. *
  28175. * _.isString('abc');
  28176. * // => true
  28177. *
  28178. * _.isString(1);
  28179. * // => false
  28180. */
  28181. function isString(value) {
  28182. return typeof value == 'string' ||
  28183. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28184. }
  28185. /**
  28186. * Checks if `value` is classified as a `Symbol` primitive or object.
  28187. *
  28188. * @static
  28189. * @memberOf _
  28190. * @since 4.0.0
  28191. * @category Lang
  28192. * @param {*} value The value to check.
  28193. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28194. * @example
  28195. *
  28196. * _.isSymbol(Symbol.iterator);
  28197. * // => true
  28198. *
  28199. * _.isSymbol('abc');
  28200. * // => false
  28201. */
  28202. function isSymbol(value) {
  28203. return typeof value == 'symbol' ||
  28204. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28205. }
  28206. /**
  28207. * Checks if `value` is classified as a typed array.
  28208. *
  28209. * @static
  28210. * @memberOf _
  28211. * @since 3.0.0
  28212. * @category Lang
  28213. * @param {*} value The value to check.
  28214. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28215. * @example
  28216. *
  28217. * _.isTypedArray(new Uint8Array);
  28218. * // => true
  28219. *
  28220. * _.isTypedArray([]);
  28221. * // => false
  28222. */
  28223. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28224. /**
  28225. * Checks if `value` is `undefined`.
  28226. *
  28227. * @static
  28228. * @since 0.1.0
  28229. * @memberOf _
  28230. * @category Lang
  28231. * @param {*} value The value to check.
  28232. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28233. * @example
  28234. *
  28235. * _.isUndefined(void 0);
  28236. * // => true
  28237. *
  28238. * _.isUndefined(null);
  28239. * // => false
  28240. */
  28241. function isUndefined(value) {
  28242. return value === undefined;
  28243. }
  28244. /**
  28245. * Checks if `value` is classified as a `WeakMap` object.
  28246. *
  28247. * @static
  28248. * @memberOf _
  28249. * @since 4.3.0
  28250. * @category Lang
  28251. * @param {*} value The value to check.
  28252. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28253. * @example
  28254. *
  28255. * _.isWeakMap(new WeakMap);
  28256. * // => true
  28257. *
  28258. * _.isWeakMap(new Map);
  28259. * // => false
  28260. */
  28261. function isWeakMap(value) {
  28262. return isObjectLike(value) && getTag(value) == weakMapTag;
  28263. }
  28264. /**
  28265. * Checks if `value` is classified as a `WeakSet` object.
  28266. *
  28267. * @static
  28268. * @memberOf _
  28269. * @since 4.3.0
  28270. * @category Lang
  28271. * @param {*} value The value to check.
  28272. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28273. * @example
  28274. *
  28275. * _.isWeakSet(new WeakSet);
  28276. * // => true
  28277. *
  28278. * _.isWeakSet(new Set);
  28279. * // => false
  28280. */
  28281. function isWeakSet(value) {
  28282. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28283. }
  28284. /**
  28285. * Checks if `value` is less than `other`.
  28286. *
  28287. * @static
  28288. * @memberOf _
  28289. * @since 3.9.0
  28290. * @category Lang
  28291. * @param {*} value The value to compare.
  28292. * @param {*} other The other value to compare.
  28293. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28294. * else `false`.
  28295. * @see _.gt
  28296. * @example
  28297. *
  28298. * _.lt(1, 3);
  28299. * // => true
  28300. *
  28301. * _.lt(3, 3);
  28302. * // => false
  28303. *
  28304. * _.lt(3, 1);
  28305. * // => false
  28306. */
  28307. var lt = createRelationalOperation(baseLt);
  28308. /**
  28309. * Checks if `value` is less than or equal to `other`.
  28310. *
  28311. * @static
  28312. * @memberOf _
  28313. * @since 3.9.0
  28314. * @category Lang
  28315. * @param {*} value The value to compare.
  28316. * @param {*} other The other value to compare.
  28317. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28318. * `other`, else `false`.
  28319. * @see _.gte
  28320. * @example
  28321. *
  28322. * _.lte(1, 3);
  28323. * // => true
  28324. *
  28325. * _.lte(3, 3);
  28326. * // => true
  28327. *
  28328. * _.lte(3, 1);
  28329. * // => false
  28330. */
  28331. var lte = createRelationalOperation(function(value, other) {
  28332. return value <= other;
  28333. });
  28334. /**
  28335. * Converts `value` to an array.
  28336. *
  28337. * @static
  28338. * @since 0.1.0
  28339. * @memberOf _
  28340. * @category Lang
  28341. * @param {*} value The value to convert.
  28342. * @returns {Array} Returns the converted array.
  28343. * @example
  28344. *
  28345. * _.toArray({ 'a': 1, 'b': 2 });
  28346. * // => [1, 2]
  28347. *
  28348. * _.toArray('abc');
  28349. * // => ['a', 'b', 'c']
  28350. *
  28351. * _.toArray(1);
  28352. * // => []
  28353. *
  28354. * _.toArray(null);
  28355. * // => []
  28356. */
  28357. function toArray(value) {
  28358. if (!value) {
  28359. return [];
  28360. }
  28361. if (isArrayLike(value)) {
  28362. return isString(value) ? stringToArray(value) : copyArray(value);
  28363. }
  28364. if (symIterator && value[symIterator]) {
  28365. return iteratorToArray(value[symIterator]());
  28366. }
  28367. var tag = getTag(value),
  28368. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28369. return func(value);
  28370. }
  28371. /**
  28372. * Converts `value` to a finite number.
  28373. *
  28374. * @static
  28375. * @memberOf _
  28376. * @since 4.12.0
  28377. * @category Lang
  28378. * @param {*} value The value to convert.
  28379. * @returns {number} Returns the converted number.
  28380. * @example
  28381. *
  28382. * _.toFinite(3.2);
  28383. * // => 3.2
  28384. *
  28385. * _.toFinite(Number.MIN_VALUE);
  28386. * // => 5e-324
  28387. *
  28388. * _.toFinite(Infinity);
  28389. * // => 1.7976931348623157e+308
  28390. *
  28391. * _.toFinite('3.2');
  28392. * // => 3.2
  28393. */
  28394. function toFinite(value) {
  28395. if (!value) {
  28396. return value === 0 ? value : 0;
  28397. }
  28398. value = toNumber(value);
  28399. if (value === INFINITY || value === -INFINITY) {
  28400. var sign = (value < 0 ? -1 : 1);
  28401. return sign * MAX_INTEGER;
  28402. }
  28403. return value === value ? value : 0;
  28404. }
  28405. /**
  28406. * Converts `value` to an integer.
  28407. *
  28408. * **Note:** This method is loosely based on
  28409. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  28410. *
  28411. * @static
  28412. * @memberOf _
  28413. * @since 4.0.0
  28414. * @category Lang
  28415. * @param {*} value The value to convert.
  28416. * @returns {number} Returns the converted integer.
  28417. * @example
  28418. *
  28419. * _.toInteger(3.2);
  28420. * // => 3
  28421. *
  28422. * _.toInteger(Number.MIN_VALUE);
  28423. * // => 0
  28424. *
  28425. * _.toInteger(Infinity);
  28426. * // => 1.7976931348623157e+308
  28427. *
  28428. * _.toInteger('3.2');
  28429. * // => 3
  28430. */
  28431. function toInteger(value) {
  28432. var result = toFinite(value),
  28433. remainder = result % 1;
  28434. return result === result ? (remainder ? result - remainder : result) : 0;
  28435. }
  28436. /**
  28437. * Converts `value` to an integer suitable for use as the length of an
  28438. * array-like object.
  28439. *
  28440. * **Note:** This method is based on
  28441. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28442. *
  28443. * @static
  28444. * @memberOf _
  28445. * @since 4.0.0
  28446. * @category Lang
  28447. * @param {*} value The value to convert.
  28448. * @returns {number} Returns the converted integer.
  28449. * @example
  28450. *
  28451. * _.toLength(3.2);
  28452. * // => 3
  28453. *
  28454. * _.toLength(Number.MIN_VALUE);
  28455. * // => 0
  28456. *
  28457. * _.toLength(Infinity);
  28458. * // => 4294967295
  28459. *
  28460. * _.toLength('3.2');
  28461. * // => 3
  28462. */
  28463. function toLength(value) {
  28464. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28465. }
  28466. /**
  28467. * Converts `value` to a number.
  28468. *
  28469. * @static
  28470. * @memberOf _
  28471. * @since 4.0.0
  28472. * @category Lang
  28473. * @param {*} value The value to process.
  28474. * @returns {number} Returns the number.
  28475. * @example
  28476. *
  28477. * _.toNumber(3.2);
  28478. * // => 3.2
  28479. *
  28480. * _.toNumber(Number.MIN_VALUE);
  28481. * // => 5e-324
  28482. *
  28483. * _.toNumber(Infinity);
  28484. * // => Infinity
  28485. *
  28486. * _.toNumber('3.2');
  28487. * // => 3.2
  28488. */
  28489. function toNumber(value) {
  28490. if (typeof value == 'number') {
  28491. return value;
  28492. }
  28493. if (isSymbol(value)) {
  28494. return NAN;
  28495. }
  28496. if (isObject(value)) {
  28497. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28498. value = isObject(other) ? (other + '') : other;
  28499. }
  28500. if (typeof value != 'string') {
  28501. return value === 0 ? value : +value;
  28502. }
  28503. value = value.replace(reTrim, '');
  28504. var isBinary = reIsBinary.test(value);
  28505. return (isBinary || reIsOctal.test(value))
  28506. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28507. : (reIsBadHex.test(value) ? NAN : +value);
  28508. }
  28509. /**
  28510. * Converts `value` to a plain object flattening inherited enumerable string
  28511. * keyed properties of `value` to own properties of the plain object.
  28512. *
  28513. * @static
  28514. * @memberOf _
  28515. * @since 3.0.0
  28516. * @category Lang
  28517. * @param {*} value The value to convert.
  28518. * @returns {Object} Returns the converted plain object.
  28519. * @example
  28520. *
  28521. * function Foo() {
  28522. * this.b = 2;
  28523. * }
  28524. *
  28525. * Foo.prototype.c = 3;
  28526. *
  28527. * _.assign({ 'a': 1 }, new Foo);
  28528. * // => { 'a': 1, 'b': 2 }
  28529. *
  28530. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28531. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28532. */
  28533. function toPlainObject(value) {
  28534. return copyObject(value, keysIn(value));
  28535. }
  28536. /**
  28537. * Converts `value` to a safe integer. A safe integer can be compared and
  28538. * represented correctly.
  28539. *
  28540. * @static
  28541. * @memberOf _
  28542. * @since 4.0.0
  28543. * @category Lang
  28544. * @param {*} value The value to convert.
  28545. * @returns {number} Returns the converted integer.
  28546. * @example
  28547. *
  28548. * _.toSafeInteger(3.2);
  28549. * // => 3
  28550. *
  28551. * _.toSafeInteger(Number.MIN_VALUE);
  28552. * // => 0
  28553. *
  28554. * _.toSafeInteger(Infinity);
  28555. * // => 9007199254740991
  28556. *
  28557. * _.toSafeInteger('3.2');
  28558. * // => 3
  28559. */
  28560. function toSafeInteger(value) {
  28561. return value
  28562. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28563. : (value === 0 ? value : 0);
  28564. }
  28565. /**
  28566. * Converts `value` to a string. An empty string is returned for `null`
  28567. * and `undefined` values. The sign of `-0` is preserved.
  28568. *
  28569. * @static
  28570. * @memberOf _
  28571. * @since 4.0.0
  28572. * @category Lang
  28573. * @param {*} value The value to convert.
  28574. * @returns {string} Returns the converted string.
  28575. * @example
  28576. *
  28577. * _.toString(null);
  28578. * // => ''
  28579. *
  28580. * _.toString(-0);
  28581. * // => '-0'
  28582. *
  28583. * _.toString([1, 2, 3]);
  28584. * // => '1,2,3'
  28585. */
  28586. function toString(value) {
  28587. return value == null ? '' : baseToString(value);
  28588. }
  28589. /*------------------------------------------------------------------------*/
  28590. /**
  28591. * Assigns own enumerable string keyed properties of source objects to the
  28592. * destination object. Source objects are applied from left to right.
  28593. * Subsequent sources overwrite property assignments of previous sources.
  28594. *
  28595. * **Note:** This method mutates `object` and is loosely based on
  28596. * [`Object.assign`](https://mdn.io/Object/assign).
  28597. *
  28598. * @static
  28599. * @memberOf _
  28600. * @since 0.10.0
  28601. * @category Object
  28602. * @param {Object} object The destination object.
  28603. * @param {...Object} [sources] The source objects.
  28604. * @returns {Object} Returns `object`.
  28605. * @see _.assignIn
  28606. * @example
  28607. *
  28608. * function Foo() {
  28609. * this.a = 1;
  28610. * }
  28611. *
  28612. * function Bar() {
  28613. * this.c = 3;
  28614. * }
  28615. *
  28616. * Foo.prototype.b = 2;
  28617. * Bar.prototype.d = 4;
  28618. *
  28619. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28620. * // => { 'a': 1, 'c': 3 }
  28621. */
  28622. var assign = createAssigner(function(object, source) {
  28623. if (isPrototype(source) || isArrayLike(source)) {
  28624. copyObject(source, keys(source), object);
  28625. return;
  28626. }
  28627. for (var key in source) {
  28628. if (hasOwnProperty.call(source, key)) {
  28629. assignValue(object, key, source[key]);
  28630. }
  28631. }
  28632. });
  28633. /**
  28634. * This method is like `_.assign` except that it iterates over own and
  28635. * inherited source properties.
  28636. *
  28637. * **Note:** This method mutates `object`.
  28638. *
  28639. * @static
  28640. * @memberOf _
  28641. * @since 4.0.0
  28642. * @alias extend
  28643. * @category Object
  28644. * @param {Object} object The destination object.
  28645. * @param {...Object} [sources] The source objects.
  28646. * @returns {Object} Returns `object`.
  28647. * @see _.assign
  28648. * @example
  28649. *
  28650. * function Foo() {
  28651. * this.a = 1;
  28652. * }
  28653. *
  28654. * function Bar() {
  28655. * this.c = 3;
  28656. * }
  28657. *
  28658. * Foo.prototype.b = 2;
  28659. * Bar.prototype.d = 4;
  28660. *
  28661. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28662. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28663. */
  28664. var assignIn = createAssigner(function(object, source) {
  28665. copyObject(source, keysIn(source), object);
  28666. });
  28667. /**
  28668. * This method is like `_.assignIn` except that it accepts `customizer`
  28669. * which is invoked to produce the assigned values. If `customizer` returns
  28670. * `undefined`, assignment is handled by the method instead. The `customizer`
  28671. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28672. *
  28673. * **Note:** This method mutates `object`.
  28674. *
  28675. * @static
  28676. * @memberOf _
  28677. * @since 4.0.0
  28678. * @alias extendWith
  28679. * @category Object
  28680. * @param {Object} object The destination object.
  28681. * @param {...Object} sources The source objects.
  28682. * @param {Function} [customizer] The function to customize assigned values.
  28683. * @returns {Object} Returns `object`.
  28684. * @see _.assignWith
  28685. * @example
  28686. *
  28687. * function customizer(objValue, srcValue) {
  28688. * return _.isUndefined(objValue) ? srcValue : objValue;
  28689. * }
  28690. *
  28691. * var defaults = _.partialRight(_.assignInWith, customizer);
  28692. *
  28693. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28694. * // => { 'a': 1, 'b': 2 }
  28695. */
  28696. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28697. copyObject(source, keysIn(source), object, customizer);
  28698. });
  28699. /**
  28700. * This method is like `_.assign` except that it accepts `customizer`
  28701. * which is invoked to produce the assigned values. If `customizer` returns
  28702. * `undefined`, assignment is handled by the method instead. The `customizer`
  28703. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28704. *
  28705. * **Note:** This method mutates `object`.
  28706. *
  28707. * @static
  28708. * @memberOf _
  28709. * @since 4.0.0
  28710. * @category Object
  28711. * @param {Object} object The destination object.
  28712. * @param {...Object} sources The source objects.
  28713. * @param {Function} [customizer] The function to customize assigned values.
  28714. * @returns {Object} Returns `object`.
  28715. * @see _.assignInWith
  28716. * @example
  28717. *
  28718. * function customizer(objValue, srcValue) {
  28719. * return _.isUndefined(objValue) ? srcValue : objValue;
  28720. * }
  28721. *
  28722. * var defaults = _.partialRight(_.assignWith, customizer);
  28723. *
  28724. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28725. * // => { 'a': 1, 'b': 2 }
  28726. */
  28727. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28728. copyObject(source, keys(source), object, customizer);
  28729. });
  28730. /**
  28731. * Creates an array of values corresponding to `paths` of `object`.
  28732. *
  28733. * @static
  28734. * @memberOf _
  28735. * @since 1.0.0
  28736. * @category Object
  28737. * @param {Object} object The object to iterate over.
  28738. * @param {...(string|string[])} [paths] The property paths to pick.
  28739. * @returns {Array} Returns the picked values.
  28740. * @example
  28741. *
  28742. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28743. *
  28744. * _.at(object, ['a[0].b.c', 'a[1]']);
  28745. * // => [3, 4]
  28746. */
  28747. var at = flatRest(baseAt);
  28748. /**
  28749. * Creates an object that inherits from the `prototype` object. If a
  28750. * `properties` object is given, its own enumerable string keyed properties
  28751. * are assigned to the created object.
  28752. *
  28753. * @static
  28754. * @memberOf _
  28755. * @since 2.3.0
  28756. * @category Object
  28757. * @param {Object} prototype The object to inherit from.
  28758. * @param {Object} [properties] The properties to assign to the object.
  28759. * @returns {Object} Returns the new object.
  28760. * @example
  28761. *
  28762. * function Shape() {
  28763. * this.x = 0;
  28764. * this.y = 0;
  28765. * }
  28766. *
  28767. * function Circle() {
  28768. * Shape.call(this);
  28769. * }
  28770. *
  28771. * Circle.prototype = _.create(Shape.prototype, {
  28772. * 'constructor': Circle
  28773. * });
  28774. *
  28775. * var circle = new Circle;
  28776. * circle instanceof Circle;
  28777. * // => true
  28778. *
  28779. * circle instanceof Shape;
  28780. * // => true
  28781. */
  28782. function create(prototype, properties) {
  28783. var result = baseCreate(prototype);
  28784. return properties == null ? result : baseAssign(result, properties);
  28785. }
  28786. /**
  28787. * Assigns own and inherited enumerable string keyed properties of source
  28788. * objects to the destination object for all destination properties that
  28789. * resolve to `undefined`. Source objects are applied from left to right.
  28790. * Once a property is set, additional values of the same property are ignored.
  28791. *
  28792. * **Note:** This method mutates `object`.
  28793. *
  28794. * @static
  28795. * @since 0.1.0
  28796. * @memberOf _
  28797. * @category Object
  28798. * @param {Object} object The destination object.
  28799. * @param {...Object} [sources] The source objects.
  28800. * @returns {Object} Returns `object`.
  28801. * @see _.defaultsDeep
  28802. * @example
  28803. *
  28804. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28805. * // => { 'a': 1, 'b': 2 }
  28806. */
  28807. var defaults = baseRest(function(object, sources) {
  28808. object = Object(object);
  28809. var index = -1;
  28810. var length = sources.length;
  28811. var guard = length > 2 ? sources[2] : undefined;
  28812. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28813. length = 1;
  28814. }
  28815. while (++index < length) {
  28816. var source = sources[index];
  28817. var props = keysIn(source);
  28818. var propsIndex = -1;
  28819. var propsLength = props.length;
  28820. while (++propsIndex < propsLength) {
  28821. var key = props[propsIndex];
  28822. var value = object[key];
  28823. if (value === undefined ||
  28824. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28825. object[key] = source[key];
  28826. }
  28827. }
  28828. }
  28829. return object;
  28830. });
  28831. /**
  28832. * This method is like `_.defaults` except that it recursively assigns
  28833. * default properties.
  28834. *
  28835. * **Note:** This method mutates `object`.
  28836. *
  28837. * @static
  28838. * @memberOf _
  28839. * @since 3.10.0
  28840. * @category Object
  28841. * @param {Object} object The destination object.
  28842. * @param {...Object} [sources] The source objects.
  28843. * @returns {Object} Returns `object`.
  28844. * @see _.defaults
  28845. * @example
  28846. *
  28847. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28848. * // => { 'a': { 'b': 2, 'c': 3 } }
  28849. */
  28850. var defaultsDeep = baseRest(function(args) {
  28851. args.push(undefined, customDefaultsMerge);
  28852. return apply(mergeWith, undefined, args);
  28853. });
  28854. /**
  28855. * This method is like `_.find` except that it returns the key of the first
  28856. * element `predicate` returns truthy for instead of the element itself.
  28857. *
  28858. * @static
  28859. * @memberOf _
  28860. * @since 1.1.0
  28861. * @category Object
  28862. * @param {Object} object The object to inspect.
  28863. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28864. * @returns {string|undefined} Returns the key of the matched element,
  28865. * else `undefined`.
  28866. * @example
  28867. *
  28868. * var users = {
  28869. * 'barney': { 'age': 36, 'active': true },
  28870. * 'fred': { 'age': 40, 'active': false },
  28871. * 'pebbles': { 'age': 1, 'active': true }
  28872. * };
  28873. *
  28874. * _.findKey(users, function(o) { return o.age < 40; });
  28875. * // => 'barney' (iteration order is not guaranteed)
  28876. *
  28877. * // The `_.matches` iteratee shorthand.
  28878. * _.findKey(users, { 'age': 1, 'active': true });
  28879. * // => 'pebbles'
  28880. *
  28881. * // The `_.matchesProperty` iteratee shorthand.
  28882. * _.findKey(users, ['active', false]);
  28883. * // => 'fred'
  28884. *
  28885. * // The `_.property` iteratee shorthand.
  28886. * _.findKey(users, 'active');
  28887. * // => 'barney'
  28888. */
  28889. function findKey(object, predicate) {
  28890. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28891. }
  28892. /**
  28893. * This method is like `_.findKey` except that it iterates over elements of
  28894. * a collection in the opposite order.
  28895. *
  28896. * @static
  28897. * @memberOf _
  28898. * @since 2.0.0
  28899. * @category Object
  28900. * @param {Object} object The object to inspect.
  28901. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28902. * @returns {string|undefined} Returns the key of the matched element,
  28903. * else `undefined`.
  28904. * @example
  28905. *
  28906. * var users = {
  28907. * 'barney': { 'age': 36, 'active': true },
  28908. * 'fred': { 'age': 40, 'active': false },
  28909. * 'pebbles': { 'age': 1, 'active': true }
  28910. * };
  28911. *
  28912. * _.findLastKey(users, function(o) { return o.age < 40; });
  28913. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28914. *
  28915. * // The `_.matches` iteratee shorthand.
  28916. * _.findLastKey(users, { 'age': 36, 'active': true });
  28917. * // => 'barney'
  28918. *
  28919. * // The `_.matchesProperty` iteratee shorthand.
  28920. * _.findLastKey(users, ['active', false]);
  28921. * // => 'fred'
  28922. *
  28923. * // The `_.property` iteratee shorthand.
  28924. * _.findLastKey(users, 'active');
  28925. * // => 'pebbles'
  28926. */
  28927. function findLastKey(object, predicate) {
  28928. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28929. }
  28930. /**
  28931. * Iterates over own and inherited enumerable string keyed properties of an
  28932. * object and invokes `iteratee` for each property. The iteratee is invoked
  28933. * with three arguments: (value, key, object). Iteratee functions may exit
  28934. * iteration early by explicitly returning `false`.
  28935. *
  28936. * @static
  28937. * @memberOf _
  28938. * @since 0.3.0
  28939. * @category Object
  28940. * @param {Object} object The object to iterate over.
  28941. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28942. * @returns {Object} Returns `object`.
  28943. * @see _.forInRight
  28944. * @example
  28945. *
  28946. * function Foo() {
  28947. * this.a = 1;
  28948. * this.b = 2;
  28949. * }
  28950. *
  28951. * Foo.prototype.c = 3;
  28952. *
  28953. * _.forIn(new Foo, function(value, key) {
  28954. * console.log(key);
  28955. * });
  28956. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28957. */
  28958. function forIn(object, iteratee) {
  28959. return object == null
  28960. ? object
  28961. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28962. }
  28963. /**
  28964. * This method is like `_.forIn` except that it iterates over properties of
  28965. * `object` in the opposite order.
  28966. *
  28967. * @static
  28968. * @memberOf _
  28969. * @since 2.0.0
  28970. * @category Object
  28971. * @param {Object} object The object to iterate over.
  28972. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28973. * @returns {Object} Returns `object`.
  28974. * @see _.forIn
  28975. * @example
  28976. *
  28977. * function Foo() {
  28978. * this.a = 1;
  28979. * this.b = 2;
  28980. * }
  28981. *
  28982. * Foo.prototype.c = 3;
  28983. *
  28984. * _.forInRight(new Foo, function(value, key) {
  28985. * console.log(key);
  28986. * });
  28987. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  28988. */
  28989. function forInRight(object, iteratee) {
  28990. return object == null
  28991. ? object
  28992. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  28993. }
  28994. /**
  28995. * Iterates over own enumerable string keyed properties of an object and
  28996. * invokes `iteratee` for each property. The iteratee is invoked with three
  28997. * arguments: (value, key, object). Iteratee functions may exit iteration
  28998. * early by explicitly returning `false`.
  28999. *
  29000. * @static
  29001. * @memberOf _
  29002. * @since 0.3.0
  29003. * @category Object
  29004. * @param {Object} object The object to iterate over.
  29005. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29006. * @returns {Object} Returns `object`.
  29007. * @see _.forOwnRight
  29008. * @example
  29009. *
  29010. * function Foo() {
  29011. * this.a = 1;
  29012. * this.b = 2;
  29013. * }
  29014. *
  29015. * Foo.prototype.c = 3;
  29016. *
  29017. * _.forOwn(new Foo, function(value, key) {
  29018. * console.log(key);
  29019. * });
  29020. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29021. */
  29022. function forOwn(object, iteratee) {
  29023. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29024. }
  29025. /**
  29026. * This method is like `_.forOwn` except that it iterates over properties of
  29027. * `object` in the opposite order.
  29028. *
  29029. * @static
  29030. * @memberOf _
  29031. * @since 2.0.0
  29032. * @category Object
  29033. * @param {Object} object The object to iterate over.
  29034. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29035. * @returns {Object} Returns `object`.
  29036. * @see _.forOwn
  29037. * @example
  29038. *
  29039. * function Foo() {
  29040. * this.a = 1;
  29041. * this.b = 2;
  29042. * }
  29043. *
  29044. * Foo.prototype.c = 3;
  29045. *
  29046. * _.forOwnRight(new Foo, function(value, key) {
  29047. * console.log(key);
  29048. * });
  29049. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29050. */
  29051. function forOwnRight(object, iteratee) {
  29052. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29053. }
  29054. /**
  29055. * Creates an array of function property names from own enumerable properties
  29056. * of `object`.
  29057. *
  29058. * @static
  29059. * @since 0.1.0
  29060. * @memberOf _
  29061. * @category Object
  29062. * @param {Object} object The object to inspect.
  29063. * @returns {Array} Returns the function names.
  29064. * @see _.functionsIn
  29065. * @example
  29066. *
  29067. * function Foo() {
  29068. * this.a = _.constant('a');
  29069. * this.b = _.constant('b');
  29070. * }
  29071. *
  29072. * Foo.prototype.c = _.constant('c');
  29073. *
  29074. * _.functions(new Foo);
  29075. * // => ['a', 'b']
  29076. */
  29077. function functions(object) {
  29078. return object == null ? [] : baseFunctions(object, keys(object));
  29079. }
  29080. /**
  29081. * Creates an array of function property names from own and inherited
  29082. * enumerable properties of `object`.
  29083. *
  29084. * @static
  29085. * @memberOf _
  29086. * @since 4.0.0
  29087. * @category Object
  29088. * @param {Object} object The object to inspect.
  29089. * @returns {Array} Returns the function names.
  29090. * @see _.functions
  29091. * @example
  29092. *
  29093. * function Foo() {
  29094. * this.a = _.constant('a');
  29095. * this.b = _.constant('b');
  29096. * }
  29097. *
  29098. * Foo.prototype.c = _.constant('c');
  29099. *
  29100. * _.functionsIn(new Foo);
  29101. * // => ['a', 'b', 'c']
  29102. */
  29103. function functionsIn(object) {
  29104. return object == null ? [] : baseFunctions(object, keysIn(object));
  29105. }
  29106. /**
  29107. * Gets the value at `path` of `object`. If the resolved value is
  29108. * `undefined`, the `defaultValue` is returned in its place.
  29109. *
  29110. * @static
  29111. * @memberOf _
  29112. * @since 3.7.0
  29113. * @category Object
  29114. * @param {Object} object The object to query.
  29115. * @param {Array|string} path The path of the property to get.
  29116. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29117. * @returns {*} Returns the resolved value.
  29118. * @example
  29119. *
  29120. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29121. *
  29122. * _.get(object, 'a[0].b.c');
  29123. * // => 3
  29124. *
  29125. * _.get(object, ['a', '0', 'b', 'c']);
  29126. * // => 3
  29127. *
  29128. * _.get(object, 'a.b.c', 'default');
  29129. * // => 'default'
  29130. */
  29131. function get(object, path, defaultValue) {
  29132. var result = object == null ? undefined : baseGet(object, path);
  29133. return result === undefined ? defaultValue : result;
  29134. }
  29135. /**
  29136. * Checks if `path` is a direct property of `object`.
  29137. *
  29138. * @static
  29139. * @since 0.1.0
  29140. * @memberOf _
  29141. * @category Object
  29142. * @param {Object} object The object to query.
  29143. * @param {Array|string} path The path to check.
  29144. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29145. * @example
  29146. *
  29147. * var object = { 'a': { 'b': 2 } };
  29148. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29149. *
  29150. * _.has(object, 'a');
  29151. * // => true
  29152. *
  29153. * _.has(object, 'a.b');
  29154. * // => true
  29155. *
  29156. * _.has(object, ['a', 'b']);
  29157. * // => true
  29158. *
  29159. * _.has(other, 'a');
  29160. * // => false
  29161. */
  29162. function has(object, path) {
  29163. return object != null && hasPath(object, path, baseHas);
  29164. }
  29165. /**
  29166. * Checks if `path` is a direct or inherited property of `object`.
  29167. *
  29168. * @static
  29169. * @memberOf _
  29170. * @since 4.0.0
  29171. * @category Object
  29172. * @param {Object} object The object to query.
  29173. * @param {Array|string} path The path to check.
  29174. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29175. * @example
  29176. *
  29177. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29178. *
  29179. * _.hasIn(object, 'a');
  29180. * // => true
  29181. *
  29182. * _.hasIn(object, 'a.b');
  29183. * // => true
  29184. *
  29185. * _.hasIn(object, ['a', 'b']);
  29186. * // => true
  29187. *
  29188. * _.hasIn(object, 'b');
  29189. * // => false
  29190. */
  29191. function hasIn(object, path) {
  29192. return object != null && hasPath(object, path, baseHasIn);
  29193. }
  29194. /**
  29195. * Creates an object composed of the inverted keys and values of `object`.
  29196. * If `object` contains duplicate values, subsequent values overwrite
  29197. * property assignments of previous values.
  29198. *
  29199. * @static
  29200. * @memberOf _
  29201. * @since 0.7.0
  29202. * @category Object
  29203. * @param {Object} object The object to invert.
  29204. * @returns {Object} Returns the new inverted object.
  29205. * @example
  29206. *
  29207. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29208. *
  29209. * _.invert(object);
  29210. * // => { '1': 'c', '2': 'b' }
  29211. */
  29212. var invert = createInverter(function(result, value, key) {
  29213. if (value != null &&
  29214. typeof value.toString != 'function') {
  29215. value = nativeObjectToString.call(value);
  29216. }
  29217. result[value] = key;
  29218. }, constant(identity));
  29219. /**
  29220. * This method is like `_.invert` except that the inverted object is generated
  29221. * from the results of running each element of `object` thru `iteratee`. The
  29222. * corresponding inverted value of each inverted key is an array of keys
  29223. * responsible for generating the inverted value. The iteratee is invoked
  29224. * with one argument: (value).
  29225. *
  29226. * @static
  29227. * @memberOf _
  29228. * @since 4.1.0
  29229. * @category Object
  29230. * @param {Object} object The object to invert.
  29231. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29232. * @returns {Object} Returns the new inverted object.
  29233. * @example
  29234. *
  29235. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29236. *
  29237. * _.invertBy(object);
  29238. * // => { '1': ['a', 'c'], '2': ['b'] }
  29239. *
  29240. * _.invertBy(object, function(value) {
  29241. * return 'group' + value;
  29242. * });
  29243. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29244. */
  29245. var invertBy = createInverter(function(result, value, key) {
  29246. if (value != null &&
  29247. typeof value.toString != 'function') {
  29248. value = nativeObjectToString.call(value);
  29249. }
  29250. if (hasOwnProperty.call(result, value)) {
  29251. result[value].push(key);
  29252. } else {
  29253. result[value] = [key];
  29254. }
  29255. }, getIteratee);
  29256. /**
  29257. * Invokes the method at `path` of `object`.
  29258. *
  29259. * @static
  29260. * @memberOf _
  29261. * @since 4.0.0
  29262. * @category Object
  29263. * @param {Object} object The object to query.
  29264. * @param {Array|string} path The path of the method to invoke.
  29265. * @param {...*} [args] The arguments to invoke the method with.
  29266. * @returns {*} Returns the result of the invoked method.
  29267. * @example
  29268. *
  29269. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29270. *
  29271. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29272. * // => [2, 3]
  29273. */
  29274. var invoke = baseRest(baseInvoke);
  29275. /**
  29276. * Creates an array of the own enumerable property names of `object`.
  29277. *
  29278. * **Note:** Non-object values are coerced to objects. See the
  29279. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29280. * for more details.
  29281. *
  29282. * @static
  29283. * @since 0.1.0
  29284. * @memberOf _
  29285. * @category Object
  29286. * @param {Object} object The object to query.
  29287. * @returns {Array} Returns the array of property names.
  29288. * @example
  29289. *
  29290. * function Foo() {
  29291. * this.a = 1;
  29292. * this.b = 2;
  29293. * }
  29294. *
  29295. * Foo.prototype.c = 3;
  29296. *
  29297. * _.keys(new Foo);
  29298. * // => ['a', 'b'] (iteration order is not guaranteed)
  29299. *
  29300. * _.keys('hi');
  29301. * // => ['0', '1']
  29302. */
  29303. function keys(object) {
  29304. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29305. }
  29306. /**
  29307. * Creates an array of the own and inherited enumerable property names of `object`.
  29308. *
  29309. * **Note:** Non-object values are coerced to objects.
  29310. *
  29311. * @static
  29312. * @memberOf _
  29313. * @since 3.0.0
  29314. * @category Object
  29315. * @param {Object} object The object to query.
  29316. * @returns {Array} Returns the array of property names.
  29317. * @example
  29318. *
  29319. * function Foo() {
  29320. * this.a = 1;
  29321. * this.b = 2;
  29322. * }
  29323. *
  29324. * Foo.prototype.c = 3;
  29325. *
  29326. * _.keysIn(new Foo);
  29327. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29328. */
  29329. function keysIn(object) {
  29330. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29331. }
  29332. /**
  29333. * The opposite of `_.mapValues`; this method creates an object with the
  29334. * same values as `object` and keys generated by running each own enumerable
  29335. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29336. * with three arguments: (value, key, object).
  29337. *
  29338. * @static
  29339. * @memberOf _
  29340. * @since 3.8.0
  29341. * @category Object
  29342. * @param {Object} object The object to iterate over.
  29343. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29344. * @returns {Object} Returns the new mapped object.
  29345. * @see _.mapValues
  29346. * @example
  29347. *
  29348. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29349. * return key + value;
  29350. * });
  29351. * // => { 'a1': 1, 'b2': 2 }
  29352. */
  29353. function mapKeys(object, iteratee) {
  29354. var result = {};
  29355. iteratee = getIteratee(iteratee, 3);
  29356. baseForOwn(object, function(value, key, object) {
  29357. baseAssignValue(result, iteratee(value, key, object), value);
  29358. });
  29359. return result;
  29360. }
  29361. /**
  29362. * Creates an object with the same keys as `object` and values generated
  29363. * by running each own enumerable string keyed property of `object` thru
  29364. * `iteratee`. The iteratee is invoked with three arguments:
  29365. * (value, key, object).
  29366. *
  29367. * @static
  29368. * @memberOf _
  29369. * @since 2.4.0
  29370. * @category Object
  29371. * @param {Object} object The object to iterate over.
  29372. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29373. * @returns {Object} Returns the new mapped object.
  29374. * @see _.mapKeys
  29375. * @example
  29376. *
  29377. * var users = {
  29378. * 'fred': { 'user': 'fred', 'age': 40 },
  29379. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29380. * };
  29381. *
  29382. * _.mapValues(users, function(o) { return o.age; });
  29383. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29384. *
  29385. * // The `_.property` iteratee shorthand.
  29386. * _.mapValues(users, 'age');
  29387. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29388. */
  29389. function mapValues(object, iteratee) {
  29390. var result = {};
  29391. iteratee = getIteratee(iteratee, 3);
  29392. baseForOwn(object, function(value, key, object) {
  29393. baseAssignValue(result, key, iteratee(value, key, object));
  29394. });
  29395. return result;
  29396. }
  29397. /**
  29398. * This method is like `_.assign` except that it recursively merges own and
  29399. * inherited enumerable string keyed properties of source objects into the
  29400. * destination object. Source properties that resolve to `undefined` are
  29401. * skipped if a destination value exists. Array and plain object properties
  29402. * are merged recursively. Other objects and value types are overridden by
  29403. * assignment. Source objects are applied from left to right. Subsequent
  29404. * sources overwrite property assignments of previous sources.
  29405. *
  29406. * **Note:** This method mutates `object`.
  29407. *
  29408. * @static
  29409. * @memberOf _
  29410. * @since 0.5.0
  29411. * @category Object
  29412. * @param {Object} object The destination object.
  29413. * @param {...Object} [sources] The source objects.
  29414. * @returns {Object} Returns `object`.
  29415. * @example
  29416. *
  29417. * var object = {
  29418. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29419. * };
  29420. *
  29421. * var other = {
  29422. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29423. * };
  29424. *
  29425. * _.merge(object, other);
  29426. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29427. */
  29428. var merge = createAssigner(function(object, source, srcIndex) {
  29429. baseMerge(object, source, srcIndex);
  29430. });
  29431. /**
  29432. * This method is like `_.merge` except that it accepts `customizer` which
  29433. * is invoked to produce the merged values of the destination and source
  29434. * properties. If `customizer` returns `undefined`, merging is handled by the
  29435. * method instead. The `customizer` is invoked with six arguments:
  29436. * (objValue, srcValue, key, object, source, stack).
  29437. *
  29438. * **Note:** This method mutates `object`.
  29439. *
  29440. * @static
  29441. * @memberOf _
  29442. * @since 4.0.0
  29443. * @category Object
  29444. * @param {Object} object The destination object.
  29445. * @param {...Object} sources The source objects.
  29446. * @param {Function} customizer The function to customize assigned values.
  29447. * @returns {Object} Returns `object`.
  29448. * @example
  29449. *
  29450. * function customizer(objValue, srcValue) {
  29451. * if (_.isArray(objValue)) {
  29452. * return objValue.concat(srcValue);
  29453. * }
  29454. * }
  29455. *
  29456. * var object = { 'a': [1], 'b': [2] };
  29457. * var other = { 'a': [3], 'b': [4] };
  29458. *
  29459. * _.mergeWith(object, other, customizer);
  29460. * // => { 'a': [1, 3], 'b': [2, 4] }
  29461. */
  29462. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29463. baseMerge(object, source, srcIndex, customizer);
  29464. });
  29465. /**
  29466. * The opposite of `_.pick`; this method creates an object composed of the
  29467. * own and inherited enumerable property paths of `object` that are not omitted.
  29468. *
  29469. * **Note:** This method is considerably slower than `_.pick`.
  29470. *
  29471. * @static
  29472. * @since 0.1.0
  29473. * @memberOf _
  29474. * @category Object
  29475. * @param {Object} object The source object.
  29476. * @param {...(string|string[])} [paths] The property paths to omit.
  29477. * @returns {Object} Returns the new object.
  29478. * @example
  29479. *
  29480. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29481. *
  29482. * _.omit(object, ['a', 'c']);
  29483. * // => { 'b': '2' }
  29484. */
  29485. var omit = flatRest(function(object, paths) {
  29486. var result = {};
  29487. if (object == null) {
  29488. return result;
  29489. }
  29490. var isDeep = false;
  29491. paths = arrayMap(paths, function(path) {
  29492. path = castPath(path, object);
  29493. isDeep || (isDeep = path.length > 1);
  29494. return path;
  29495. });
  29496. copyObject(object, getAllKeysIn(object), result);
  29497. if (isDeep) {
  29498. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29499. }
  29500. var length = paths.length;
  29501. while (length--) {
  29502. baseUnset(result, paths[length]);
  29503. }
  29504. return result;
  29505. });
  29506. /**
  29507. * The opposite of `_.pickBy`; this method creates an object composed of
  29508. * the own and inherited enumerable string keyed properties of `object` that
  29509. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29510. * arguments: (value, key).
  29511. *
  29512. * @static
  29513. * @memberOf _
  29514. * @since 4.0.0
  29515. * @category Object
  29516. * @param {Object} object The source object.
  29517. * @param {Function} [predicate=_.identity] The function invoked per property.
  29518. * @returns {Object} Returns the new object.
  29519. * @example
  29520. *
  29521. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29522. *
  29523. * _.omitBy(object, _.isNumber);
  29524. * // => { 'b': '2' }
  29525. */
  29526. function omitBy(object, predicate) {
  29527. return pickBy(object, negate(getIteratee(predicate)));
  29528. }
  29529. /**
  29530. * Creates an object composed of the picked `object` properties.
  29531. *
  29532. * @static
  29533. * @since 0.1.0
  29534. * @memberOf _
  29535. * @category Object
  29536. * @param {Object} object The source object.
  29537. * @param {...(string|string[])} [paths] The property paths to pick.
  29538. * @returns {Object} Returns the new object.
  29539. * @example
  29540. *
  29541. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29542. *
  29543. * _.pick(object, ['a', 'c']);
  29544. * // => { 'a': 1, 'c': 3 }
  29545. */
  29546. var pick = flatRest(function(object, paths) {
  29547. return object == null ? {} : basePick(object, paths);
  29548. });
  29549. /**
  29550. * Creates an object composed of the `object` properties `predicate` returns
  29551. * truthy for. The predicate is invoked with two arguments: (value, key).
  29552. *
  29553. * @static
  29554. * @memberOf _
  29555. * @since 4.0.0
  29556. * @category Object
  29557. * @param {Object} object The source object.
  29558. * @param {Function} [predicate=_.identity] The function invoked per property.
  29559. * @returns {Object} Returns the new object.
  29560. * @example
  29561. *
  29562. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29563. *
  29564. * _.pickBy(object, _.isNumber);
  29565. * // => { 'a': 1, 'c': 3 }
  29566. */
  29567. function pickBy(object, predicate) {
  29568. if (object == null) {
  29569. return {};
  29570. }
  29571. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29572. return [prop];
  29573. });
  29574. predicate = getIteratee(predicate);
  29575. return basePickBy(object, props, function(value, path) {
  29576. return predicate(value, path[0]);
  29577. });
  29578. }
  29579. /**
  29580. * This method is like `_.get` except that if the resolved value is a
  29581. * function it's invoked with the `this` binding of its parent object and
  29582. * its result is returned.
  29583. *
  29584. * @static
  29585. * @since 0.1.0
  29586. * @memberOf _
  29587. * @category Object
  29588. * @param {Object} object The object to query.
  29589. * @param {Array|string} path The path of the property to resolve.
  29590. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29591. * @returns {*} Returns the resolved value.
  29592. * @example
  29593. *
  29594. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29595. *
  29596. * _.result(object, 'a[0].b.c1');
  29597. * // => 3
  29598. *
  29599. * _.result(object, 'a[0].b.c2');
  29600. * // => 4
  29601. *
  29602. * _.result(object, 'a[0].b.c3', 'default');
  29603. * // => 'default'
  29604. *
  29605. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29606. * // => 'default'
  29607. */
  29608. function result(object, path, defaultValue) {
  29609. path = castPath(path, object);
  29610. var index = -1,
  29611. length = path.length;
  29612. // Ensure the loop is entered when path is empty.
  29613. if (!length) {
  29614. length = 1;
  29615. object = undefined;
  29616. }
  29617. while (++index < length) {
  29618. var value = object == null ? undefined : object[toKey(path[index])];
  29619. if (value === undefined) {
  29620. index = length;
  29621. value = defaultValue;
  29622. }
  29623. object = isFunction(value) ? value.call(object) : value;
  29624. }
  29625. return object;
  29626. }
  29627. /**
  29628. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29629. * it's created. Arrays are created for missing index properties while objects
  29630. * are created for all other missing properties. Use `_.setWith` to customize
  29631. * `path` creation.
  29632. *
  29633. * **Note:** This method mutates `object`.
  29634. *
  29635. * @static
  29636. * @memberOf _
  29637. * @since 3.7.0
  29638. * @category Object
  29639. * @param {Object} object The object to modify.
  29640. * @param {Array|string} path The path of the property to set.
  29641. * @param {*} value The value to set.
  29642. * @returns {Object} Returns `object`.
  29643. * @example
  29644. *
  29645. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29646. *
  29647. * _.set(object, 'a[0].b.c', 4);
  29648. * console.log(object.a[0].b.c);
  29649. * // => 4
  29650. *
  29651. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29652. * console.log(object.x[0].y.z);
  29653. * // => 5
  29654. */
  29655. function set(object, path, value) {
  29656. return object == null ? object : baseSet(object, path, value);
  29657. }
  29658. /**
  29659. * This method is like `_.set` except that it accepts `customizer` which is
  29660. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29661. * path creation is handled by the method instead. The `customizer` is invoked
  29662. * with three arguments: (nsValue, key, nsObject).
  29663. *
  29664. * **Note:** This method mutates `object`.
  29665. *
  29666. * @static
  29667. * @memberOf _
  29668. * @since 4.0.0
  29669. * @category Object
  29670. * @param {Object} object The object to modify.
  29671. * @param {Array|string} path The path of the property to set.
  29672. * @param {*} value The value to set.
  29673. * @param {Function} [customizer] The function to customize assigned values.
  29674. * @returns {Object} Returns `object`.
  29675. * @example
  29676. *
  29677. * var object = {};
  29678. *
  29679. * _.setWith(object, '[0][1]', 'a', Object);
  29680. * // => { '0': { '1': 'a' } }
  29681. */
  29682. function setWith(object, path, value, customizer) {
  29683. customizer = typeof customizer == 'function' ? customizer : undefined;
  29684. return object == null ? object : baseSet(object, path, value, customizer);
  29685. }
  29686. /**
  29687. * Creates an array of own enumerable string keyed-value pairs for `object`
  29688. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29689. * entries are returned.
  29690. *
  29691. * @static
  29692. * @memberOf _
  29693. * @since 4.0.0
  29694. * @alias entries
  29695. * @category Object
  29696. * @param {Object} object The object to query.
  29697. * @returns {Array} Returns the key-value pairs.
  29698. * @example
  29699. *
  29700. * function Foo() {
  29701. * this.a = 1;
  29702. * this.b = 2;
  29703. * }
  29704. *
  29705. * Foo.prototype.c = 3;
  29706. *
  29707. * _.toPairs(new Foo);
  29708. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29709. */
  29710. var toPairs = createToPairs(keys);
  29711. /**
  29712. * Creates an array of own and inherited enumerable string keyed-value pairs
  29713. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29714. * or set, its entries are returned.
  29715. *
  29716. * @static
  29717. * @memberOf _
  29718. * @since 4.0.0
  29719. * @alias entriesIn
  29720. * @category Object
  29721. * @param {Object} object The object to query.
  29722. * @returns {Array} Returns the key-value pairs.
  29723. * @example
  29724. *
  29725. * function Foo() {
  29726. * this.a = 1;
  29727. * this.b = 2;
  29728. * }
  29729. *
  29730. * Foo.prototype.c = 3;
  29731. *
  29732. * _.toPairsIn(new Foo);
  29733. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29734. */
  29735. var toPairsIn = createToPairs(keysIn);
  29736. /**
  29737. * An alternative to `_.reduce`; this method transforms `object` to a new
  29738. * `accumulator` object which is the result of running each of its own
  29739. * enumerable string keyed properties thru `iteratee`, with each invocation
  29740. * potentially mutating the `accumulator` object. If `accumulator` is not
  29741. * provided, a new object with the same `[[Prototype]]` will be used. The
  29742. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29743. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29744. *
  29745. * @static
  29746. * @memberOf _
  29747. * @since 1.3.0
  29748. * @category Object
  29749. * @param {Object} object The object to iterate over.
  29750. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29751. * @param {*} [accumulator] The custom accumulator value.
  29752. * @returns {*} Returns the accumulated value.
  29753. * @example
  29754. *
  29755. * _.transform([2, 3, 4], function(result, n) {
  29756. * result.push(n *= n);
  29757. * return n % 2 == 0;
  29758. * }, []);
  29759. * // => [4, 9]
  29760. *
  29761. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29762. * (result[value] || (result[value] = [])).push(key);
  29763. * }, {});
  29764. * // => { '1': ['a', 'c'], '2': ['b'] }
  29765. */
  29766. function transform(object, iteratee, accumulator) {
  29767. var isArr = isArray(object),
  29768. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29769. iteratee = getIteratee(iteratee, 4);
  29770. if (accumulator == null) {
  29771. var Ctor = object && object.constructor;
  29772. if (isArrLike) {
  29773. accumulator = isArr ? new Ctor : [];
  29774. }
  29775. else if (isObject(object)) {
  29776. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29777. }
  29778. else {
  29779. accumulator = {};
  29780. }
  29781. }
  29782. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29783. return iteratee(accumulator, value, index, object);
  29784. });
  29785. return accumulator;
  29786. }
  29787. /**
  29788. * Removes the property at `path` of `object`.
  29789. *
  29790. * **Note:** This method mutates `object`.
  29791. *
  29792. * @static
  29793. * @memberOf _
  29794. * @since 4.0.0
  29795. * @category Object
  29796. * @param {Object} object The object to modify.
  29797. * @param {Array|string} path The path of the property to unset.
  29798. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29799. * @example
  29800. *
  29801. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29802. * _.unset(object, 'a[0].b.c');
  29803. * // => true
  29804. *
  29805. * console.log(object);
  29806. * // => { 'a': [{ 'b': {} }] };
  29807. *
  29808. * _.unset(object, ['a', '0', 'b', 'c']);
  29809. * // => true
  29810. *
  29811. * console.log(object);
  29812. * // => { 'a': [{ 'b': {} }] };
  29813. */
  29814. function unset(object, path) {
  29815. return object == null ? true : baseUnset(object, path);
  29816. }
  29817. /**
  29818. * This method is like `_.set` except that accepts `updater` to produce the
  29819. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29820. * is invoked with one argument: (value).
  29821. *
  29822. * **Note:** This method mutates `object`.
  29823. *
  29824. * @static
  29825. * @memberOf _
  29826. * @since 4.6.0
  29827. * @category Object
  29828. * @param {Object} object The object to modify.
  29829. * @param {Array|string} path The path of the property to set.
  29830. * @param {Function} updater The function to produce the updated value.
  29831. * @returns {Object} Returns `object`.
  29832. * @example
  29833. *
  29834. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29835. *
  29836. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29837. * console.log(object.a[0].b.c);
  29838. * // => 9
  29839. *
  29840. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29841. * console.log(object.x[0].y.z);
  29842. * // => 0
  29843. */
  29844. function update(object, path, updater) {
  29845. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29846. }
  29847. /**
  29848. * This method is like `_.update` except that it accepts `customizer` which is
  29849. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29850. * path creation is handled by the method instead. The `customizer` is invoked
  29851. * with three arguments: (nsValue, key, nsObject).
  29852. *
  29853. * **Note:** This method mutates `object`.
  29854. *
  29855. * @static
  29856. * @memberOf _
  29857. * @since 4.6.0
  29858. * @category Object
  29859. * @param {Object} object The object to modify.
  29860. * @param {Array|string} path The path of the property to set.
  29861. * @param {Function} updater The function to produce the updated value.
  29862. * @param {Function} [customizer] The function to customize assigned values.
  29863. * @returns {Object} Returns `object`.
  29864. * @example
  29865. *
  29866. * var object = {};
  29867. *
  29868. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29869. * // => { '0': { '1': 'a' } }
  29870. */
  29871. function updateWith(object, path, updater, customizer) {
  29872. customizer = typeof customizer == 'function' ? customizer : undefined;
  29873. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29874. }
  29875. /**
  29876. * Creates an array of the own enumerable string keyed property values of `object`.
  29877. *
  29878. * **Note:** Non-object values are coerced to objects.
  29879. *
  29880. * @static
  29881. * @since 0.1.0
  29882. * @memberOf _
  29883. * @category Object
  29884. * @param {Object} object The object to query.
  29885. * @returns {Array} Returns the array of property values.
  29886. * @example
  29887. *
  29888. * function Foo() {
  29889. * this.a = 1;
  29890. * this.b = 2;
  29891. * }
  29892. *
  29893. * Foo.prototype.c = 3;
  29894. *
  29895. * _.values(new Foo);
  29896. * // => [1, 2] (iteration order is not guaranteed)
  29897. *
  29898. * _.values('hi');
  29899. * // => ['h', 'i']
  29900. */
  29901. function values(object) {
  29902. return object == null ? [] : baseValues(object, keys(object));
  29903. }
  29904. /**
  29905. * Creates an array of the own and inherited enumerable string keyed property
  29906. * values of `object`.
  29907. *
  29908. * **Note:** Non-object values are coerced to objects.
  29909. *
  29910. * @static
  29911. * @memberOf _
  29912. * @since 3.0.0
  29913. * @category Object
  29914. * @param {Object} object The object to query.
  29915. * @returns {Array} Returns the array of property values.
  29916. * @example
  29917. *
  29918. * function Foo() {
  29919. * this.a = 1;
  29920. * this.b = 2;
  29921. * }
  29922. *
  29923. * Foo.prototype.c = 3;
  29924. *
  29925. * _.valuesIn(new Foo);
  29926. * // => [1, 2, 3] (iteration order is not guaranteed)
  29927. */
  29928. function valuesIn(object) {
  29929. return object == null ? [] : baseValues(object, keysIn(object));
  29930. }
  29931. /*------------------------------------------------------------------------*/
  29932. /**
  29933. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29934. *
  29935. * @static
  29936. * @memberOf _
  29937. * @since 4.0.0
  29938. * @category Number
  29939. * @param {number} number The number to clamp.
  29940. * @param {number} [lower] The lower bound.
  29941. * @param {number} upper The upper bound.
  29942. * @returns {number} Returns the clamped number.
  29943. * @example
  29944. *
  29945. * _.clamp(-10, -5, 5);
  29946. * // => -5
  29947. *
  29948. * _.clamp(10, -5, 5);
  29949. * // => 5
  29950. */
  29951. function clamp(number, lower, upper) {
  29952. if (upper === undefined) {
  29953. upper = lower;
  29954. lower = undefined;
  29955. }
  29956. if (upper !== undefined) {
  29957. upper = toNumber(upper);
  29958. upper = upper === upper ? upper : 0;
  29959. }
  29960. if (lower !== undefined) {
  29961. lower = toNumber(lower);
  29962. lower = lower === lower ? lower : 0;
  29963. }
  29964. return baseClamp(toNumber(number), lower, upper);
  29965. }
  29966. /**
  29967. * Checks if `n` is between `start` and up to, but not including, `end`. If
  29968. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  29969. * If `start` is greater than `end` the params are swapped to support
  29970. * negative ranges.
  29971. *
  29972. * @static
  29973. * @memberOf _
  29974. * @since 3.3.0
  29975. * @category Number
  29976. * @param {number} number The number to check.
  29977. * @param {number} [start=0] The start of the range.
  29978. * @param {number} end The end of the range.
  29979. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  29980. * @see _.range, _.rangeRight
  29981. * @example
  29982. *
  29983. * _.inRange(3, 2, 4);
  29984. * // => true
  29985. *
  29986. * _.inRange(4, 8);
  29987. * // => true
  29988. *
  29989. * _.inRange(4, 2);
  29990. * // => false
  29991. *
  29992. * _.inRange(2, 2);
  29993. * // => false
  29994. *
  29995. * _.inRange(1.2, 2);
  29996. * // => true
  29997. *
  29998. * _.inRange(5.2, 4);
  29999. * // => false
  30000. *
  30001. * _.inRange(-3, -2, -6);
  30002. * // => true
  30003. */
  30004. function inRange(number, start, end) {
  30005. start = toFinite(start);
  30006. if (end === undefined) {
  30007. end = start;
  30008. start = 0;
  30009. } else {
  30010. end = toFinite(end);
  30011. }
  30012. number = toNumber(number);
  30013. return baseInRange(number, start, end);
  30014. }
  30015. /**
  30016. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30017. * If only one argument is provided a number between `0` and the given number
  30018. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30019. * floats, a floating-point number is returned instead of an integer.
  30020. *
  30021. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30022. * floating-point values which can produce unexpected results.
  30023. *
  30024. * @static
  30025. * @memberOf _
  30026. * @since 0.7.0
  30027. * @category Number
  30028. * @param {number} [lower=0] The lower bound.
  30029. * @param {number} [upper=1] The upper bound.
  30030. * @param {boolean} [floating] Specify returning a floating-point number.
  30031. * @returns {number} Returns the random number.
  30032. * @example
  30033. *
  30034. * _.random(0, 5);
  30035. * // => an integer between 0 and 5
  30036. *
  30037. * _.random(5);
  30038. * // => also an integer between 0 and 5
  30039. *
  30040. * _.random(5, true);
  30041. * // => a floating-point number between 0 and 5
  30042. *
  30043. * _.random(1.2, 5.2);
  30044. * // => a floating-point number between 1.2 and 5.2
  30045. */
  30046. function random(lower, upper, floating) {
  30047. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30048. upper = floating = undefined;
  30049. }
  30050. if (floating === undefined) {
  30051. if (typeof upper == 'boolean') {
  30052. floating = upper;
  30053. upper = undefined;
  30054. }
  30055. else if (typeof lower == 'boolean') {
  30056. floating = lower;
  30057. lower = undefined;
  30058. }
  30059. }
  30060. if (lower === undefined && upper === undefined) {
  30061. lower = 0;
  30062. upper = 1;
  30063. }
  30064. else {
  30065. lower = toFinite(lower);
  30066. if (upper === undefined) {
  30067. upper = lower;
  30068. lower = 0;
  30069. } else {
  30070. upper = toFinite(upper);
  30071. }
  30072. }
  30073. if (lower > upper) {
  30074. var temp = lower;
  30075. lower = upper;
  30076. upper = temp;
  30077. }
  30078. if (floating || lower % 1 || upper % 1) {
  30079. var rand = nativeRandom();
  30080. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30081. }
  30082. return baseRandom(lower, upper);
  30083. }
  30084. /*------------------------------------------------------------------------*/
  30085. /**
  30086. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30087. *
  30088. * @static
  30089. * @memberOf _
  30090. * @since 3.0.0
  30091. * @category String
  30092. * @param {string} [string=''] The string to convert.
  30093. * @returns {string} Returns the camel cased string.
  30094. * @example
  30095. *
  30096. * _.camelCase('Foo Bar');
  30097. * // => 'fooBar'
  30098. *
  30099. * _.camelCase('--foo-bar--');
  30100. * // => 'fooBar'
  30101. *
  30102. * _.camelCase('__FOO_BAR__');
  30103. * // => 'fooBar'
  30104. */
  30105. var camelCase = createCompounder(function(result, word, index) {
  30106. word = word.toLowerCase();
  30107. return result + (index ? capitalize(word) : word);
  30108. });
  30109. /**
  30110. * Converts the first character of `string` to upper case and the remaining
  30111. * to lower case.
  30112. *
  30113. * @static
  30114. * @memberOf _
  30115. * @since 3.0.0
  30116. * @category String
  30117. * @param {string} [string=''] The string to capitalize.
  30118. * @returns {string} Returns the capitalized string.
  30119. * @example
  30120. *
  30121. * _.capitalize('FRED');
  30122. * // => 'Fred'
  30123. */
  30124. function capitalize(string) {
  30125. return upperFirst(toString(string).toLowerCase());
  30126. }
  30127. /**
  30128. * Deburrs `string` by converting
  30129. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30130. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30131. * letters to basic Latin letters and removing
  30132. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30133. *
  30134. * @static
  30135. * @memberOf _
  30136. * @since 3.0.0
  30137. * @category String
  30138. * @param {string} [string=''] The string to deburr.
  30139. * @returns {string} Returns the deburred string.
  30140. * @example
  30141. *
  30142. * _.deburr('déjà vu');
  30143. * // => 'deja vu'
  30144. */
  30145. function deburr(string) {
  30146. string = toString(string);
  30147. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30148. }
  30149. /**
  30150. * Checks if `string` ends with the given target string.
  30151. *
  30152. * @static
  30153. * @memberOf _
  30154. * @since 3.0.0
  30155. * @category String
  30156. * @param {string} [string=''] The string to inspect.
  30157. * @param {string} [target] The string to search for.
  30158. * @param {number} [position=string.length] The position to search up to.
  30159. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30160. * else `false`.
  30161. * @example
  30162. *
  30163. * _.endsWith('abc', 'c');
  30164. * // => true
  30165. *
  30166. * _.endsWith('abc', 'b');
  30167. * // => false
  30168. *
  30169. * _.endsWith('abc', 'b', 2);
  30170. * // => true
  30171. */
  30172. function endsWith(string, target, position) {
  30173. string = toString(string);
  30174. target = baseToString(target);
  30175. var length = string.length;
  30176. position = position === undefined
  30177. ? length
  30178. : baseClamp(toInteger(position), 0, length);
  30179. var end = position;
  30180. position -= target.length;
  30181. return position >= 0 && string.slice(position, end) == target;
  30182. }
  30183. /**
  30184. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30185. * corresponding HTML entities.
  30186. *
  30187. * **Note:** No other characters are escaped. To escape additional
  30188. * characters use a third-party library like [_he_](https://mths.be/he).
  30189. *
  30190. * Though the ">" character is escaped for symmetry, characters like
  30191. * ">" and "/" don't need escaping in HTML and have no special meaning
  30192. * unless they're part of a tag or unquoted attribute value. See
  30193. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30194. * (under "semi-related fun fact") for more details.
  30195. *
  30196. * When working with HTML you should always
  30197. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30198. * XSS vectors.
  30199. *
  30200. * @static
  30201. * @since 0.1.0
  30202. * @memberOf _
  30203. * @category String
  30204. * @param {string} [string=''] The string to escape.
  30205. * @returns {string} Returns the escaped string.
  30206. * @example
  30207. *
  30208. * _.escape('fred, barney, & pebbles');
  30209. * // => 'fred, barney, &amp; pebbles'
  30210. */
  30211. function escape(string) {
  30212. string = toString(string);
  30213. return (string && reHasUnescapedHtml.test(string))
  30214. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30215. : string;
  30216. }
  30217. /**
  30218. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30219. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30220. *
  30221. * @static
  30222. * @memberOf _
  30223. * @since 3.0.0
  30224. * @category String
  30225. * @param {string} [string=''] The string to escape.
  30226. * @returns {string} Returns the escaped string.
  30227. * @example
  30228. *
  30229. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30230. * // => '\[lodash\]\(https://lodash\.com/\)'
  30231. */
  30232. function escapeRegExp(string) {
  30233. string = toString(string);
  30234. return (string && reHasRegExpChar.test(string))
  30235. ? string.replace(reRegExpChar, '\\$&')
  30236. : string;
  30237. }
  30238. /**
  30239. * Converts `string` to
  30240. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30241. *
  30242. * @static
  30243. * @memberOf _
  30244. * @since 3.0.0
  30245. * @category String
  30246. * @param {string} [string=''] The string to convert.
  30247. * @returns {string} Returns the kebab cased string.
  30248. * @example
  30249. *
  30250. * _.kebabCase('Foo Bar');
  30251. * // => 'foo-bar'
  30252. *
  30253. * _.kebabCase('fooBar');
  30254. * // => 'foo-bar'
  30255. *
  30256. * _.kebabCase('__FOO_BAR__');
  30257. * // => 'foo-bar'
  30258. */
  30259. var kebabCase = createCompounder(function(result, word, index) {
  30260. return result + (index ? '-' : '') + word.toLowerCase();
  30261. });
  30262. /**
  30263. * Converts `string`, as space separated words, to lower case.
  30264. *
  30265. * @static
  30266. * @memberOf _
  30267. * @since 4.0.0
  30268. * @category String
  30269. * @param {string} [string=''] The string to convert.
  30270. * @returns {string} Returns the lower cased string.
  30271. * @example
  30272. *
  30273. * _.lowerCase('--Foo-Bar--');
  30274. * // => 'foo bar'
  30275. *
  30276. * _.lowerCase('fooBar');
  30277. * // => 'foo bar'
  30278. *
  30279. * _.lowerCase('__FOO_BAR__');
  30280. * // => 'foo bar'
  30281. */
  30282. var lowerCase = createCompounder(function(result, word, index) {
  30283. return result + (index ? ' ' : '') + word.toLowerCase();
  30284. });
  30285. /**
  30286. * Converts the first character of `string` to lower case.
  30287. *
  30288. * @static
  30289. * @memberOf _
  30290. * @since 4.0.0
  30291. * @category String
  30292. * @param {string} [string=''] The string to convert.
  30293. * @returns {string} Returns the converted string.
  30294. * @example
  30295. *
  30296. * _.lowerFirst('Fred');
  30297. * // => 'fred'
  30298. *
  30299. * _.lowerFirst('FRED');
  30300. * // => 'fRED'
  30301. */
  30302. var lowerFirst = createCaseFirst('toLowerCase');
  30303. /**
  30304. * Pads `string` on the left and right sides if it's shorter than `length`.
  30305. * Padding characters are truncated if they can't be evenly divided by `length`.
  30306. *
  30307. * @static
  30308. * @memberOf _
  30309. * @since 3.0.0
  30310. * @category String
  30311. * @param {string} [string=''] The string to pad.
  30312. * @param {number} [length=0] The padding length.
  30313. * @param {string} [chars=' '] The string used as padding.
  30314. * @returns {string} Returns the padded string.
  30315. * @example
  30316. *
  30317. * _.pad('abc', 8);
  30318. * // => ' abc '
  30319. *
  30320. * _.pad('abc', 8, '_-');
  30321. * // => '_-abc_-_'
  30322. *
  30323. * _.pad('abc', 3);
  30324. * // => 'abc'
  30325. */
  30326. function pad(string, length, chars) {
  30327. string = toString(string);
  30328. length = toInteger(length);
  30329. var strLength = length ? stringSize(string) : 0;
  30330. if (!length || strLength >= length) {
  30331. return string;
  30332. }
  30333. var mid = (length - strLength) / 2;
  30334. return (
  30335. createPadding(nativeFloor(mid), chars) +
  30336. string +
  30337. createPadding(nativeCeil(mid), chars)
  30338. );
  30339. }
  30340. /**
  30341. * Pads `string` on the right side if it's shorter than `length`. Padding
  30342. * characters are truncated if they exceed `length`.
  30343. *
  30344. * @static
  30345. * @memberOf _
  30346. * @since 4.0.0
  30347. * @category String
  30348. * @param {string} [string=''] The string to pad.
  30349. * @param {number} [length=0] The padding length.
  30350. * @param {string} [chars=' '] The string used as padding.
  30351. * @returns {string} Returns the padded string.
  30352. * @example
  30353. *
  30354. * _.padEnd('abc', 6);
  30355. * // => 'abc '
  30356. *
  30357. * _.padEnd('abc', 6, '_-');
  30358. * // => 'abc_-_'
  30359. *
  30360. * _.padEnd('abc', 3);
  30361. * // => 'abc'
  30362. */
  30363. function padEnd(string, length, chars) {
  30364. string = toString(string);
  30365. length = toInteger(length);
  30366. var strLength = length ? stringSize(string) : 0;
  30367. return (length && strLength < length)
  30368. ? (string + createPadding(length - strLength, chars))
  30369. : string;
  30370. }
  30371. /**
  30372. * Pads `string` on the left side if it's shorter than `length`. Padding
  30373. * characters are truncated if they exceed `length`.
  30374. *
  30375. * @static
  30376. * @memberOf _
  30377. * @since 4.0.0
  30378. * @category String
  30379. * @param {string} [string=''] The string to pad.
  30380. * @param {number} [length=0] The padding length.
  30381. * @param {string} [chars=' '] The string used as padding.
  30382. * @returns {string} Returns the padded string.
  30383. * @example
  30384. *
  30385. * _.padStart('abc', 6);
  30386. * // => ' abc'
  30387. *
  30388. * _.padStart('abc', 6, '_-');
  30389. * // => '_-_abc'
  30390. *
  30391. * _.padStart('abc', 3);
  30392. * // => 'abc'
  30393. */
  30394. function padStart(string, length, chars) {
  30395. string = toString(string);
  30396. length = toInteger(length);
  30397. var strLength = length ? stringSize(string) : 0;
  30398. return (length && strLength < length)
  30399. ? (createPadding(length - strLength, chars) + string)
  30400. : string;
  30401. }
  30402. /**
  30403. * Converts `string` to an integer of the specified radix. If `radix` is
  30404. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30405. * hexadecimal, in which case a `radix` of `16` is used.
  30406. *
  30407. * **Note:** This method aligns with the
  30408. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30409. *
  30410. * @static
  30411. * @memberOf _
  30412. * @since 1.1.0
  30413. * @category String
  30414. * @param {string} string The string to convert.
  30415. * @param {number} [radix=10] The radix to interpret `value` by.
  30416. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30417. * @returns {number} Returns the converted integer.
  30418. * @example
  30419. *
  30420. * _.parseInt('08');
  30421. * // => 8
  30422. *
  30423. * _.map(['6', '08', '10'], _.parseInt);
  30424. * // => [6, 8, 10]
  30425. */
  30426. function parseInt(string, radix, guard) {
  30427. if (guard || radix == null) {
  30428. radix = 0;
  30429. } else if (radix) {
  30430. radix = +radix;
  30431. }
  30432. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30433. }
  30434. /**
  30435. * Repeats the given string `n` times.
  30436. *
  30437. * @static
  30438. * @memberOf _
  30439. * @since 3.0.0
  30440. * @category String
  30441. * @param {string} [string=''] The string to repeat.
  30442. * @param {number} [n=1] The number of times to repeat the string.
  30443. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30444. * @returns {string} Returns the repeated string.
  30445. * @example
  30446. *
  30447. * _.repeat('*', 3);
  30448. * // => '***'
  30449. *
  30450. * _.repeat('abc', 2);
  30451. * // => 'abcabc'
  30452. *
  30453. * _.repeat('abc', 0);
  30454. * // => ''
  30455. */
  30456. function repeat(string, n, guard) {
  30457. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30458. n = 1;
  30459. } else {
  30460. n = toInteger(n);
  30461. }
  30462. return baseRepeat(toString(string), n);
  30463. }
  30464. /**
  30465. * Replaces matches for `pattern` in `string` with `replacement`.
  30466. *
  30467. * **Note:** This method is based on
  30468. * [`String#replace`](https://mdn.io/String/replace).
  30469. *
  30470. * @static
  30471. * @memberOf _
  30472. * @since 4.0.0
  30473. * @category String
  30474. * @param {string} [string=''] The string to modify.
  30475. * @param {RegExp|string} pattern The pattern to replace.
  30476. * @param {Function|string} replacement The match replacement.
  30477. * @returns {string} Returns the modified string.
  30478. * @example
  30479. *
  30480. * _.replace('Hi Fred', 'Fred', 'Barney');
  30481. * // => 'Hi Barney'
  30482. */
  30483. function replace() {
  30484. var args = arguments,
  30485. string = toString(args[0]);
  30486. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30487. }
  30488. /**
  30489. * Converts `string` to
  30490. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30491. *
  30492. * @static
  30493. * @memberOf _
  30494. * @since 3.0.0
  30495. * @category String
  30496. * @param {string} [string=''] The string to convert.
  30497. * @returns {string} Returns the snake cased string.
  30498. * @example
  30499. *
  30500. * _.snakeCase('Foo Bar');
  30501. * // => 'foo_bar'
  30502. *
  30503. * _.snakeCase('fooBar');
  30504. * // => 'foo_bar'
  30505. *
  30506. * _.snakeCase('--FOO-BAR--');
  30507. * // => 'foo_bar'
  30508. */
  30509. var snakeCase = createCompounder(function(result, word, index) {
  30510. return result + (index ? '_' : '') + word.toLowerCase();
  30511. });
  30512. /**
  30513. * Splits `string` by `separator`.
  30514. *
  30515. * **Note:** This method is based on
  30516. * [`String#split`](https://mdn.io/String/split).
  30517. *
  30518. * @static
  30519. * @memberOf _
  30520. * @since 4.0.0
  30521. * @category String
  30522. * @param {string} [string=''] The string to split.
  30523. * @param {RegExp|string} separator The separator pattern to split by.
  30524. * @param {number} [limit] The length to truncate results to.
  30525. * @returns {Array} Returns the string segments.
  30526. * @example
  30527. *
  30528. * _.split('a-b-c', '-', 2);
  30529. * // => ['a', 'b']
  30530. */
  30531. function split(string, separator, limit) {
  30532. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30533. separator = limit = undefined;
  30534. }
  30535. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30536. if (!limit) {
  30537. return [];
  30538. }
  30539. string = toString(string);
  30540. if (string && (
  30541. typeof separator == 'string' ||
  30542. (separator != null && !isRegExp(separator))
  30543. )) {
  30544. separator = baseToString(separator);
  30545. if (!separator && hasUnicode(string)) {
  30546. return castSlice(stringToArray(string), 0, limit);
  30547. }
  30548. }
  30549. return string.split(separator, limit);
  30550. }
  30551. /**
  30552. * Converts `string` to
  30553. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30554. *
  30555. * @static
  30556. * @memberOf _
  30557. * @since 3.1.0
  30558. * @category String
  30559. * @param {string} [string=''] The string to convert.
  30560. * @returns {string} Returns the start cased string.
  30561. * @example
  30562. *
  30563. * _.startCase('--foo-bar--');
  30564. * // => 'Foo Bar'
  30565. *
  30566. * _.startCase('fooBar');
  30567. * // => 'Foo Bar'
  30568. *
  30569. * _.startCase('__FOO_BAR__');
  30570. * // => 'FOO BAR'
  30571. */
  30572. var startCase = createCompounder(function(result, word, index) {
  30573. return result + (index ? ' ' : '') + upperFirst(word);
  30574. });
  30575. /**
  30576. * Checks if `string` starts with the given target string.
  30577. *
  30578. * @static
  30579. * @memberOf _
  30580. * @since 3.0.0
  30581. * @category String
  30582. * @param {string} [string=''] The string to inspect.
  30583. * @param {string} [target] The string to search for.
  30584. * @param {number} [position=0] The position to search from.
  30585. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30586. * else `false`.
  30587. * @example
  30588. *
  30589. * _.startsWith('abc', 'a');
  30590. * // => true
  30591. *
  30592. * _.startsWith('abc', 'b');
  30593. * // => false
  30594. *
  30595. * _.startsWith('abc', 'b', 1);
  30596. * // => true
  30597. */
  30598. function startsWith(string, target, position) {
  30599. string = toString(string);
  30600. position = position == null
  30601. ? 0
  30602. : baseClamp(toInteger(position), 0, string.length);
  30603. target = baseToString(target);
  30604. return string.slice(position, position + target.length) == target;
  30605. }
  30606. /**
  30607. * Creates a compiled template function that can interpolate data properties
  30608. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30609. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30610. * properties may be accessed as free variables in the template. If a setting
  30611. * object is given, it takes precedence over `_.templateSettings` values.
  30612. *
  30613. * **Note:** In the development build `_.template` utilizes
  30614. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30615. * for easier debugging.
  30616. *
  30617. * For more information on precompiling templates see
  30618. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30619. *
  30620. * For more information on Chrome extension sandboxes see
  30621. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30622. *
  30623. * @static
  30624. * @since 0.1.0
  30625. * @memberOf _
  30626. * @category String
  30627. * @param {string} [string=''] The template string.
  30628. * @param {Object} [options={}] The options object.
  30629. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30630. * The HTML "escape" delimiter.
  30631. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30632. * The "evaluate" delimiter.
  30633. * @param {Object} [options.imports=_.templateSettings.imports]
  30634. * An object to import into the template as free variables.
  30635. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30636. * The "interpolate" delimiter.
  30637. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30638. * The sourceURL of the compiled template.
  30639. * @param {string} [options.variable='obj']
  30640. * The data object variable name.
  30641. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30642. * @returns {Function} Returns the compiled template function.
  30643. * @example
  30644. *
  30645. * // Use the "interpolate" delimiter to create a compiled template.
  30646. * var compiled = _.template('hello <%= user %>!');
  30647. * compiled({ 'user': 'fred' });
  30648. * // => 'hello fred!'
  30649. *
  30650. * // Use the HTML "escape" delimiter to escape data property values.
  30651. * var compiled = _.template('<b><%- value %></b>');
  30652. * compiled({ 'value': '<script>' });
  30653. * // => '<b>&lt;script&gt;</b>'
  30654. *
  30655. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30656. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30657. * compiled({ 'users': ['fred', 'barney'] });
  30658. * // => '<li>fred</li><li>barney</li>'
  30659. *
  30660. * // Use the internal `print` function in "evaluate" delimiters.
  30661. * var compiled = _.template('<% print("hello " + user); %>!');
  30662. * compiled({ 'user': 'barney' });
  30663. * // => 'hello barney!'
  30664. *
  30665. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30666. * // Disable support by replacing the "interpolate" delimiter.
  30667. * var compiled = _.template('hello ${ user }!');
  30668. * compiled({ 'user': 'pebbles' });
  30669. * // => 'hello pebbles!'
  30670. *
  30671. * // Use backslashes to treat delimiters as plain text.
  30672. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30673. * compiled({ 'value': 'ignored' });
  30674. * // => '<%- value %>'
  30675. *
  30676. * // Use the `imports` option to import `jQuery` as `jq`.
  30677. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30678. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30679. * compiled({ 'users': ['fred', 'barney'] });
  30680. * // => '<li>fred</li><li>barney</li>'
  30681. *
  30682. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30683. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30684. * compiled(data);
  30685. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30686. *
  30687. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30688. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30689. * compiled.source;
  30690. * // => function(data) {
  30691. * // var __t, __p = '';
  30692. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30693. * // return __p;
  30694. * // }
  30695. *
  30696. * // Use custom template delimiters.
  30697. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30698. * var compiled = _.template('hello {{ user }}!');
  30699. * compiled({ 'user': 'mustache' });
  30700. * // => 'hello mustache!'
  30701. *
  30702. * // Use the `source` property to inline compiled templates for meaningful
  30703. * // line numbers in error messages and stack traces.
  30704. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30705. * var JST = {\
  30706. * "main": ' + _.template(mainText).source + '\
  30707. * };\
  30708. * ');
  30709. */
  30710. function template(string, options, guard) {
  30711. // Based on John Resig's `tmpl` implementation
  30712. // (http://ejohn.org/blog/javascript-micro-templating/)
  30713. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30714. var settings = lodash.templateSettings;
  30715. if (guard && isIterateeCall(string, options, guard)) {
  30716. options = undefined;
  30717. }
  30718. string = toString(string);
  30719. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30720. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30721. importsKeys = keys(imports),
  30722. importsValues = baseValues(imports, importsKeys);
  30723. var isEscaping,
  30724. isEvaluating,
  30725. index = 0,
  30726. interpolate = options.interpolate || reNoMatch,
  30727. source = "__p += '";
  30728. // Compile the regexp to match each delimiter.
  30729. var reDelimiters = RegExp(
  30730. (options.escape || reNoMatch).source + '|' +
  30731. interpolate.source + '|' +
  30732. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30733. (options.evaluate || reNoMatch).source + '|$'
  30734. , 'g');
  30735. // Use a sourceURL for easier debugging.
  30736. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30737. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30738. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30739. var sourceURL = '//# sourceURL=' +
  30740. (hasOwnProperty.call(options, 'sourceURL')
  30741. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30742. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30743. ) + '\n';
  30744. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30745. interpolateValue || (interpolateValue = esTemplateValue);
  30746. // Escape characters that can't be included in string literals.
  30747. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30748. // Replace delimiters with snippets.
  30749. if (escapeValue) {
  30750. isEscaping = true;
  30751. source += "' +\n__e(" + escapeValue + ") +\n'";
  30752. }
  30753. if (evaluateValue) {
  30754. isEvaluating = true;
  30755. source += "';\n" + evaluateValue + ";\n__p += '";
  30756. }
  30757. if (interpolateValue) {
  30758. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30759. }
  30760. index = offset + match.length;
  30761. // The JS engine embedded in Adobe products needs `match` returned in
  30762. // order to produce the correct `offset` value.
  30763. return match;
  30764. });
  30765. source += "';\n";
  30766. // If `variable` is not specified wrap a with-statement around the generated
  30767. // code to add the data object to the top of the scope chain.
  30768. // Like with sourceURL, we take care to not check the option's prototype,
  30769. // as this configuration is a code injection vector.
  30770. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30771. if (!variable) {
  30772. source = 'with (obj) {\n' + source + '\n}\n';
  30773. }
  30774. // Cleanup code by stripping empty strings.
  30775. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30776. .replace(reEmptyStringMiddle, '$1')
  30777. .replace(reEmptyStringTrailing, '$1;');
  30778. // Frame code as the function body.
  30779. source = 'function(' + (variable || 'obj') + ') {\n' +
  30780. (variable
  30781. ? ''
  30782. : 'obj || (obj = {});\n'
  30783. ) +
  30784. "var __t, __p = ''" +
  30785. (isEscaping
  30786. ? ', __e = _.escape'
  30787. : ''
  30788. ) +
  30789. (isEvaluating
  30790. ? ', __j = Array.prototype.join;\n' +
  30791. "function print() { __p += __j.call(arguments, '') }\n"
  30792. : ';\n'
  30793. ) +
  30794. source +
  30795. 'return __p\n}';
  30796. var result = attempt(function() {
  30797. return Function(importsKeys, sourceURL + 'return ' + source)
  30798. .apply(undefined, importsValues);
  30799. });
  30800. // Provide the compiled function's source by its `toString` method or
  30801. // the `source` property as a convenience for inlining compiled templates.
  30802. result.source = source;
  30803. if (isError(result)) {
  30804. throw result;
  30805. }
  30806. return result;
  30807. }
  30808. /**
  30809. * Converts `string`, as a whole, to lower case just like
  30810. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30811. *
  30812. * @static
  30813. * @memberOf _
  30814. * @since 4.0.0
  30815. * @category String
  30816. * @param {string} [string=''] The string to convert.
  30817. * @returns {string} Returns the lower cased string.
  30818. * @example
  30819. *
  30820. * _.toLower('--Foo-Bar--');
  30821. * // => '--foo-bar--'
  30822. *
  30823. * _.toLower('fooBar');
  30824. * // => 'foobar'
  30825. *
  30826. * _.toLower('__FOO_BAR__');
  30827. * // => '__foo_bar__'
  30828. */
  30829. function toLower(value) {
  30830. return toString(value).toLowerCase();
  30831. }
  30832. /**
  30833. * Converts `string`, as a whole, to upper case just like
  30834. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30835. *
  30836. * @static
  30837. * @memberOf _
  30838. * @since 4.0.0
  30839. * @category String
  30840. * @param {string} [string=''] The string to convert.
  30841. * @returns {string} Returns the upper cased string.
  30842. * @example
  30843. *
  30844. * _.toUpper('--foo-bar--');
  30845. * // => '--FOO-BAR--'
  30846. *
  30847. * _.toUpper('fooBar');
  30848. * // => 'FOOBAR'
  30849. *
  30850. * _.toUpper('__foo_bar__');
  30851. * // => '__FOO_BAR__'
  30852. */
  30853. function toUpper(value) {
  30854. return toString(value).toUpperCase();
  30855. }
  30856. /**
  30857. * Removes leading and trailing whitespace or specified characters from `string`.
  30858. *
  30859. * @static
  30860. * @memberOf _
  30861. * @since 3.0.0
  30862. * @category String
  30863. * @param {string} [string=''] The string to trim.
  30864. * @param {string} [chars=whitespace] The characters to trim.
  30865. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30866. * @returns {string} Returns the trimmed string.
  30867. * @example
  30868. *
  30869. * _.trim(' abc ');
  30870. * // => 'abc'
  30871. *
  30872. * _.trim('-_-abc-_-', '_-');
  30873. * // => 'abc'
  30874. *
  30875. * _.map([' foo ', ' bar '], _.trim);
  30876. * // => ['foo', 'bar']
  30877. */
  30878. function trim(string, chars, guard) {
  30879. string = toString(string);
  30880. if (string && (guard || chars === undefined)) {
  30881. return string.replace(reTrim, '');
  30882. }
  30883. if (!string || !(chars = baseToString(chars))) {
  30884. return string;
  30885. }
  30886. var strSymbols = stringToArray(string),
  30887. chrSymbols = stringToArray(chars),
  30888. start = charsStartIndex(strSymbols, chrSymbols),
  30889. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30890. return castSlice(strSymbols, start, end).join('');
  30891. }
  30892. /**
  30893. * Removes trailing whitespace or specified characters from `string`.
  30894. *
  30895. * @static
  30896. * @memberOf _
  30897. * @since 4.0.0
  30898. * @category String
  30899. * @param {string} [string=''] The string to trim.
  30900. * @param {string} [chars=whitespace] The characters to trim.
  30901. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30902. * @returns {string} Returns the trimmed string.
  30903. * @example
  30904. *
  30905. * _.trimEnd(' abc ');
  30906. * // => ' abc'
  30907. *
  30908. * _.trimEnd('-_-abc-_-', '_-');
  30909. * // => '-_-abc'
  30910. */
  30911. function trimEnd(string, chars, guard) {
  30912. string = toString(string);
  30913. if (string && (guard || chars === undefined)) {
  30914. return string.replace(reTrimEnd, '');
  30915. }
  30916. if (!string || !(chars = baseToString(chars))) {
  30917. return string;
  30918. }
  30919. var strSymbols = stringToArray(string),
  30920. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30921. return castSlice(strSymbols, 0, end).join('');
  30922. }
  30923. /**
  30924. * Removes leading whitespace or specified characters from `string`.
  30925. *
  30926. * @static
  30927. * @memberOf _
  30928. * @since 4.0.0
  30929. * @category String
  30930. * @param {string} [string=''] The string to trim.
  30931. * @param {string} [chars=whitespace] The characters to trim.
  30932. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30933. * @returns {string} Returns the trimmed string.
  30934. * @example
  30935. *
  30936. * _.trimStart(' abc ');
  30937. * // => 'abc '
  30938. *
  30939. * _.trimStart('-_-abc-_-', '_-');
  30940. * // => 'abc-_-'
  30941. */
  30942. function trimStart(string, chars, guard) {
  30943. string = toString(string);
  30944. if (string && (guard || chars === undefined)) {
  30945. return string.replace(reTrimStart, '');
  30946. }
  30947. if (!string || !(chars = baseToString(chars))) {
  30948. return string;
  30949. }
  30950. var strSymbols = stringToArray(string),
  30951. start = charsStartIndex(strSymbols, stringToArray(chars));
  30952. return castSlice(strSymbols, start).join('');
  30953. }
  30954. /**
  30955. * Truncates `string` if it's longer than the given maximum string length.
  30956. * The last characters of the truncated string are replaced with the omission
  30957. * string which defaults to "...".
  30958. *
  30959. * @static
  30960. * @memberOf _
  30961. * @since 4.0.0
  30962. * @category String
  30963. * @param {string} [string=''] The string to truncate.
  30964. * @param {Object} [options={}] The options object.
  30965. * @param {number} [options.length=30] The maximum string length.
  30966. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  30967. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  30968. * @returns {string} Returns the truncated string.
  30969. * @example
  30970. *
  30971. * _.truncate('hi-diddly-ho there, neighborino');
  30972. * // => 'hi-diddly-ho there, neighbo...'
  30973. *
  30974. * _.truncate('hi-diddly-ho there, neighborino', {
  30975. * 'length': 24,
  30976. * 'separator': ' '
  30977. * });
  30978. * // => 'hi-diddly-ho there,...'
  30979. *
  30980. * _.truncate('hi-diddly-ho there, neighborino', {
  30981. * 'length': 24,
  30982. * 'separator': /,? +/
  30983. * });
  30984. * // => 'hi-diddly-ho there...'
  30985. *
  30986. * _.truncate('hi-diddly-ho there, neighborino', {
  30987. * 'omission': ' [...]'
  30988. * });
  30989. * // => 'hi-diddly-ho there, neig [...]'
  30990. */
  30991. function truncate(string, options) {
  30992. var length = DEFAULT_TRUNC_LENGTH,
  30993. omission = DEFAULT_TRUNC_OMISSION;
  30994. if (isObject(options)) {
  30995. var separator = 'separator' in options ? options.separator : separator;
  30996. length = 'length' in options ? toInteger(options.length) : length;
  30997. omission = 'omission' in options ? baseToString(options.omission) : omission;
  30998. }
  30999. string = toString(string);
  31000. var strLength = string.length;
  31001. if (hasUnicode(string)) {
  31002. var strSymbols = stringToArray(string);
  31003. strLength = strSymbols.length;
  31004. }
  31005. if (length >= strLength) {
  31006. return string;
  31007. }
  31008. var end = length - stringSize(omission);
  31009. if (end < 1) {
  31010. return omission;
  31011. }
  31012. var result = strSymbols
  31013. ? castSlice(strSymbols, 0, end).join('')
  31014. : string.slice(0, end);
  31015. if (separator === undefined) {
  31016. return result + omission;
  31017. }
  31018. if (strSymbols) {
  31019. end += (result.length - end);
  31020. }
  31021. if (isRegExp(separator)) {
  31022. if (string.slice(end).search(separator)) {
  31023. var match,
  31024. substring = result;
  31025. if (!separator.global) {
  31026. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31027. }
  31028. separator.lastIndex = 0;
  31029. while ((match = separator.exec(substring))) {
  31030. var newEnd = match.index;
  31031. }
  31032. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31033. }
  31034. } else if (string.indexOf(baseToString(separator), end) != end) {
  31035. var index = result.lastIndexOf(separator);
  31036. if (index > -1) {
  31037. result = result.slice(0, index);
  31038. }
  31039. }
  31040. return result + omission;
  31041. }
  31042. /**
  31043. * The inverse of `_.escape`; this method converts the HTML entities
  31044. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31045. * their corresponding characters.
  31046. *
  31047. * **Note:** No other HTML entities are unescaped. To unescape additional
  31048. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31049. *
  31050. * @static
  31051. * @memberOf _
  31052. * @since 0.6.0
  31053. * @category String
  31054. * @param {string} [string=''] The string to unescape.
  31055. * @returns {string} Returns the unescaped string.
  31056. * @example
  31057. *
  31058. * _.unescape('fred, barney, &amp; pebbles');
  31059. * // => 'fred, barney, & pebbles'
  31060. */
  31061. function unescape(string) {
  31062. string = toString(string);
  31063. return (string && reHasEscapedHtml.test(string))
  31064. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31065. : string;
  31066. }
  31067. /**
  31068. * Converts `string`, as space separated words, to upper case.
  31069. *
  31070. * @static
  31071. * @memberOf _
  31072. * @since 4.0.0
  31073. * @category String
  31074. * @param {string} [string=''] The string to convert.
  31075. * @returns {string} Returns the upper cased string.
  31076. * @example
  31077. *
  31078. * _.upperCase('--foo-bar');
  31079. * // => 'FOO BAR'
  31080. *
  31081. * _.upperCase('fooBar');
  31082. * // => 'FOO BAR'
  31083. *
  31084. * _.upperCase('__foo_bar__');
  31085. * // => 'FOO BAR'
  31086. */
  31087. var upperCase = createCompounder(function(result, word, index) {
  31088. return result + (index ? ' ' : '') + word.toUpperCase();
  31089. });
  31090. /**
  31091. * Converts the first character of `string` to upper case.
  31092. *
  31093. * @static
  31094. * @memberOf _
  31095. * @since 4.0.0
  31096. * @category String
  31097. * @param {string} [string=''] The string to convert.
  31098. * @returns {string} Returns the converted string.
  31099. * @example
  31100. *
  31101. * _.upperFirst('fred');
  31102. * // => 'Fred'
  31103. *
  31104. * _.upperFirst('FRED');
  31105. * // => 'FRED'
  31106. */
  31107. var upperFirst = createCaseFirst('toUpperCase');
  31108. /**
  31109. * Splits `string` into an array of its words.
  31110. *
  31111. * @static
  31112. * @memberOf _
  31113. * @since 3.0.0
  31114. * @category String
  31115. * @param {string} [string=''] The string to inspect.
  31116. * @param {RegExp|string} [pattern] The pattern to match words.
  31117. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31118. * @returns {Array} Returns the words of `string`.
  31119. * @example
  31120. *
  31121. * _.words('fred, barney, & pebbles');
  31122. * // => ['fred', 'barney', 'pebbles']
  31123. *
  31124. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31125. * // => ['fred', 'barney', '&', 'pebbles']
  31126. */
  31127. function words(string, pattern, guard) {
  31128. string = toString(string);
  31129. pattern = guard ? undefined : pattern;
  31130. if (pattern === undefined) {
  31131. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31132. }
  31133. return string.match(pattern) || [];
  31134. }
  31135. /*------------------------------------------------------------------------*/
  31136. /**
  31137. * Attempts to invoke `func`, returning either the result or the caught error
  31138. * object. Any additional arguments are provided to `func` when it's invoked.
  31139. *
  31140. * @static
  31141. * @memberOf _
  31142. * @since 3.0.0
  31143. * @category Util
  31144. * @param {Function} func The function to attempt.
  31145. * @param {...*} [args] The arguments to invoke `func` with.
  31146. * @returns {*} Returns the `func` result or error object.
  31147. * @example
  31148. *
  31149. * // Avoid throwing errors for invalid selectors.
  31150. * var elements = _.attempt(function(selector) {
  31151. * return document.querySelectorAll(selector);
  31152. * }, '>_>');
  31153. *
  31154. * if (_.isError(elements)) {
  31155. * elements = [];
  31156. * }
  31157. */
  31158. var attempt = baseRest(function(func, args) {
  31159. try {
  31160. return apply(func, undefined, args);
  31161. } catch (e) {
  31162. return isError(e) ? e : new Error(e);
  31163. }
  31164. });
  31165. /**
  31166. * Binds methods of an object to the object itself, overwriting the existing
  31167. * method.
  31168. *
  31169. * **Note:** This method doesn't set the "length" property of bound functions.
  31170. *
  31171. * @static
  31172. * @since 0.1.0
  31173. * @memberOf _
  31174. * @category Util
  31175. * @param {Object} object The object to bind and assign the bound methods to.
  31176. * @param {...(string|string[])} methodNames The object method names to bind.
  31177. * @returns {Object} Returns `object`.
  31178. * @example
  31179. *
  31180. * var view = {
  31181. * 'label': 'docs',
  31182. * 'click': function() {
  31183. * console.log('clicked ' + this.label);
  31184. * }
  31185. * };
  31186. *
  31187. * _.bindAll(view, ['click']);
  31188. * jQuery(element).on('click', view.click);
  31189. * // => Logs 'clicked docs' when clicked.
  31190. */
  31191. var bindAll = flatRest(function(object, methodNames) {
  31192. arrayEach(methodNames, function(key) {
  31193. key = toKey(key);
  31194. baseAssignValue(object, key, bind(object[key], object));
  31195. });
  31196. return object;
  31197. });
  31198. /**
  31199. * Creates a function that iterates over `pairs` and invokes the corresponding
  31200. * function of the first predicate to return truthy. The predicate-function
  31201. * pairs are invoked with the `this` binding and arguments of the created
  31202. * function.
  31203. *
  31204. * @static
  31205. * @memberOf _
  31206. * @since 4.0.0
  31207. * @category Util
  31208. * @param {Array} pairs The predicate-function pairs.
  31209. * @returns {Function} Returns the new composite function.
  31210. * @example
  31211. *
  31212. * var func = _.cond([
  31213. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31214. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31215. * [_.stubTrue, _.constant('no match')]
  31216. * ]);
  31217. *
  31218. * func({ 'a': 1, 'b': 2 });
  31219. * // => 'matches A'
  31220. *
  31221. * func({ 'a': 0, 'b': 1 });
  31222. * // => 'matches B'
  31223. *
  31224. * func({ 'a': '1', 'b': '2' });
  31225. * // => 'no match'
  31226. */
  31227. function cond(pairs) {
  31228. var length = pairs == null ? 0 : pairs.length,
  31229. toIteratee = getIteratee();
  31230. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31231. if (typeof pair[1] != 'function') {
  31232. throw new TypeError(FUNC_ERROR_TEXT);
  31233. }
  31234. return [toIteratee(pair[0]), pair[1]];
  31235. });
  31236. return baseRest(function(args) {
  31237. var index = -1;
  31238. while (++index < length) {
  31239. var pair = pairs[index];
  31240. if (apply(pair[0], this, args)) {
  31241. return apply(pair[1], this, args);
  31242. }
  31243. }
  31244. });
  31245. }
  31246. /**
  31247. * Creates a function that invokes the predicate properties of `source` with
  31248. * the corresponding property values of a given object, returning `true` if
  31249. * all predicates return truthy, else `false`.
  31250. *
  31251. * **Note:** The created function is equivalent to `_.conformsTo` with
  31252. * `source` partially applied.
  31253. *
  31254. * @static
  31255. * @memberOf _
  31256. * @since 4.0.0
  31257. * @category Util
  31258. * @param {Object} source The object of property predicates to conform to.
  31259. * @returns {Function} Returns the new spec function.
  31260. * @example
  31261. *
  31262. * var objects = [
  31263. * { 'a': 2, 'b': 1 },
  31264. * { 'a': 1, 'b': 2 }
  31265. * ];
  31266. *
  31267. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31268. * // => [{ 'a': 1, 'b': 2 }]
  31269. */
  31270. function conforms(source) {
  31271. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31272. }
  31273. /**
  31274. * Creates a function that returns `value`.
  31275. *
  31276. * @static
  31277. * @memberOf _
  31278. * @since 2.4.0
  31279. * @category Util
  31280. * @param {*} value The value to return from the new function.
  31281. * @returns {Function} Returns the new constant function.
  31282. * @example
  31283. *
  31284. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31285. *
  31286. * console.log(objects);
  31287. * // => [{ 'a': 1 }, { 'a': 1 }]
  31288. *
  31289. * console.log(objects[0] === objects[1]);
  31290. * // => true
  31291. */
  31292. function constant(value) {
  31293. return function() {
  31294. return value;
  31295. };
  31296. }
  31297. /**
  31298. * Checks `value` to determine whether a default value should be returned in
  31299. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31300. * or `undefined`.
  31301. *
  31302. * @static
  31303. * @memberOf _
  31304. * @since 4.14.0
  31305. * @category Util
  31306. * @param {*} value The value to check.
  31307. * @param {*} defaultValue The default value.
  31308. * @returns {*} Returns the resolved value.
  31309. * @example
  31310. *
  31311. * _.defaultTo(1, 10);
  31312. * // => 1
  31313. *
  31314. * _.defaultTo(undefined, 10);
  31315. * // => 10
  31316. */
  31317. function defaultTo(value, defaultValue) {
  31318. return (value == null || value !== value) ? defaultValue : value;
  31319. }
  31320. /**
  31321. * Creates a function that returns the result of invoking the given functions
  31322. * with the `this` binding of the created function, where each successive
  31323. * invocation is supplied the return value of the previous.
  31324. *
  31325. * @static
  31326. * @memberOf _
  31327. * @since 3.0.0
  31328. * @category Util
  31329. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31330. * @returns {Function} Returns the new composite function.
  31331. * @see _.flowRight
  31332. * @example
  31333. *
  31334. * function square(n) {
  31335. * return n * n;
  31336. * }
  31337. *
  31338. * var addSquare = _.flow([_.add, square]);
  31339. * addSquare(1, 2);
  31340. * // => 9
  31341. */
  31342. var flow = createFlow();
  31343. /**
  31344. * This method is like `_.flow` except that it creates a function that
  31345. * invokes the given functions from right to left.
  31346. *
  31347. * @static
  31348. * @since 3.0.0
  31349. * @memberOf _
  31350. * @category Util
  31351. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31352. * @returns {Function} Returns the new composite function.
  31353. * @see _.flow
  31354. * @example
  31355. *
  31356. * function square(n) {
  31357. * return n * n;
  31358. * }
  31359. *
  31360. * var addSquare = _.flowRight([square, _.add]);
  31361. * addSquare(1, 2);
  31362. * // => 9
  31363. */
  31364. var flowRight = createFlow(true);
  31365. /**
  31366. * This method returns the first argument it receives.
  31367. *
  31368. * @static
  31369. * @since 0.1.0
  31370. * @memberOf _
  31371. * @category Util
  31372. * @param {*} value Any value.
  31373. * @returns {*} Returns `value`.
  31374. * @example
  31375. *
  31376. * var object = { 'a': 1 };
  31377. *
  31378. * console.log(_.identity(object) === object);
  31379. * // => true
  31380. */
  31381. function identity(value) {
  31382. return value;
  31383. }
  31384. /**
  31385. * Creates a function that invokes `func` with the arguments of the created
  31386. * function. If `func` is a property name, the created function returns the
  31387. * property value for a given element. If `func` is an array or object, the
  31388. * created function returns `true` for elements that contain the equivalent
  31389. * source properties, otherwise it returns `false`.
  31390. *
  31391. * @static
  31392. * @since 4.0.0
  31393. * @memberOf _
  31394. * @category Util
  31395. * @param {*} [func=_.identity] The value to convert to a callback.
  31396. * @returns {Function} Returns the callback.
  31397. * @example
  31398. *
  31399. * var users = [
  31400. * { 'user': 'barney', 'age': 36, 'active': true },
  31401. * { 'user': 'fred', 'age': 40, 'active': false }
  31402. * ];
  31403. *
  31404. * // The `_.matches` iteratee shorthand.
  31405. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31406. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31407. *
  31408. * // The `_.matchesProperty` iteratee shorthand.
  31409. * _.filter(users, _.iteratee(['user', 'fred']));
  31410. * // => [{ 'user': 'fred', 'age': 40 }]
  31411. *
  31412. * // The `_.property` iteratee shorthand.
  31413. * _.map(users, _.iteratee('user'));
  31414. * // => ['barney', 'fred']
  31415. *
  31416. * // Create custom iteratee shorthands.
  31417. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31418. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31419. * return func.test(string);
  31420. * };
  31421. * });
  31422. *
  31423. * _.filter(['abc', 'def'], /ef/);
  31424. * // => ['def']
  31425. */
  31426. function iteratee(func) {
  31427. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31428. }
  31429. /**
  31430. * Creates a function that performs a partial deep comparison between a given
  31431. * object and `source`, returning `true` if the given object has equivalent
  31432. * property values, else `false`.
  31433. *
  31434. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31435. * partially applied.
  31436. *
  31437. * Partial comparisons will match empty array and empty object `source`
  31438. * values against any array or object value, respectively. See `_.isEqual`
  31439. * for a list of supported value comparisons.
  31440. *
  31441. * @static
  31442. * @memberOf _
  31443. * @since 3.0.0
  31444. * @category Util
  31445. * @param {Object} source The object of property values to match.
  31446. * @returns {Function} Returns the new spec function.
  31447. * @example
  31448. *
  31449. * var objects = [
  31450. * { 'a': 1, 'b': 2, 'c': 3 },
  31451. * { 'a': 4, 'b': 5, 'c': 6 }
  31452. * ];
  31453. *
  31454. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31455. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31456. */
  31457. function matches(source) {
  31458. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31459. }
  31460. /**
  31461. * Creates a function that performs a partial deep comparison between the
  31462. * value at `path` of a given object to `srcValue`, returning `true` if the
  31463. * object value is equivalent, else `false`.
  31464. *
  31465. * **Note:** Partial comparisons will match empty array and empty object
  31466. * `srcValue` values against any array or object value, respectively. See
  31467. * `_.isEqual` for a list of supported value comparisons.
  31468. *
  31469. * @static
  31470. * @memberOf _
  31471. * @since 3.2.0
  31472. * @category Util
  31473. * @param {Array|string} path The path of the property to get.
  31474. * @param {*} srcValue The value to match.
  31475. * @returns {Function} Returns the new spec function.
  31476. * @example
  31477. *
  31478. * var objects = [
  31479. * { 'a': 1, 'b': 2, 'c': 3 },
  31480. * { 'a': 4, 'b': 5, 'c': 6 }
  31481. * ];
  31482. *
  31483. * _.find(objects, _.matchesProperty('a', 4));
  31484. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31485. */
  31486. function matchesProperty(path, srcValue) {
  31487. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31488. }
  31489. /**
  31490. * Creates a function that invokes the method at `path` of a given object.
  31491. * Any additional arguments are provided to the invoked method.
  31492. *
  31493. * @static
  31494. * @memberOf _
  31495. * @since 3.7.0
  31496. * @category Util
  31497. * @param {Array|string} path The path of the method to invoke.
  31498. * @param {...*} [args] The arguments to invoke the method with.
  31499. * @returns {Function} Returns the new invoker function.
  31500. * @example
  31501. *
  31502. * var objects = [
  31503. * { 'a': { 'b': _.constant(2) } },
  31504. * { 'a': { 'b': _.constant(1) } }
  31505. * ];
  31506. *
  31507. * _.map(objects, _.method('a.b'));
  31508. * // => [2, 1]
  31509. *
  31510. * _.map(objects, _.method(['a', 'b']));
  31511. * // => [2, 1]
  31512. */
  31513. var method = baseRest(function(path, args) {
  31514. return function(object) {
  31515. return baseInvoke(object, path, args);
  31516. };
  31517. });
  31518. /**
  31519. * The opposite of `_.method`; this method creates a function that invokes
  31520. * the method at a given path of `object`. Any additional arguments are
  31521. * provided to the invoked method.
  31522. *
  31523. * @static
  31524. * @memberOf _
  31525. * @since 3.7.0
  31526. * @category Util
  31527. * @param {Object} object The object to query.
  31528. * @param {...*} [args] The arguments to invoke the method with.
  31529. * @returns {Function} Returns the new invoker function.
  31530. * @example
  31531. *
  31532. * var array = _.times(3, _.constant),
  31533. * object = { 'a': array, 'b': array, 'c': array };
  31534. *
  31535. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31536. * // => [2, 0]
  31537. *
  31538. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31539. * // => [2, 0]
  31540. */
  31541. var methodOf = baseRest(function(object, args) {
  31542. return function(path) {
  31543. return baseInvoke(object, path, args);
  31544. };
  31545. });
  31546. /**
  31547. * Adds all own enumerable string keyed function properties of a source
  31548. * object to the destination object. If `object` is a function, then methods
  31549. * are added to its prototype as well.
  31550. *
  31551. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31552. * avoid conflicts caused by modifying the original.
  31553. *
  31554. * @static
  31555. * @since 0.1.0
  31556. * @memberOf _
  31557. * @category Util
  31558. * @param {Function|Object} [object=lodash] The destination object.
  31559. * @param {Object} source The object of functions to add.
  31560. * @param {Object} [options={}] The options object.
  31561. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31562. * @returns {Function|Object} Returns `object`.
  31563. * @example
  31564. *
  31565. * function vowels(string) {
  31566. * return _.filter(string, function(v) {
  31567. * return /[aeiou]/i.test(v);
  31568. * });
  31569. * }
  31570. *
  31571. * _.mixin({ 'vowels': vowels });
  31572. * _.vowels('fred');
  31573. * // => ['e']
  31574. *
  31575. * _('fred').vowels().value();
  31576. * // => ['e']
  31577. *
  31578. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31579. * _('fred').vowels();
  31580. * // => ['e']
  31581. */
  31582. function mixin(object, source, options) {
  31583. var props = keys(source),
  31584. methodNames = baseFunctions(source, props);
  31585. if (options == null &&
  31586. !(isObject(source) && (methodNames.length || !props.length))) {
  31587. options = source;
  31588. source = object;
  31589. object = this;
  31590. methodNames = baseFunctions(source, keys(source));
  31591. }
  31592. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31593. isFunc = isFunction(object);
  31594. arrayEach(methodNames, function(methodName) {
  31595. var func = source[methodName];
  31596. object[methodName] = func;
  31597. if (isFunc) {
  31598. object.prototype[methodName] = function() {
  31599. var chainAll = this.__chain__;
  31600. if (chain || chainAll) {
  31601. var result = object(this.__wrapped__),
  31602. actions = result.__actions__ = copyArray(this.__actions__);
  31603. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31604. result.__chain__ = chainAll;
  31605. return result;
  31606. }
  31607. return func.apply(object, arrayPush([this.value()], arguments));
  31608. };
  31609. }
  31610. });
  31611. return object;
  31612. }
  31613. /**
  31614. * Reverts the `_` variable to its previous value and returns a reference to
  31615. * the `lodash` function.
  31616. *
  31617. * @static
  31618. * @since 0.1.0
  31619. * @memberOf _
  31620. * @category Util
  31621. * @returns {Function} Returns the `lodash` function.
  31622. * @example
  31623. *
  31624. * var lodash = _.noConflict();
  31625. */
  31626. function noConflict() {
  31627. if (root._ === this) {
  31628. root._ = oldDash;
  31629. }
  31630. return this;
  31631. }
  31632. /**
  31633. * This method returns `undefined`.
  31634. *
  31635. * @static
  31636. * @memberOf _
  31637. * @since 2.3.0
  31638. * @category Util
  31639. * @example
  31640. *
  31641. * _.times(2, _.noop);
  31642. * // => [undefined, undefined]
  31643. */
  31644. function noop() {
  31645. // No operation performed.
  31646. }
  31647. /**
  31648. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31649. * the nth argument from the end is returned.
  31650. *
  31651. * @static
  31652. * @memberOf _
  31653. * @since 4.0.0
  31654. * @category Util
  31655. * @param {number} [n=0] The index of the argument to return.
  31656. * @returns {Function} Returns the new pass-thru function.
  31657. * @example
  31658. *
  31659. * var func = _.nthArg(1);
  31660. * func('a', 'b', 'c', 'd');
  31661. * // => 'b'
  31662. *
  31663. * var func = _.nthArg(-2);
  31664. * func('a', 'b', 'c', 'd');
  31665. * // => 'c'
  31666. */
  31667. function nthArg(n) {
  31668. n = toInteger(n);
  31669. return baseRest(function(args) {
  31670. return baseNth(args, n);
  31671. });
  31672. }
  31673. /**
  31674. * Creates a function that invokes `iteratees` with the arguments it receives
  31675. * and returns their results.
  31676. *
  31677. * @static
  31678. * @memberOf _
  31679. * @since 4.0.0
  31680. * @category Util
  31681. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31682. * The iteratees to invoke.
  31683. * @returns {Function} Returns the new function.
  31684. * @example
  31685. *
  31686. * var func = _.over([Math.max, Math.min]);
  31687. *
  31688. * func(1, 2, 3, 4);
  31689. * // => [4, 1]
  31690. */
  31691. var over = createOver(arrayMap);
  31692. /**
  31693. * Creates a function that checks if **all** of the `predicates` return
  31694. * truthy when invoked with the arguments it receives.
  31695. *
  31696. * @static
  31697. * @memberOf _
  31698. * @since 4.0.0
  31699. * @category Util
  31700. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31701. * The predicates to check.
  31702. * @returns {Function} Returns the new function.
  31703. * @example
  31704. *
  31705. * var func = _.overEvery([Boolean, isFinite]);
  31706. *
  31707. * func('1');
  31708. * // => true
  31709. *
  31710. * func(null);
  31711. * // => false
  31712. *
  31713. * func(NaN);
  31714. * // => false
  31715. */
  31716. var overEvery = createOver(arrayEvery);
  31717. /**
  31718. * Creates a function that checks if **any** of the `predicates` return
  31719. * truthy when invoked with the arguments it receives.
  31720. *
  31721. * @static
  31722. * @memberOf _
  31723. * @since 4.0.0
  31724. * @category Util
  31725. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31726. * The predicates to check.
  31727. * @returns {Function} Returns the new function.
  31728. * @example
  31729. *
  31730. * var func = _.overSome([Boolean, isFinite]);
  31731. *
  31732. * func('1');
  31733. * // => true
  31734. *
  31735. * func(null);
  31736. * // => true
  31737. *
  31738. * func(NaN);
  31739. * // => false
  31740. */
  31741. var overSome = createOver(arraySome);
  31742. /**
  31743. * Creates a function that returns the value at `path` of a given object.
  31744. *
  31745. * @static
  31746. * @memberOf _
  31747. * @since 2.4.0
  31748. * @category Util
  31749. * @param {Array|string} path The path of the property to get.
  31750. * @returns {Function} Returns the new accessor function.
  31751. * @example
  31752. *
  31753. * var objects = [
  31754. * { 'a': { 'b': 2 } },
  31755. * { 'a': { 'b': 1 } }
  31756. * ];
  31757. *
  31758. * _.map(objects, _.property('a.b'));
  31759. * // => [2, 1]
  31760. *
  31761. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31762. * // => [1, 2]
  31763. */
  31764. function property(path) {
  31765. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31766. }
  31767. /**
  31768. * The opposite of `_.property`; this method creates a function that returns
  31769. * the value at a given path of `object`.
  31770. *
  31771. * @static
  31772. * @memberOf _
  31773. * @since 3.0.0
  31774. * @category Util
  31775. * @param {Object} object The object to query.
  31776. * @returns {Function} Returns the new accessor function.
  31777. * @example
  31778. *
  31779. * var array = [0, 1, 2],
  31780. * object = { 'a': array, 'b': array, 'c': array };
  31781. *
  31782. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31783. * // => [2, 0]
  31784. *
  31785. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31786. * // => [2, 0]
  31787. */
  31788. function propertyOf(object) {
  31789. return function(path) {
  31790. return object == null ? undefined : baseGet(object, path);
  31791. };
  31792. }
  31793. /**
  31794. * Creates an array of numbers (positive and/or negative) progressing from
  31795. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31796. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31797. * it's set to `start` with `start` then set to `0`.
  31798. *
  31799. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31800. * floating-point values which can produce unexpected results.
  31801. *
  31802. * @static
  31803. * @since 0.1.0
  31804. * @memberOf _
  31805. * @category Util
  31806. * @param {number} [start=0] The start of the range.
  31807. * @param {number} end The end of the range.
  31808. * @param {number} [step=1] The value to increment or decrement by.
  31809. * @returns {Array} Returns the range of numbers.
  31810. * @see _.inRange, _.rangeRight
  31811. * @example
  31812. *
  31813. * _.range(4);
  31814. * // => [0, 1, 2, 3]
  31815. *
  31816. * _.range(-4);
  31817. * // => [0, -1, -2, -3]
  31818. *
  31819. * _.range(1, 5);
  31820. * // => [1, 2, 3, 4]
  31821. *
  31822. * _.range(0, 20, 5);
  31823. * // => [0, 5, 10, 15]
  31824. *
  31825. * _.range(0, -4, -1);
  31826. * // => [0, -1, -2, -3]
  31827. *
  31828. * _.range(1, 4, 0);
  31829. * // => [1, 1, 1]
  31830. *
  31831. * _.range(0);
  31832. * // => []
  31833. */
  31834. var range = createRange();
  31835. /**
  31836. * This method is like `_.range` except that it populates values in
  31837. * descending order.
  31838. *
  31839. * @static
  31840. * @memberOf _
  31841. * @since 4.0.0
  31842. * @category Util
  31843. * @param {number} [start=0] The start of the range.
  31844. * @param {number} end The end of the range.
  31845. * @param {number} [step=1] The value to increment or decrement by.
  31846. * @returns {Array} Returns the range of numbers.
  31847. * @see _.inRange, _.range
  31848. * @example
  31849. *
  31850. * _.rangeRight(4);
  31851. * // => [3, 2, 1, 0]
  31852. *
  31853. * _.rangeRight(-4);
  31854. * // => [-3, -2, -1, 0]
  31855. *
  31856. * _.rangeRight(1, 5);
  31857. * // => [4, 3, 2, 1]
  31858. *
  31859. * _.rangeRight(0, 20, 5);
  31860. * // => [15, 10, 5, 0]
  31861. *
  31862. * _.rangeRight(0, -4, -1);
  31863. * // => [-3, -2, -1, 0]
  31864. *
  31865. * _.rangeRight(1, 4, 0);
  31866. * // => [1, 1, 1]
  31867. *
  31868. * _.rangeRight(0);
  31869. * // => []
  31870. */
  31871. var rangeRight = createRange(true);
  31872. /**
  31873. * This method returns a new empty array.
  31874. *
  31875. * @static
  31876. * @memberOf _
  31877. * @since 4.13.0
  31878. * @category Util
  31879. * @returns {Array} Returns the new empty array.
  31880. * @example
  31881. *
  31882. * var arrays = _.times(2, _.stubArray);
  31883. *
  31884. * console.log(arrays);
  31885. * // => [[], []]
  31886. *
  31887. * console.log(arrays[0] === arrays[1]);
  31888. * // => false
  31889. */
  31890. function stubArray() {
  31891. return [];
  31892. }
  31893. /**
  31894. * This method returns `false`.
  31895. *
  31896. * @static
  31897. * @memberOf _
  31898. * @since 4.13.0
  31899. * @category Util
  31900. * @returns {boolean} Returns `false`.
  31901. * @example
  31902. *
  31903. * _.times(2, _.stubFalse);
  31904. * // => [false, false]
  31905. */
  31906. function stubFalse() {
  31907. return false;
  31908. }
  31909. /**
  31910. * This method returns a new empty object.
  31911. *
  31912. * @static
  31913. * @memberOf _
  31914. * @since 4.13.0
  31915. * @category Util
  31916. * @returns {Object} Returns the new empty object.
  31917. * @example
  31918. *
  31919. * var objects = _.times(2, _.stubObject);
  31920. *
  31921. * console.log(objects);
  31922. * // => [{}, {}]
  31923. *
  31924. * console.log(objects[0] === objects[1]);
  31925. * // => false
  31926. */
  31927. function stubObject() {
  31928. return {};
  31929. }
  31930. /**
  31931. * This method returns an empty string.
  31932. *
  31933. * @static
  31934. * @memberOf _
  31935. * @since 4.13.0
  31936. * @category Util
  31937. * @returns {string} Returns the empty string.
  31938. * @example
  31939. *
  31940. * _.times(2, _.stubString);
  31941. * // => ['', '']
  31942. */
  31943. function stubString() {
  31944. return '';
  31945. }
  31946. /**
  31947. * This method returns `true`.
  31948. *
  31949. * @static
  31950. * @memberOf _
  31951. * @since 4.13.0
  31952. * @category Util
  31953. * @returns {boolean} Returns `true`.
  31954. * @example
  31955. *
  31956. * _.times(2, _.stubTrue);
  31957. * // => [true, true]
  31958. */
  31959. function stubTrue() {
  31960. return true;
  31961. }
  31962. /**
  31963. * Invokes the iteratee `n` times, returning an array of the results of
  31964. * each invocation. The iteratee is invoked with one argument; (index).
  31965. *
  31966. * @static
  31967. * @since 0.1.0
  31968. * @memberOf _
  31969. * @category Util
  31970. * @param {number} n The number of times to invoke `iteratee`.
  31971. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  31972. * @returns {Array} Returns the array of results.
  31973. * @example
  31974. *
  31975. * _.times(3, String);
  31976. * // => ['0', '1', '2']
  31977. *
  31978. * _.times(4, _.constant(0));
  31979. * // => [0, 0, 0, 0]
  31980. */
  31981. function times(n, iteratee) {
  31982. n = toInteger(n);
  31983. if (n < 1 || n > MAX_SAFE_INTEGER) {
  31984. return [];
  31985. }
  31986. var index = MAX_ARRAY_LENGTH,
  31987. length = nativeMin(n, MAX_ARRAY_LENGTH);
  31988. iteratee = getIteratee(iteratee);
  31989. n -= MAX_ARRAY_LENGTH;
  31990. var result = baseTimes(length, iteratee);
  31991. while (++index < n) {
  31992. iteratee(index);
  31993. }
  31994. return result;
  31995. }
  31996. /**
  31997. * Converts `value` to a property path array.
  31998. *
  31999. * @static
  32000. * @memberOf _
  32001. * @since 4.0.0
  32002. * @category Util
  32003. * @param {*} value The value to convert.
  32004. * @returns {Array} Returns the new property path array.
  32005. * @example
  32006. *
  32007. * _.toPath('a.b.c');
  32008. * // => ['a', 'b', 'c']
  32009. *
  32010. * _.toPath('a[0].b.c');
  32011. * // => ['a', '0', 'b', 'c']
  32012. */
  32013. function toPath(value) {
  32014. if (isArray(value)) {
  32015. return arrayMap(value, toKey);
  32016. }
  32017. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32018. }
  32019. /**
  32020. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32021. *
  32022. * @static
  32023. * @since 0.1.0
  32024. * @memberOf _
  32025. * @category Util
  32026. * @param {string} [prefix=''] The value to prefix the ID with.
  32027. * @returns {string} Returns the unique ID.
  32028. * @example
  32029. *
  32030. * _.uniqueId('contact_');
  32031. * // => 'contact_104'
  32032. *
  32033. * _.uniqueId();
  32034. * // => '105'
  32035. */
  32036. function uniqueId(prefix) {
  32037. var id = ++idCounter;
  32038. return toString(prefix) + id;
  32039. }
  32040. /*------------------------------------------------------------------------*/
  32041. /**
  32042. * Adds two numbers.
  32043. *
  32044. * @static
  32045. * @memberOf _
  32046. * @since 3.4.0
  32047. * @category Math
  32048. * @param {number} augend The first number in an addition.
  32049. * @param {number} addend The second number in an addition.
  32050. * @returns {number} Returns the total.
  32051. * @example
  32052. *
  32053. * _.add(6, 4);
  32054. * // => 10
  32055. */
  32056. var add = createMathOperation(function(augend, addend) {
  32057. return augend + addend;
  32058. }, 0);
  32059. /**
  32060. * Computes `number` rounded up to `precision`.
  32061. *
  32062. * @static
  32063. * @memberOf _
  32064. * @since 3.10.0
  32065. * @category Math
  32066. * @param {number} number The number to round up.
  32067. * @param {number} [precision=0] The precision to round up to.
  32068. * @returns {number} Returns the rounded up number.
  32069. * @example
  32070. *
  32071. * _.ceil(4.006);
  32072. * // => 5
  32073. *
  32074. * _.ceil(6.004, 2);
  32075. * // => 6.01
  32076. *
  32077. * _.ceil(6040, -2);
  32078. * // => 6100
  32079. */
  32080. var ceil = createRound('ceil');
  32081. /**
  32082. * Divide two numbers.
  32083. *
  32084. * @static
  32085. * @memberOf _
  32086. * @since 4.7.0
  32087. * @category Math
  32088. * @param {number} dividend The first number in a division.
  32089. * @param {number} divisor The second number in a division.
  32090. * @returns {number} Returns the quotient.
  32091. * @example
  32092. *
  32093. * _.divide(6, 4);
  32094. * // => 1.5
  32095. */
  32096. var divide = createMathOperation(function(dividend, divisor) {
  32097. return dividend / divisor;
  32098. }, 1);
  32099. /**
  32100. * Computes `number` rounded down to `precision`.
  32101. *
  32102. * @static
  32103. * @memberOf _
  32104. * @since 3.10.0
  32105. * @category Math
  32106. * @param {number} number The number to round down.
  32107. * @param {number} [precision=0] The precision to round down to.
  32108. * @returns {number} Returns the rounded down number.
  32109. * @example
  32110. *
  32111. * _.floor(4.006);
  32112. * // => 4
  32113. *
  32114. * _.floor(0.046, 2);
  32115. * // => 0.04
  32116. *
  32117. * _.floor(4060, -2);
  32118. * // => 4000
  32119. */
  32120. var floor = createRound('floor');
  32121. /**
  32122. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32123. * `undefined` is returned.
  32124. *
  32125. * @static
  32126. * @since 0.1.0
  32127. * @memberOf _
  32128. * @category Math
  32129. * @param {Array} array The array to iterate over.
  32130. * @returns {*} Returns the maximum value.
  32131. * @example
  32132. *
  32133. * _.max([4, 2, 8, 6]);
  32134. * // => 8
  32135. *
  32136. * _.max([]);
  32137. * // => undefined
  32138. */
  32139. function max(array) {
  32140. return (array && array.length)
  32141. ? baseExtremum(array, identity, baseGt)
  32142. : undefined;
  32143. }
  32144. /**
  32145. * This method is like `_.max` except that it accepts `iteratee` which is
  32146. * invoked for each element in `array` to generate the criterion by which
  32147. * the value is ranked. The iteratee is invoked with one argument: (value).
  32148. *
  32149. * @static
  32150. * @memberOf _
  32151. * @since 4.0.0
  32152. * @category Math
  32153. * @param {Array} array The array to iterate over.
  32154. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32155. * @returns {*} Returns the maximum value.
  32156. * @example
  32157. *
  32158. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32159. *
  32160. * _.maxBy(objects, function(o) { return o.n; });
  32161. * // => { 'n': 2 }
  32162. *
  32163. * // The `_.property` iteratee shorthand.
  32164. * _.maxBy(objects, 'n');
  32165. * // => { 'n': 2 }
  32166. */
  32167. function maxBy(array, iteratee) {
  32168. return (array && array.length)
  32169. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32170. : undefined;
  32171. }
  32172. /**
  32173. * Computes the mean of the values in `array`.
  32174. *
  32175. * @static
  32176. * @memberOf _
  32177. * @since 4.0.0
  32178. * @category Math
  32179. * @param {Array} array The array to iterate over.
  32180. * @returns {number} Returns the mean.
  32181. * @example
  32182. *
  32183. * _.mean([4, 2, 8, 6]);
  32184. * // => 5
  32185. */
  32186. function mean(array) {
  32187. return baseMean(array, identity);
  32188. }
  32189. /**
  32190. * This method is like `_.mean` except that it accepts `iteratee` which is
  32191. * invoked for each element in `array` to generate the value to be averaged.
  32192. * The iteratee is invoked with one argument: (value).
  32193. *
  32194. * @static
  32195. * @memberOf _
  32196. * @since 4.7.0
  32197. * @category Math
  32198. * @param {Array} array The array to iterate over.
  32199. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32200. * @returns {number} Returns the mean.
  32201. * @example
  32202. *
  32203. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32204. *
  32205. * _.meanBy(objects, function(o) { return o.n; });
  32206. * // => 5
  32207. *
  32208. * // The `_.property` iteratee shorthand.
  32209. * _.meanBy(objects, 'n');
  32210. * // => 5
  32211. */
  32212. function meanBy(array, iteratee) {
  32213. return baseMean(array, getIteratee(iteratee, 2));
  32214. }
  32215. /**
  32216. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32217. * `undefined` is returned.
  32218. *
  32219. * @static
  32220. * @since 0.1.0
  32221. * @memberOf _
  32222. * @category Math
  32223. * @param {Array} array The array to iterate over.
  32224. * @returns {*} Returns the minimum value.
  32225. * @example
  32226. *
  32227. * _.min([4, 2, 8, 6]);
  32228. * // => 2
  32229. *
  32230. * _.min([]);
  32231. * // => undefined
  32232. */
  32233. function min(array) {
  32234. return (array && array.length)
  32235. ? baseExtremum(array, identity, baseLt)
  32236. : undefined;
  32237. }
  32238. /**
  32239. * This method is like `_.min` except that it accepts `iteratee` which is
  32240. * invoked for each element in `array` to generate the criterion by which
  32241. * the value is ranked. The iteratee is invoked with one argument: (value).
  32242. *
  32243. * @static
  32244. * @memberOf _
  32245. * @since 4.0.0
  32246. * @category Math
  32247. * @param {Array} array The array to iterate over.
  32248. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32249. * @returns {*} Returns the minimum value.
  32250. * @example
  32251. *
  32252. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32253. *
  32254. * _.minBy(objects, function(o) { return o.n; });
  32255. * // => { 'n': 1 }
  32256. *
  32257. * // The `_.property` iteratee shorthand.
  32258. * _.minBy(objects, 'n');
  32259. * // => { 'n': 1 }
  32260. */
  32261. function minBy(array, iteratee) {
  32262. return (array && array.length)
  32263. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32264. : undefined;
  32265. }
  32266. /**
  32267. * Multiply two numbers.
  32268. *
  32269. * @static
  32270. * @memberOf _
  32271. * @since 4.7.0
  32272. * @category Math
  32273. * @param {number} multiplier The first number in a multiplication.
  32274. * @param {number} multiplicand The second number in a multiplication.
  32275. * @returns {number} Returns the product.
  32276. * @example
  32277. *
  32278. * _.multiply(6, 4);
  32279. * // => 24
  32280. */
  32281. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32282. return multiplier * multiplicand;
  32283. }, 1);
  32284. /**
  32285. * Computes `number` rounded to `precision`.
  32286. *
  32287. * @static
  32288. * @memberOf _
  32289. * @since 3.10.0
  32290. * @category Math
  32291. * @param {number} number The number to round.
  32292. * @param {number} [precision=0] The precision to round to.
  32293. * @returns {number} Returns the rounded number.
  32294. * @example
  32295. *
  32296. * _.round(4.006);
  32297. * // => 4
  32298. *
  32299. * _.round(4.006, 2);
  32300. * // => 4.01
  32301. *
  32302. * _.round(4060, -2);
  32303. * // => 4100
  32304. */
  32305. var round = createRound('round');
  32306. /**
  32307. * Subtract two numbers.
  32308. *
  32309. * @static
  32310. * @memberOf _
  32311. * @since 4.0.0
  32312. * @category Math
  32313. * @param {number} minuend The first number in a subtraction.
  32314. * @param {number} subtrahend The second number in a subtraction.
  32315. * @returns {number} Returns the difference.
  32316. * @example
  32317. *
  32318. * _.subtract(6, 4);
  32319. * // => 2
  32320. */
  32321. var subtract = createMathOperation(function(minuend, subtrahend) {
  32322. return minuend - subtrahend;
  32323. }, 0);
  32324. /**
  32325. * Computes the sum of the values in `array`.
  32326. *
  32327. * @static
  32328. * @memberOf _
  32329. * @since 3.4.0
  32330. * @category Math
  32331. * @param {Array} array The array to iterate over.
  32332. * @returns {number} Returns the sum.
  32333. * @example
  32334. *
  32335. * _.sum([4, 2, 8, 6]);
  32336. * // => 20
  32337. */
  32338. function sum(array) {
  32339. return (array && array.length)
  32340. ? baseSum(array, identity)
  32341. : 0;
  32342. }
  32343. /**
  32344. * This method is like `_.sum` except that it accepts `iteratee` which is
  32345. * invoked for each element in `array` to generate the value to be summed.
  32346. * The iteratee is invoked with one argument: (value).
  32347. *
  32348. * @static
  32349. * @memberOf _
  32350. * @since 4.0.0
  32351. * @category Math
  32352. * @param {Array} array The array to iterate over.
  32353. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32354. * @returns {number} Returns the sum.
  32355. * @example
  32356. *
  32357. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32358. *
  32359. * _.sumBy(objects, function(o) { return o.n; });
  32360. * // => 20
  32361. *
  32362. * // The `_.property` iteratee shorthand.
  32363. * _.sumBy(objects, 'n');
  32364. * // => 20
  32365. */
  32366. function sumBy(array, iteratee) {
  32367. return (array && array.length)
  32368. ? baseSum(array, getIteratee(iteratee, 2))
  32369. : 0;
  32370. }
  32371. /*------------------------------------------------------------------------*/
  32372. // Add methods that return wrapped values in chain sequences.
  32373. lodash.after = after;
  32374. lodash.ary = ary;
  32375. lodash.assign = assign;
  32376. lodash.assignIn = assignIn;
  32377. lodash.assignInWith = assignInWith;
  32378. lodash.assignWith = assignWith;
  32379. lodash.at = at;
  32380. lodash.before = before;
  32381. lodash.bind = bind;
  32382. lodash.bindAll = bindAll;
  32383. lodash.bindKey = bindKey;
  32384. lodash.castArray = castArray;
  32385. lodash.chain = chain;
  32386. lodash.chunk = chunk;
  32387. lodash.compact = compact;
  32388. lodash.concat = concat;
  32389. lodash.cond = cond;
  32390. lodash.conforms = conforms;
  32391. lodash.constant = constant;
  32392. lodash.countBy = countBy;
  32393. lodash.create = create;
  32394. lodash.curry = curry;
  32395. lodash.curryRight = curryRight;
  32396. lodash.debounce = debounce;
  32397. lodash.defaults = defaults;
  32398. lodash.defaultsDeep = defaultsDeep;
  32399. lodash.defer = defer;
  32400. lodash.delay = delay;
  32401. lodash.difference = difference;
  32402. lodash.differenceBy = differenceBy;
  32403. lodash.differenceWith = differenceWith;
  32404. lodash.drop = drop;
  32405. lodash.dropRight = dropRight;
  32406. lodash.dropRightWhile = dropRightWhile;
  32407. lodash.dropWhile = dropWhile;
  32408. lodash.fill = fill;
  32409. lodash.filter = filter;
  32410. lodash.flatMap = flatMap;
  32411. lodash.flatMapDeep = flatMapDeep;
  32412. lodash.flatMapDepth = flatMapDepth;
  32413. lodash.flatten = flatten;
  32414. lodash.flattenDeep = flattenDeep;
  32415. lodash.flattenDepth = flattenDepth;
  32416. lodash.flip = flip;
  32417. lodash.flow = flow;
  32418. lodash.flowRight = flowRight;
  32419. lodash.fromPairs = fromPairs;
  32420. lodash.functions = functions;
  32421. lodash.functionsIn = functionsIn;
  32422. lodash.groupBy = groupBy;
  32423. lodash.initial = initial;
  32424. lodash.intersection = intersection;
  32425. lodash.intersectionBy = intersectionBy;
  32426. lodash.intersectionWith = intersectionWith;
  32427. lodash.invert = invert;
  32428. lodash.invertBy = invertBy;
  32429. lodash.invokeMap = invokeMap;
  32430. lodash.iteratee = iteratee;
  32431. lodash.keyBy = keyBy;
  32432. lodash.keys = keys;
  32433. lodash.keysIn = keysIn;
  32434. lodash.map = map;
  32435. lodash.mapKeys = mapKeys;
  32436. lodash.mapValues = mapValues;
  32437. lodash.matches = matches;
  32438. lodash.matchesProperty = matchesProperty;
  32439. lodash.memoize = memoize;
  32440. lodash.merge = merge;
  32441. lodash.mergeWith = mergeWith;
  32442. lodash.method = method;
  32443. lodash.methodOf = methodOf;
  32444. lodash.mixin = mixin;
  32445. lodash.negate = negate;
  32446. lodash.nthArg = nthArg;
  32447. lodash.omit = omit;
  32448. lodash.omitBy = omitBy;
  32449. lodash.once = once;
  32450. lodash.orderBy = orderBy;
  32451. lodash.over = over;
  32452. lodash.overArgs = overArgs;
  32453. lodash.overEvery = overEvery;
  32454. lodash.overSome = overSome;
  32455. lodash.partial = partial;
  32456. lodash.partialRight = partialRight;
  32457. lodash.partition = partition;
  32458. lodash.pick = pick;
  32459. lodash.pickBy = pickBy;
  32460. lodash.property = property;
  32461. lodash.propertyOf = propertyOf;
  32462. lodash.pull = pull;
  32463. lodash.pullAll = pullAll;
  32464. lodash.pullAllBy = pullAllBy;
  32465. lodash.pullAllWith = pullAllWith;
  32466. lodash.pullAt = pullAt;
  32467. lodash.range = range;
  32468. lodash.rangeRight = rangeRight;
  32469. lodash.rearg = rearg;
  32470. lodash.reject = reject;
  32471. lodash.remove = remove;
  32472. lodash.rest = rest;
  32473. lodash.reverse = reverse;
  32474. lodash.sampleSize = sampleSize;
  32475. lodash.set = set;
  32476. lodash.setWith = setWith;
  32477. lodash.shuffle = shuffle;
  32478. lodash.slice = slice;
  32479. lodash.sortBy = sortBy;
  32480. lodash.sortedUniq = sortedUniq;
  32481. lodash.sortedUniqBy = sortedUniqBy;
  32482. lodash.split = split;
  32483. lodash.spread = spread;
  32484. lodash.tail = tail;
  32485. lodash.take = take;
  32486. lodash.takeRight = takeRight;
  32487. lodash.takeRightWhile = takeRightWhile;
  32488. lodash.takeWhile = takeWhile;
  32489. lodash.tap = tap;
  32490. lodash.throttle = throttle;
  32491. lodash.thru = thru;
  32492. lodash.toArray = toArray;
  32493. lodash.toPairs = toPairs;
  32494. lodash.toPairsIn = toPairsIn;
  32495. lodash.toPath = toPath;
  32496. lodash.toPlainObject = toPlainObject;
  32497. lodash.transform = transform;
  32498. lodash.unary = unary;
  32499. lodash.union = union;
  32500. lodash.unionBy = unionBy;
  32501. lodash.unionWith = unionWith;
  32502. lodash.uniq = uniq;
  32503. lodash.uniqBy = uniqBy;
  32504. lodash.uniqWith = uniqWith;
  32505. lodash.unset = unset;
  32506. lodash.unzip = unzip;
  32507. lodash.unzipWith = unzipWith;
  32508. lodash.update = update;
  32509. lodash.updateWith = updateWith;
  32510. lodash.values = values;
  32511. lodash.valuesIn = valuesIn;
  32512. lodash.without = without;
  32513. lodash.words = words;
  32514. lodash.wrap = wrap;
  32515. lodash.xor = xor;
  32516. lodash.xorBy = xorBy;
  32517. lodash.xorWith = xorWith;
  32518. lodash.zip = zip;
  32519. lodash.zipObject = zipObject;
  32520. lodash.zipObjectDeep = zipObjectDeep;
  32521. lodash.zipWith = zipWith;
  32522. // Add aliases.
  32523. lodash.entries = toPairs;
  32524. lodash.entriesIn = toPairsIn;
  32525. lodash.extend = assignIn;
  32526. lodash.extendWith = assignInWith;
  32527. // Add methods to `lodash.prototype`.
  32528. mixin(lodash, lodash);
  32529. /*------------------------------------------------------------------------*/
  32530. // Add methods that return unwrapped values in chain sequences.
  32531. lodash.add = add;
  32532. lodash.attempt = attempt;
  32533. lodash.camelCase = camelCase;
  32534. lodash.capitalize = capitalize;
  32535. lodash.ceil = ceil;
  32536. lodash.clamp = clamp;
  32537. lodash.clone = clone;
  32538. lodash.cloneDeep = cloneDeep;
  32539. lodash.cloneDeepWith = cloneDeepWith;
  32540. lodash.cloneWith = cloneWith;
  32541. lodash.conformsTo = conformsTo;
  32542. lodash.deburr = deburr;
  32543. lodash.defaultTo = defaultTo;
  32544. lodash.divide = divide;
  32545. lodash.endsWith = endsWith;
  32546. lodash.eq = eq;
  32547. lodash.escape = escape;
  32548. lodash.escapeRegExp = escapeRegExp;
  32549. lodash.every = every;
  32550. lodash.find = find;
  32551. lodash.findIndex = findIndex;
  32552. lodash.findKey = findKey;
  32553. lodash.findLast = findLast;
  32554. lodash.findLastIndex = findLastIndex;
  32555. lodash.findLastKey = findLastKey;
  32556. lodash.floor = floor;
  32557. lodash.forEach = forEach;
  32558. lodash.forEachRight = forEachRight;
  32559. lodash.forIn = forIn;
  32560. lodash.forInRight = forInRight;
  32561. lodash.forOwn = forOwn;
  32562. lodash.forOwnRight = forOwnRight;
  32563. lodash.get = get;
  32564. lodash.gt = gt;
  32565. lodash.gte = gte;
  32566. lodash.has = has;
  32567. lodash.hasIn = hasIn;
  32568. lodash.head = head;
  32569. lodash.identity = identity;
  32570. lodash.includes = includes;
  32571. lodash.indexOf = indexOf;
  32572. lodash.inRange = inRange;
  32573. lodash.invoke = invoke;
  32574. lodash.isArguments = isArguments;
  32575. lodash.isArray = isArray;
  32576. lodash.isArrayBuffer = isArrayBuffer;
  32577. lodash.isArrayLike = isArrayLike;
  32578. lodash.isArrayLikeObject = isArrayLikeObject;
  32579. lodash.isBoolean = isBoolean;
  32580. lodash.isBuffer = isBuffer;
  32581. lodash.isDate = isDate;
  32582. lodash.isElement = isElement;
  32583. lodash.isEmpty = isEmpty;
  32584. lodash.isEqual = isEqual;
  32585. lodash.isEqualWith = isEqualWith;
  32586. lodash.isError = isError;
  32587. lodash.isFinite = isFinite;
  32588. lodash.isFunction = isFunction;
  32589. lodash.isInteger = isInteger;
  32590. lodash.isLength = isLength;
  32591. lodash.isMap = isMap;
  32592. lodash.isMatch = isMatch;
  32593. lodash.isMatchWith = isMatchWith;
  32594. lodash.isNaN = isNaN;
  32595. lodash.isNative = isNative;
  32596. lodash.isNil = isNil;
  32597. lodash.isNull = isNull;
  32598. lodash.isNumber = isNumber;
  32599. lodash.isObject = isObject;
  32600. lodash.isObjectLike = isObjectLike;
  32601. lodash.isPlainObject = isPlainObject;
  32602. lodash.isRegExp = isRegExp;
  32603. lodash.isSafeInteger = isSafeInteger;
  32604. lodash.isSet = isSet;
  32605. lodash.isString = isString;
  32606. lodash.isSymbol = isSymbol;
  32607. lodash.isTypedArray = isTypedArray;
  32608. lodash.isUndefined = isUndefined;
  32609. lodash.isWeakMap = isWeakMap;
  32610. lodash.isWeakSet = isWeakSet;
  32611. lodash.join = join;
  32612. lodash.kebabCase = kebabCase;
  32613. lodash.last = last;
  32614. lodash.lastIndexOf = lastIndexOf;
  32615. lodash.lowerCase = lowerCase;
  32616. lodash.lowerFirst = lowerFirst;
  32617. lodash.lt = lt;
  32618. lodash.lte = lte;
  32619. lodash.max = max;
  32620. lodash.maxBy = maxBy;
  32621. lodash.mean = mean;
  32622. lodash.meanBy = meanBy;
  32623. lodash.min = min;
  32624. lodash.minBy = minBy;
  32625. lodash.stubArray = stubArray;
  32626. lodash.stubFalse = stubFalse;
  32627. lodash.stubObject = stubObject;
  32628. lodash.stubString = stubString;
  32629. lodash.stubTrue = stubTrue;
  32630. lodash.multiply = multiply;
  32631. lodash.nth = nth;
  32632. lodash.noConflict = noConflict;
  32633. lodash.noop = noop;
  32634. lodash.now = now;
  32635. lodash.pad = pad;
  32636. lodash.padEnd = padEnd;
  32637. lodash.padStart = padStart;
  32638. lodash.parseInt = parseInt;
  32639. lodash.random = random;
  32640. lodash.reduce = reduce;
  32641. lodash.reduceRight = reduceRight;
  32642. lodash.repeat = repeat;
  32643. lodash.replace = replace;
  32644. lodash.result = result;
  32645. lodash.round = round;
  32646. lodash.runInContext = runInContext;
  32647. lodash.sample = sample;
  32648. lodash.size = size;
  32649. lodash.snakeCase = snakeCase;
  32650. lodash.some = some;
  32651. lodash.sortedIndex = sortedIndex;
  32652. lodash.sortedIndexBy = sortedIndexBy;
  32653. lodash.sortedIndexOf = sortedIndexOf;
  32654. lodash.sortedLastIndex = sortedLastIndex;
  32655. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32656. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32657. lodash.startCase = startCase;
  32658. lodash.startsWith = startsWith;
  32659. lodash.subtract = subtract;
  32660. lodash.sum = sum;
  32661. lodash.sumBy = sumBy;
  32662. lodash.template = template;
  32663. lodash.times = times;
  32664. lodash.toFinite = toFinite;
  32665. lodash.toInteger = toInteger;
  32666. lodash.toLength = toLength;
  32667. lodash.toLower = toLower;
  32668. lodash.toNumber = toNumber;
  32669. lodash.toSafeInteger = toSafeInteger;
  32670. lodash.toString = toString;
  32671. lodash.toUpper = toUpper;
  32672. lodash.trim = trim;
  32673. lodash.trimEnd = trimEnd;
  32674. lodash.trimStart = trimStart;
  32675. lodash.truncate = truncate;
  32676. lodash.unescape = unescape;
  32677. lodash.uniqueId = uniqueId;
  32678. lodash.upperCase = upperCase;
  32679. lodash.upperFirst = upperFirst;
  32680. // Add aliases.
  32681. lodash.each = forEach;
  32682. lodash.eachRight = forEachRight;
  32683. lodash.first = head;
  32684. mixin(lodash, (function() {
  32685. var source = {};
  32686. baseForOwn(lodash, function(func, methodName) {
  32687. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32688. source[methodName] = func;
  32689. }
  32690. });
  32691. return source;
  32692. }()), { 'chain': false });
  32693. /*------------------------------------------------------------------------*/
  32694. /**
  32695. * The semantic version number.
  32696. *
  32697. * @static
  32698. * @memberOf _
  32699. * @type {string}
  32700. */
  32701. lodash.VERSION = VERSION;
  32702. // Assign default placeholders.
  32703. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32704. lodash[methodName].placeholder = lodash;
  32705. });
  32706. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32707. arrayEach(['drop', 'take'], function(methodName, index) {
  32708. LazyWrapper.prototype[methodName] = function(n) {
  32709. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32710. var result = (this.__filtered__ && !index)
  32711. ? new LazyWrapper(this)
  32712. : this.clone();
  32713. if (result.__filtered__) {
  32714. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32715. } else {
  32716. result.__views__.push({
  32717. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32718. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32719. });
  32720. }
  32721. return result;
  32722. };
  32723. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32724. return this.reverse()[methodName](n).reverse();
  32725. };
  32726. });
  32727. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32728. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32729. var type = index + 1,
  32730. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32731. LazyWrapper.prototype[methodName] = function(iteratee) {
  32732. var result = this.clone();
  32733. result.__iteratees__.push({
  32734. 'iteratee': getIteratee(iteratee, 3),
  32735. 'type': type
  32736. });
  32737. result.__filtered__ = result.__filtered__ || isFilter;
  32738. return result;
  32739. };
  32740. });
  32741. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32742. arrayEach(['head', 'last'], function(methodName, index) {
  32743. var takeName = 'take' + (index ? 'Right' : '');
  32744. LazyWrapper.prototype[methodName] = function() {
  32745. return this[takeName](1).value()[0];
  32746. };
  32747. });
  32748. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32749. arrayEach(['initial', 'tail'], function(methodName, index) {
  32750. var dropName = 'drop' + (index ? '' : 'Right');
  32751. LazyWrapper.prototype[methodName] = function() {
  32752. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32753. };
  32754. });
  32755. LazyWrapper.prototype.compact = function() {
  32756. return this.filter(identity);
  32757. };
  32758. LazyWrapper.prototype.find = function(predicate) {
  32759. return this.filter(predicate).head();
  32760. };
  32761. LazyWrapper.prototype.findLast = function(predicate) {
  32762. return this.reverse().find(predicate);
  32763. };
  32764. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32765. if (typeof path == 'function') {
  32766. return new LazyWrapper(this);
  32767. }
  32768. return this.map(function(value) {
  32769. return baseInvoke(value, path, args);
  32770. });
  32771. });
  32772. LazyWrapper.prototype.reject = function(predicate) {
  32773. return this.filter(negate(getIteratee(predicate)));
  32774. };
  32775. LazyWrapper.prototype.slice = function(start, end) {
  32776. start = toInteger(start);
  32777. var result = this;
  32778. if (result.__filtered__ && (start > 0 || end < 0)) {
  32779. return new LazyWrapper(result);
  32780. }
  32781. if (start < 0) {
  32782. result = result.takeRight(-start);
  32783. } else if (start) {
  32784. result = result.drop(start);
  32785. }
  32786. if (end !== undefined) {
  32787. end = toInteger(end);
  32788. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32789. }
  32790. return result;
  32791. };
  32792. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32793. return this.reverse().takeWhile(predicate).reverse();
  32794. };
  32795. LazyWrapper.prototype.toArray = function() {
  32796. return this.take(MAX_ARRAY_LENGTH);
  32797. };
  32798. // Add `LazyWrapper` methods to `lodash.prototype`.
  32799. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32800. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32801. isTaker = /^(?:head|last)$/.test(methodName),
  32802. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32803. retUnwrapped = isTaker || /^find/.test(methodName);
  32804. if (!lodashFunc) {
  32805. return;
  32806. }
  32807. lodash.prototype[methodName] = function() {
  32808. var value = this.__wrapped__,
  32809. args = isTaker ? [1] : arguments,
  32810. isLazy = value instanceof LazyWrapper,
  32811. iteratee = args[0],
  32812. useLazy = isLazy || isArray(value);
  32813. var interceptor = function(value) {
  32814. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32815. return (isTaker && chainAll) ? result[0] : result;
  32816. };
  32817. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32818. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32819. isLazy = useLazy = false;
  32820. }
  32821. var chainAll = this.__chain__,
  32822. isHybrid = !!this.__actions__.length,
  32823. isUnwrapped = retUnwrapped && !chainAll,
  32824. onlyLazy = isLazy && !isHybrid;
  32825. if (!retUnwrapped && useLazy) {
  32826. value = onlyLazy ? value : new LazyWrapper(this);
  32827. var result = func.apply(value, args);
  32828. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32829. return new LodashWrapper(result, chainAll);
  32830. }
  32831. if (isUnwrapped && onlyLazy) {
  32832. return func.apply(this, args);
  32833. }
  32834. result = this.thru(interceptor);
  32835. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32836. };
  32837. });
  32838. // Add `Array` methods to `lodash.prototype`.
  32839. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32840. var func = arrayProto[methodName],
  32841. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32842. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32843. lodash.prototype[methodName] = function() {
  32844. var args = arguments;
  32845. if (retUnwrapped && !this.__chain__) {
  32846. var value = this.value();
  32847. return func.apply(isArray(value) ? value : [], args);
  32848. }
  32849. return this[chainName](function(value) {
  32850. return func.apply(isArray(value) ? value : [], args);
  32851. });
  32852. };
  32853. });
  32854. // Map minified method names to their real names.
  32855. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32856. var lodashFunc = lodash[methodName];
  32857. if (lodashFunc) {
  32858. var key = lodashFunc.name + '';
  32859. if (!hasOwnProperty.call(realNames, key)) {
  32860. realNames[key] = [];
  32861. }
  32862. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32863. }
  32864. });
  32865. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32866. 'name': 'wrapper',
  32867. 'func': undefined
  32868. }];
  32869. // Add methods to `LazyWrapper`.
  32870. LazyWrapper.prototype.clone = lazyClone;
  32871. LazyWrapper.prototype.reverse = lazyReverse;
  32872. LazyWrapper.prototype.value = lazyValue;
  32873. // Add chain sequence methods to the `lodash` wrapper.
  32874. lodash.prototype.at = wrapperAt;
  32875. lodash.prototype.chain = wrapperChain;
  32876. lodash.prototype.commit = wrapperCommit;
  32877. lodash.prototype.next = wrapperNext;
  32878. lodash.prototype.plant = wrapperPlant;
  32879. lodash.prototype.reverse = wrapperReverse;
  32880. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32881. // Add lazy aliases.
  32882. lodash.prototype.first = lodash.prototype.head;
  32883. if (symIterator) {
  32884. lodash.prototype[symIterator] = wrapperToIterator;
  32885. }
  32886. return lodash;
  32887. });
  32888. /*--------------------------------------------------------------------------*/
  32889. // Export lodash.
  32890. var _ = runInContext();
  32891. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32892. if (true) {
  32893. // Expose Lodash on the global object to prevent errors when Lodash is
  32894. // loaded by a script tag in the presence of an AMD loader.
  32895. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32896. // Use `_.noConflict` to remove Lodash from the global object.
  32897. root._ = _;
  32898. // Define as an anonymous module so, through path mapping, it can be
  32899. // referenced as the "underscore" module.
  32900. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32901. return _;
  32902. }).call(exports, __webpack_require__, exports, module),
  32903. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32904. }
  32905. // Check for `exports` after `define` in case a build optimizer adds it.
  32906. else {}
  32907. }.call(this));
  32908. /* 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)))
  32909. /***/ }),
  32910. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32911. /*!***************************************************!*\
  32912. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32913. \***************************************************/
  32914. /*! exports provided: default */
  32915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32916. "use strict";
  32917. __webpack_require__.r(__webpack_exports__);
  32918. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32919. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32920. * @version 1.16.1
  32921. * @license
  32922. * Copyright (c) 2016 Federico Zivolo and contributors
  32923. *
  32924. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32925. * of this software and associated documentation files (the "Software"), to deal
  32926. * in the Software without restriction, including without limitation the rights
  32927. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32928. * copies of the Software, and to permit persons to whom the Software is
  32929. * furnished to do so, subject to the following conditions:
  32930. *
  32931. * The above copyright notice and this permission notice shall be included in all
  32932. * copies or substantial portions of the Software.
  32933. *
  32934. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32935. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32936. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32937. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32938. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32939. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32940. * SOFTWARE.
  32941. */
  32942. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32943. var timeoutDuration = function () {
  32944. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32945. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32946. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32947. return 1;
  32948. }
  32949. }
  32950. return 0;
  32951. }();
  32952. function microtaskDebounce(fn) {
  32953. var called = false;
  32954. return function () {
  32955. if (called) {
  32956. return;
  32957. }
  32958. called = true;
  32959. window.Promise.resolve().then(function () {
  32960. called = false;
  32961. fn();
  32962. });
  32963. };
  32964. }
  32965. function taskDebounce(fn) {
  32966. var scheduled = false;
  32967. return function () {
  32968. if (!scheduled) {
  32969. scheduled = true;
  32970. setTimeout(function () {
  32971. scheduled = false;
  32972. fn();
  32973. }, timeoutDuration);
  32974. }
  32975. };
  32976. }
  32977. var supportsMicroTasks = isBrowser && window.Promise;
  32978. /**
  32979. * Create a debounced version of a method, that's asynchronously deferred
  32980. * but called in the minimum time possible.
  32981. *
  32982. * @method
  32983. * @memberof Popper.Utils
  32984. * @argument {Function} fn
  32985. * @returns {Function}
  32986. */
  32987. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  32988. /**
  32989. * Check if the given variable is a function
  32990. * @method
  32991. * @memberof Popper.Utils
  32992. * @argument {Any} functionToCheck - variable to check
  32993. * @returns {Boolean} answer to: is a function?
  32994. */
  32995. function isFunction(functionToCheck) {
  32996. var getType = {};
  32997. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  32998. }
  32999. /**
  33000. * Get CSS computed property of the given element
  33001. * @method
  33002. * @memberof Popper.Utils
  33003. * @argument {Eement} element
  33004. * @argument {String} property
  33005. */
  33006. function getStyleComputedProperty(element, property) {
  33007. if (element.nodeType !== 1) {
  33008. return [];
  33009. }
  33010. // NOTE: 1 DOM access here
  33011. var window = element.ownerDocument.defaultView;
  33012. var css = window.getComputedStyle(element, null);
  33013. return property ? css[property] : css;
  33014. }
  33015. /**
  33016. * Returns the parentNode or the host of the element
  33017. * @method
  33018. * @memberof Popper.Utils
  33019. * @argument {Element} element
  33020. * @returns {Element} parent
  33021. */
  33022. function getParentNode(element) {
  33023. if (element.nodeName === 'HTML') {
  33024. return element;
  33025. }
  33026. return element.parentNode || element.host;
  33027. }
  33028. /**
  33029. * Returns the scrolling parent of the given element
  33030. * @method
  33031. * @memberof Popper.Utils
  33032. * @argument {Element} element
  33033. * @returns {Element} scroll parent
  33034. */
  33035. function getScrollParent(element) {
  33036. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33037. if (!element) {
  33038. return document.body;
  33039. }
  33040. switch (element.nodeName) {
  33041. case 'HTML':
  33042. case 'BODY':
  33043. return element.ownerDocument.body;
  33044. case '#document':
  33045. return element.body;
  33046. }
  33047. // Firefox want us to check `-x` and `-y` variations as well
  33048. var _getStyleComputedProp = getStyleComputedProperty(element),
  33049. overflow = _getStyleComputedProp.overflow,
  33050. overflowX = _getStyleComputedProp.overflowX,
  33051. overflowY = _getStyleComputedProp.overflowY;
  33052. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33053. return element;
  33054. }
  33055. return getScrollParent(getParentNode(element));
  33056. }
  33057. /**
  33058. * Returns the reference node of the reference object, or the reference object itself.
  33059. * @method
  33060. * @memberof Popper.Utils
  33061. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33062. * @returns {Element} parent
  33063. */
  33064. function getReferenceNode(reference) {
  33065. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33066. }
  33067. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33068. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33069. /**
  33070. * Determines if the browser is Internet Explorer
  33071. * @method
  33072. * @memberof Popper.Utils
  33073. * @param {Number} version to check
  33074. * @returns {Boolean} isIE
  33075. */
  33076. function isIE(version) {
  33077. if (version === 11) {
  33078. return isIE11;
  33079. }
  33080. if (version === 10) {
  33081. return isIE10;
  33082. }
  33083. return isIE11 || isIE10;
  33084. }
  33085. /**
  33086. * Returns the offset parent of the given element
  33087. * @method
  33088. * @memberof Popper.Utils
  33089. * @argument {Element} element
  33090. * @returns {Element} offset parent
  33091. */
  33092. function getOffsetParent(element) {
  33093. if (!element) {
  33094. return document.documentElement;
  33095. }
  33096. var noOffsetParent = isIE(10) ? document.body : null;
  33097. // NOTE: 1 DOM access here
  33098. var offsetParent = element.offsetParent || null;
  33099. // Skip hidden elements which don't have an offsetParent
  33100. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33101. offsetParent = (element = element.nextElementSibling).offsetParent;
  33102. }
  33103. var nodeName = offsetParent && offsetParent.nodeName;
  33104. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33105. return element ? element.ownerDocument.documentElement : document.documentElement;
  33106. }
  33107. // .offsetParent will return the closest TH, TD or TABLE in case
  33108. // no offsetParent is present, I hate this job...
  33109. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33110. return getOffsetParent(offsetParent);
  33111. }
  33112. return offsetParent;
  33113. }
  33114. function isOffsetContainer(element) {
  33115. var nodeName = element.nodeName;
  33116. if (nodeName === 'BODY') {
  33117. return false;
  33118. }
  33119. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33120. }
  33121. /**
  33122. * Finds the root node (document, shadowDOM root) of the given element
  33123. * @method
  33124. * @memberof Popper.Utils
  33125. * @argument {Element} node
  33126. * @returns {Element} root node
  33127. */
  33128. function getRoot(node) {
  33129. if (node.parentNode !== null) {
  33130. return getRoot(node.parentNode);
  33131. }
  33132. return node;
  33133. }
  33134. /**
  33135. * Finds the offset parent common to the two provided nodes
  33136. * @method
  33137. * @memberof Popper.Utils
  33138. * @argument {Element} element1
  33139. * @argument {Element} element2
  33140. * @returns {Element} common offset parent
  33141. */
  33142. function findCommonOffsetParent(element1, element2) {
  33143. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33144. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33145. return document.documentElement;
  33146. }
  33147. // Here we make sure to give as "start" the element that comes first in the DOM
  33148. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33149. var start = order ? element1 : element2;
  33150. var end = order ? element2 : element1;
  33151. // Get common ancestor container
  33152. var range = document.createRange();
  33153. range.setStart(start, 0);
  33154. range.setEnd(end, 0);
  33155. var commonAncestorContainer = range.commonAncestorContainer;
  33156. // Both nodes are inside #document
  33157. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33158. if (isOffsetContainer(commonAncestorContainer)) {
  33159. return commonAncestorContainer;
  33160. }
  33161. return getOffsetParent(commonAncestorContainer);
  33162. }
  33163. // one of the nodes is inside shadowDOM, find which one
  33164. var element1root = getRoot(element1);
  33165. if (element1root.host) {
  33166. return findCommonOffsetParent(element1root.host, element2);
  33167. } else {
  33168. return findCommonOffsetParent(element1, getRoot(element2).host);
  33169. }
  33170. }
  33171. /**
  33172. * Gets the scroll value of the given element in the given side (top and left)
  33173. * @method
  33174. * @memberof Popper.Utils
  33175. * @argument {Element} element
  33176. * @argument {String} side `top` or `left`
  33177. * @returns {number} amount of scrolled pixels
  33178. */
  33179. function getScroll(element) {
  33180. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33181. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33182. var nodeName = element.nodeName;
  33183. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33184. var html = element.ownerDocument.documentElement;
  33185. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33186. return scrollingElement[upperSide];
  33187. }
  33188. return element[upperSide];
  33189. }
  33190. /*
  33191. * Sum or subtract the element scroll values (left and top) from a given rect object
  33192. * @method
  33193. * @memberof Popper.Utils
  33194. * @param {Object} rect - Rect object you want to change
  33195. * @param {HTMLElement} element - The element from the function reads the scroll values
  33196. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33197. * @return {Object} rect - The modifier rect object
  33198. */
  33199. function includeScroll(rect, element) {
  33200. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33201. var scrollTop = getScroll(element, 'top');
  33202. var scrollLeft = getScroll(element, 'left');
  33203. var modifier = subtract ? -1 : 1;
  33204. rect.top += scrollTop * modifier;
  33205. rect.bottom += scrollTop * modifier;
  33206. rect.left += scrollLeft * modifier;
  33207. rect.right += scrollLeft * modifier;
  33208. return rect;
  33209. }
  33210. /*
  33211. * Helper to detect borders of a given element
  33212. * @method
  33213. * @memberof Popper.Utils
  33214. * @param {CSSStyleDeclaration} styles
  33215. * Result of `getStyleComputedProperty` on the given element
  33216. * @param {String} axis - `x` or `y`
  33217. * @return {number} borders - The borders size of the given axis
  33218. */
  33219. function getBordersSize(styles, axis) {
  33220. var sideA = axis === 'x' ? 'Left' : 'Top';
  33221. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33222. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33223. }
  33224. function getSize(axis, body, html, computedStyle) {
  33225. 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);
  33226. }
  33227. function getWindowSizes(document) {
  33228. var body = document.body;
  33229. var html = document.documentElement;
  33230. var computedStyle = isIE(10) && getComputedStyle(html);
  33231. return {
  33232. height: getSize('Height', body, html, computedStyle),
  33233. width: getSize('Width', body, html, computedStyle)
  33234. };
  33235. }
  33236. var classCallCheck = function (instance, Constructor) {
  33237. if (!(instance instanceof Constructor)) {
  33238. throw new TypeError("Cannot call a class as a function");
  33239. }
  33240. };
  33241. var createClass = function () {
  33242. function defineProperties(target, props) {
  33243. for (var i = 0; i < props.length; i++) {
  33244. var descriptor = props[i];
  33245. descriptor.enumerable = descriptor.enumerable || false;
  33246. descriptor.configurable = true;
  33247. if ("value" in descriptor) descriptor.writable = true;
  33248. Object.defineProperty(target, descriptor.key, descriptor);
  33249. }
  33250. }
  33251. return function (Constructor, protoProps, staticProps) {
  33252. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33253. if (staticProps) defineProperties(Constructor, staticProps);
  33254. return Constructor;
  33255. };
  33256. }();
  33257. var defineProperty = function (obj, key, value) {
  33258. if (key in obj) {
  33259. Object.defineProperty(obj, key, {
  33260. value: value,
  33261. enumerable: true,
  33262. configurable: true,
  33263. writable: true
  33264. });
  33265. } else {
  33266. obj[key] = value;
  33267. }
  33268. return obj;
  33269. };
  33270. var _extends = Object.assign || function (target) {
  33271. for (var i = 1; i < arguments.length; i++) {
  33272. var source = arguments[i];
  33273. for (var key in source) {
  33274. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33275. target[key] = source[key];
  33276. }
  33277. }
  33278. }
  33279. return target;
  33280. };
  33281. /**
  33282. * Given element offsets, generate an output similar to getBoundingClientRect
  33283. * @method
  33284. * @memberof Popper.Utils
  33285. * @argument {Object} offsets
  33286. * @returns {Object} ClientRect like output
  33287. */
  33288. function getClientRect(offsets) {
  33289. return _extends({}, offsets, {
  33290. right: offsets.left + offsets.width,
  33291. bottom: offsets.top + offsets.height
  33292. });
  33293. }
  33294. /**
  33295. * Get bounding client rect of given element
  33296. * @method
  33297. * @memberof Popper.Utils
  33298. * @param {HTMLElement} element
  33299. * @return {Object} client rect
  33300. */
  33301. function getBoundingClientRect(element) {
  33302. var rect = {};
  33303. // IE10 10 FIX: Please, don't ask, the element isn't
  33304. // considered in DOM in some circumstances...
  33305. // This isn't reproducible in IE10 compatibility mode of IE11
  33306. try {
  33307. if (isIE(10)) {
  33308. rect = element.getBoundingClientRect();
  33309. var scrollTop = getScroll(element, 'top');
  33310. var scrollLeft = getScroll(element, 'left');
  33311. rect.top += scrollTop;
  33312. rect.left += scrollLeft;
  33313. rect.bottom += scrollTop;
  33314. rect.right += scrollLeft;
  33315. } else {
  33316. rect = element.getBoundingClientRect();
  33317. }
  33318. } catch (e) {}
  33319. var result = {
  33320. left: rect.left,
  33321. top: rect.top,
  33322. width: rect.right - rect.left,
  33323. height: rect.bottom - rect.top
  33324. };
  33325. // subtract scrollbar size from sizes
  33326. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33327. var width = sizes.width || element.clientWidth || result.width;
  33328. var height = sizes.height || element.clientHeight || result.height;
  33329. var horizScrollbar = element.offsetWidth - width;
  33330. var vertScrollbar = element.offsetHeight - height;
  33331. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33332. // we make this check conditional for performance reasons
  33333. if (horizScrollbar || vertScrollbar) {
  33334. var styles = getStyleComputedProperty(element);
  33335. horizScrollbar -= getBordersSize(styles, 'x');
  33336. vertScrollbar -= getBordersSize(styles, 'y');
  33337. result.width -= horizScrollbar;
  33338. result.height -= vertScrollbar;
  33339. }
  33340. return getClientRect(result);
  33341. }
  33342. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33343. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33344. var isIE10 = isIE(10);
  33345. var isHTML = parent.nodeName === 'HTML';
  33346. var childrenRect = getBoundingClientRect(children);
  33347. var parentRect = getBoundingClientRect(parent);
  33348. var scrollParent = getScrollParent(children);
  33349. var styles = getStyleComputedProperty(parent);
  33350. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33351. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33352. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33353. if (fixedPosition && isHTML) {
  33354. parentRect.top = Math.max(parentRect.top, 0);
  33355. parentRect.left = Math.max(parentRect.left, 0);
  33356. }
  33357. var offsets = getClientRect({
  33358. top: childrenRect.top - parentRect.top - borderTopWidth,
  33359. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33360. width: childrenRect.width,
  33361. height: childrenRect.height
  33362. });
  33363. offsets.marginTop = 0;
  33364. offsets.marginLeft = 0;
  33365. // Subtract margins of documentElement in case it's being used as parent
  33366. // we do this only on HTML because it's the only element that behaves
  33367. // differently when margins are applied to it. The margins are included in
  33368. // the box of the documentElement, in the other cases not.
  33369. if (!isIE10 && isHTML) {
  33370. var marginTop = parseFloat(styles.marginTop);
  33371. var marginLeft = parseFloat(styles.marginLeft);
  33372. offsets.top -= borderTopWidth - marginTop;
  33373. offsets.bottom -= borderTopWidth - marginTop;
  33374. offsets.left -= borderLeftWidth - marginLeft;
  33375. offsets.right -= borderLeftWidth - marginLeft;
  33376. // Attach marginTop and marginLeft because in some circumstances we may need them
  33377. offsets.marginTop = marginTop;
  33378. offsets.marginLeft = marginLeft;
  33379. }
  33380. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33381. offsets = includeScroll(offsets, parent);
  33382. }
  33383. return offsets;
  33384. }
  33385. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33386. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33387. var html = element.ownerDocument.documentElement;
  33388. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33389. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33390. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33391. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33392. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33393. var offset = {
  33394. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33395. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33396. width: width,
  33397. height: height
  33398. };
  33399. return getClientRect(offset);
  33400. }
  33401. /**
  33402. * Check if the given element is fixed or is inside a fixed parent
  33403. * @method
  33404. * @memberof Popper.Utils
  33405. * @argument {Element} element
  33406. * @argument {Element} customContainer
  33407. * @returns {Boolean} answer to "isFixed?"
  33408. */
  33409. function isFixed(element) {
  33410. var nodeName = element.nodeName;
  33411. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33412. return false;
  33413. }
  33414. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33415. return true;
  33416. }
  33417. var parentNode = getParentNode(element);
  33418. if (!parentNode) {
  33419. return false;
  33420. }
  33421. return isFixed(parentNode);
  33422. }
  33423. /**
  33424. * Finds the first parent of an element that has a transformed property defined
  33425. * @method
  33426. * @memberof Popper.Utils
  33427. * @argument {Element} element
  33428. * @returns {Element} first transformed parent or documentElement
  33429. */
  33430. function getFixedPositionOffsetParent(element) {
  33431. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33432. if (!element || !element.parentElement || isIE()) {
  33433. return document.documentElement;
  33434. }
  33435. var el = element.parentElement;
  33436. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33437. el = el.parentElement;
  33438. }
  33439. return el || document.documentElement;
  33440. }
  33441. /**
  33442. * Computed the boundaries limits and return them
  33443. * @method
  33444. * @memberof Popper.Utils
  33445. * @param {HTMLElement} popper
  33446. * @param {HTMLElement} reference
  33447. * @param {number} padding
  33448. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33449. * @param {Boolean} fixedPosition - Is in fixed position mode
  33450. * @returns {Object} Coordinates of the boundaries
  33451. */
  33452. function getBoundaries(popper, reference, padding, boundariesElement) {
  33453. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33454. // NOTE: 1 DOM access here
  33455. var boundaries = { top: 0, left: 0 };
  33456. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33457. // Handle viewport case
  33458. if (boundariesElement === 'viewport') {
  33459. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33460. } else {
  33461. // Handle other cases based on DOM element used as boundaries
  33462. var boundariesNode = void 0;
  33463. if (boundariesElement === 'scrollParent') {
  33464. boundariesNode = getScrollParent(getParentNode(reference));
  33465. if (boundariesNode.nodeName === 'BODY') {
  33466. boundariesNode = popper.ownerDocument.documentElement;
  33467. }
  33468. } else if (boundariesElement === 'window') {
  33469. boundariesNode = popper.ownerDocument.documentElement;
  33470. } else {
  33471. boundariesNode = boundariesElement;
  33472. }
  33473. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33474. // In case of HTML, we need a different computation
  33475. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33476. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33477. height = _getWindowSizes.height,
  33478. width = _getWindowSizes.width;
  33479. boundaries.top += offsets.top - offsets.marginTop;
  33480. boundaries.bottom = height + offsets.top;
  33481. boundaries.left += offsets.left - offsets.marginLeft;
  33482. boundaries.right = width + offsets.left;
  33483. } else {
  33484. // for all the other DOM elements, this one is good
  33485. boundaries = offsets;
  33486. }
  33487. }
  33488. // Add paddings
  33489. padding = padding || 0;
  33490. var isPaddingNumber = typeof padding === 'number';
  33491. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33492. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33493. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33494. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33495. return boundaries;
  33496. }
  33497. function getArea(_ref) {
  33498. var width = _ref.width,
  33499. height = _ref.height;
  33500. return width * height;
  33501. }
  33502. /**
  33503. * Utility used to transform the `auto` placement to the placement with more
  33504. * available space.
  33505. * @method
  33506. * @memberof Popper.Utils
  33507. * @argument {Object} data - The data object generated by update method
  33508. * @argument {Object} options - Modifiers configuration and options
  33509. * @returns {Object} The data object, properly modified
  33510. */
  33511. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33512. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33513. if (placement.indexOf('auto') === -1) {
  33514. return placement;
  33515. }
  33516. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33517. var rects = {
  33518. top: {
  33519. width: boundaries.width,
  33520. height: refRect.top - boundaries.top
  33521. },
  33522. right: {
  33523. width: boundaries.right - refRect.right,
  33524. height: boundaries.height
  33525. },
  33526. bottom: {
  33527. width: boundaries.width,
  33528. height: boundaries.bottom - refRect.bottom
  33529. },
  33530. left: {
  33531. width: refRect.left - boundaries.left,
  33532. height: boundaries.height
  33533. }
  33534. };
  33535. var sortedAreas = Object.keys(rects).map(function (key) {
  33536. return _extends({
  33537. key: key
  33538. }, rects[key], {
  33539. area: getArea(rects[key])
  33540. });
  33541. }).sort(function (a, b) {
  33542. return b.area - a.area;
  33543. });
  33544. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33545. var width = _ref2.width,
  33546. height = _ref2.height;
  33547. return width >= popper.clientWidth && height >= popper.clientHeight;
  33548. });
  33549. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33550. var variation = placement.split('-')[1];
  33551. return computedPlacement + (variation ? '-' + variation : '');
  33552. }
  33553. /**
  33554. * Get offsets to the reference element
  33555. * @method
  33556. * @memberof Popper.Utils
  33557. * @param {Object} state
  33558. * @param {Element} popper - the popper element
  33559. * @param {Element} reference - the reference element (the popper will be relative to this)
  33560. * @param {Element} fixedPosition - is in fixed position mode
  33561. * @returns {Object} An object containing the offsets which will be applied to the popper
  33562. */
  33563. function getReferenceOffsets(state, popper, reference) {
  33564. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33565. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33566. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33567. }
  33568. /**
  33569. * Get the outer sizes of the given element (offset size + margins)
  33570. * @method
  33571. * @memberof Popper.Utils
  33572. * @argument {Element} element
  33573. * @returns {Object} object containing width and height properties
  33574. */
  33575. function getOuterSizes(element) {
  33576. var window = element.ownerDocument.defaultView;
  33577. var styles = window.getComputedStyle(element);
  33578. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33579. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33580. var result = {
  33581. width: element.offsetWidth + y,
  33582. height: element.offsetHeight + x
  33583. };
  33584. return result;
  33585. }
  33586. /**
  33587. * Get the opposite placement of the given one
  33588. * @method
  33589. * @memberof Popper.Utils
  33590. * @argument {String} placement
  33591. * @returns {String} flipped placement
  33592. */
  33593. function getOppositePlacement(placement) {
  33594. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33595. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33596. return hash[matched];
  33597. });
  33598. }
  33599. /**
  33600. * Get offsets to the popper
  33601. * @method
  33602. * @memberof Popper.Utils
  33603. * @param {Object} position - CSS position the Popper will get applied
  33604. * @param {HTMLElement} popper - the popper element
  33605. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33606. * @param {String} placement - one of the valid placement options
  33607. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33608. */
  33609. function getPopperOffsets(popper, referenceOffsets, placement) {
  33610. placement = placement.split('-')[0];
  33611. // Get popper node sizes
  33612. var popperRect = getOuterSizes(popper);
  33613. // Add position, width and height to our offsets object
  33614. var popperOffsets = {
  33615. width: popperRect.width,
  33616. height: popperRect.height
  33617. };
  33618. // depending by the popper placement we have to compute its offsets slightly differently
  33619. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33620. var mainSide = isHoriz ? 'top' : 'left';
  33621. var secondarySide = isHoriz ? 'left' : 'top';
  33622. var measurement = isHoriz ? 'height' : 'width';
  33623. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33624. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33625. if (placement === secondarySide) {
  33626. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33627. } else {
  33628. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33629. }
  33630. return popperOffsets;
  33631. }
  33632. /**
  33633. * Mimics the `find` method of Array
  33634. * @method
  33635. * @memberof Popper.Utils
  33636. * @argument {Array} arr
  33637. * @argument prop
  33638. * @argument value
  33639. * @returns index or -1
  33640. */
  33641. function find(arr, check) {
  33642. // use native find if supported
  33643. if (Array.prototype.find) {
  33644. return arr.find(check);
  33645. }
  33646. // use `filter` to obtain the same behavior of `find`
  33647. return arr.filter(check)[0];
  33648. }
  33649. /**
  33650. * Return the index of the matching object
  33651. * @method
  33652. * @memberof Popper.Utils
  33653. * @argument {Array} arr
  33654. * @argument prop
  33655. * @argument value
  33656. * @returns index or -1
  33657. */
  33658. function findIndex(arr, prop, value) {
  33659. // use native findIndex if supported
  33660. if (Array.prototype.findIndex) {
  33661. return arr.findIndex(function (cur) {
  33662. return cur[prop] === value;
  33663. });
  33664. }
  33665. // use `find` + `indexOf` if `findIndex` isn't supported
  33666. var match = find(arr, function (obj) {
  33667. return obj[prop] === value;
  33668. });
  33669. return arr.indexOf(match);
  33670. }
  33671. /**
  33672. * Loop trough the list of modifiers and run them in order,
  33673. * each of them will then edit the data object.
  33674. * @method
  33675. * @memberof Popper.Utils
  33676. * @param {dataObject} data
  33677. * @param {Array} modifiers
  33678. * @param {String} ends - Optional modifier name used as stopper
  33679. * @returns {dataObject}
  33680. */
  33681. function runModifiers(modifiers, data, ends) {
  33682. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33683. modifiersToRun.forEach(function (modifier) {
  33684. if (modifier['function']) {
  33685. // eslint-disable-line dot-notation
  33686. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33687. }
  33688. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33689. if (modifier.enabled && isFunction(fn)) {
  33690. // Add properties to offsets to make them a complete clientRect object
  33691. // we do this before each modifier to make sure the previous one doesn't
  33692. // mess with these values
  33693. data.offsets.popper = getClientRect(data.offsets.popper);
  33694. data.offsets.reference = getClientRect(data.offsets.reference);
  33695. data = fn(data, modifier);
  33696. }
  33697. });
  33698. return data;
  33699. }
  33700. /**
  33701. * Updates the position of the popper, computing the new offsets and applying
  33702. * the new style.<br />
  33703. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33704. * @method
  33705. * @memberof Popper
  33706. */
  33707. function update() {
  33708. // if popper is destroyed, don't perform any further update
  33709. if (this.state.isDestroyed) {
  33710. return;
  33711. }
  33712. var data = {
  33713. instance: this,
  33714. styles: {},
  33715. arrowStyles: {},
  33716. attributes: {},
  33717. flipped: false,
  33718. offsets: {}
  33719. };
  33720. // compute reference element offsets
  33721. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33722. // compute auto placement, store placement inside the data object,
  33723. // modifiers will be able to edit `placement` if needed
  33724. // and refer to originalPlacement to know the original value
  33725. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33726. // store the computed placement inside `originalPlacement`
  33727. data.originalPlacement = data.placement;
  33728. data.positionFixed = this.options.positionFixed;
  33729. // compute the popper offsets
  33730. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33731. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33732. // run the modifiers
  33733. data = runModifiers(this.modifiers, data);
  33734. // the first `update` will call `onCreate` callback
  33735. // the other ones will call `onUpdate` callback
  33736. if (!this.state.isCreated) {
  33737. this.state.isCreated = true;
  33738. this.options.onCreate(data);
  33739. } else {
  33740. this.options.onUpdate(data);
  33741. }
  33742. }
  33743. /**
  33744. * Helper used to know if the given modifier is enabled.
  33745. * @method
  33746. * @memberof Popper.Utils
  33747. * @returns {Boolean}
  33748. */
  33749. function isModifierEnabled(modifiers, modifierName) {
  33750. return modifiers.some(function (_ref) {
  33751. var name = _ref.name,
  33752. enabled = _ref.enabled;
  33753. return enabled && name === modifierName;
  33754. });
  33755. }
  33756. /**
  33757. * Get the prefixed supported property name
  33758. * @method
  33759. * @memberof Popper.Utils
  33760. * @argument {String} property (camelCase)
  33761. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33762. */
  33763. function getSupportedPropertyName(property) {
  33764. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33765. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33766. for (var i = 0; i < prefixes.length; i++) {
  33767. var prefix = prefixes[i];
  33768. var toCheck = prefix ? '' + prefix + upperProp : property;
  33769. if (typeof document.body.style[toCheck] !== 'undefined') {
  33770. return toCheck;
  33771. }
  33772. }
  33773. return null;
  33774. }
  33775. /**
  33776. * Destroys the popper.
  33777. * @method
  33778. * @memberof Popper
  33779. */
  33780. function destroy() {
  33781. this.state.isDestroyed = true;
  33782. // touch DOM only if `applyStyle` modifier is enabled
  33783. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33784. this.popper.removeAttribute('x-placement');
  33785. this.popper.style.position = '';
  33786. this.popper.style.top = '';
  33787. this.popper.style.left = '';
  33788. this.popper.style.right = '';
  33789. this.popper.style.bottom = '';
  33790. this.popper.style.willChange = '';
  33791. this.popper.style[getSupportedPropertyName('transform')] = '';
  33792. }
  33793. this.disableEventListeners();
  33794. // remove the popper if user explicitly asked for the deletion on destroy
  33795. // do not use `remove` because IE11 doesn't support it
  33796. if (this.options.removeOnDestroy) {
  33797. this.popper.parentNode.removeChild(this.popper);
  33798. }
  33799. return this;
  33800. }
  33801. /**
  33802. * Get the window associated with the element
  33803. * @argument {Element} element
  33804. * @returns {Window}
  33805. */
  33806. function getWindow(element) {
  33807. var ownerDocument = element.ownerDocument;
  33808. return ownerDocument ? ownerDocument.defaultView : window;
  33809. }
  33810. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33811. var isBody = scrollParent.nodeName === 'BODY';
  33812. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33813. target.addEventListener(event, callback, { passive: true });
  33814. if (!isBody) {
  33815. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33816. }
  33817. scrollParents.push(target);
  33818. }
  33819. /**
  33820. * Setup needed event listeners used to update the popper position
  33821. * @method
  33822. * @memberof Popper.Utils
  33823. * @private
  33824. */
  33825. function setupEventListeners(reference, options, state, updateBound) {
  33826. // Resize event listener on window
  33827. state.updateBound = updateBound;
  33828. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33829. // Scroll event listener on scroll parents
  33830. var scrollElement = getScrollParent(reference);
  33831. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33832. state.scrollElement = scrollElement;
  33833. state.eventsEnabled = true;
  33834. return state;
  33835. }
  33836. /**
  33837. * It will add resize/scroll events and start recalculating
  33838. * position of the popper element when they are triggered.
  33839. * @method
  33840. * @memberof Popper
  33841. */
  33842. function enableEventListeners() {
  33843. if (!this.state.eventsEnabled) {
  33844. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33845. }
  33846. }
  33847. /**
  33848. * Remove event listeners used to update the popper position
  33849. * @method
  33850. * @memberof Popper.Utils
  33851. * @private
  33852. */
  33853. function removeEventListeners(reference, state) {
  33854. // Remove resize event listener on window
  33855. getWindow(reference).removeEventListener('resize', state.updateBound);
  33856. // Remove scroll event listener on scroll parents
  33857. state.scrollParents.forEach(function (target) {
  33858. target.removeEventListener('scroll', state.updateBound);
  33859. });
  33860. // Reset state
  33861. state.updateBound = null;
  33862. state.scrollParents = [];
  33863. state.scrollElement = null;
  33864. state.eventsEnabled = false;
  33865. return state;
  33866. }
  33867. /**
  33868. * It will remove resize/scroll events and won't recalculate popper position
  33869. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33870. * unless you call `update` method manually.
  33871. * @method
  33872. * @memberof Popper
  33873. */
  33874. function disableEventListeners() {
  33875. if (this.state.eventsEnabled) {
  33876. cancelAnimationFrame(this.scheduleUpdate);
  33877. this.state = removeEventListeners(this.reference, this.state);
  33878. }
  33879. }
  33880. /**
  33881. * Tells if a given input is a number
  33882. * @method
  33883. * @memberof Popper.Utils
  33884. * @param {*} input to check
  33885. * @return {Boolean}
  33886. */
  33887. function isNumeric(n) {
  33888. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33889. }
  33890. /**
  33891. * Set the style to the given popper
  33892. * @method
  33893. * @memberof Popper.Utils
  33894. * @argument {Element} element - Element to apply the style to
  33895. * @argument {Object} styles
  33896. * Object with a list of properties and values which will be applied to the element
  33897. */
  33898. function setStyles(element, styles) {
  33899. Object.keys(styles).forEach(function (prop) {
  33900. var unit = '';
  33901. // add unit if the value is numeric and is one of the following
  33902. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33903. unit = 'px';
  33904. }
  33905. element.style[prop] = styles[prop] + unit;
  33906. });
  33907. }
  33908. /**
  33909. * Set the attributes to the given popper
  33910. * @method
  33911. * @memberof Popper.Utils
  33912. * @argument {Element} element - Element to apply the attributes to
  33913. * @argument {Object} styles
  33914. * Object with a list of properties and values which will be applied to the element
  33915. */
  33916. function setAttributes(element, attributes) {
  33917. Object.keys(attributes).forEach(function (prop) {
  33918. var value = attributes[prop];
  33919. if (value !== false) {
  33920. element.setAttribute(prop, attributes[prop]);
  33921. } else {
  33922. element.removeAttribute(prop);
  33923. }
  33924. });
  33925. }
  33926. /**
  33927. * @function
  33928. * @memberof Modifiers
  33929. * @argument {Object} data - The data object generated by `update` method
  33930. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33931. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33932. * @argument {Object} options - Modifiers configuration and options
  33933. * @returns {Object} The same data object
  33934. */
  33935. function applyStyle(data) {
  33936. // any property present in `data.styles` will be applied to the popper,
  33937. // in this way we can make the 3rd party modifiers add custom styles to it
  33938. // Be aware, modifiers could override the properties defined in the previous
  33939. // lines of this modifier!
  33940. setStyles(data.instance.popper, data.styles);
  33941. // any property present in `data.attributes` will be applied to the popper,
  33942. // they will be set as HTML attributes of the element
  33943. setAttributes(data.instance.popper, data.attributes);
  33944. // if arrowElement is defined and arrowStyles has some properties
  33945. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33946. setStyles(data.arrowElement, data.arrowStyles);
  33947. }
  33948. return data;
  33949. }
  33950. /**
  33951. * Set the x-placement attribute before everything else because it could be used
  33952. * to add margins to the popper margins needs to be calculated to get the
  33953. * correct popper offsets.
  33954. * @method
  33955. * @memberof Popper.modifiers
  33956. * @param {HTMLElement} reference - The reference element used to position the popper
  33957. * @param {HTMLElement} popper - The HTML element used as popper
  33958. * @param {Object} options - Popper.js options
  33959. */
  33960. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33961. // compute reference element offsets
  33962. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33963. // compute auto placement, store placement inside the data object,
  33964. // modifiers will be able to edit `placement` if needed
  33965. // and refer to originalPlacement to know the original value
  33966. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  33967. popper.setAttribute('x-placement', placement);
  33968. // Apply `position` to popper before anything else because
  33969. // without the position applied we can't guarantee correct computations
  33970. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  33971. return options;
  33972. }
  33973. /**
  33974. * @function
  33975. * @memberof Popper.Utils
  33976. * @argument {Object} data - The data object generated by `update` method
  33977. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  33978. * @returns {Object} The popper's position offsets rounded
  33979. *
  33980. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  33981. * good as it can be within reason.
  33982. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  33983. *
  33984. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  33985. * as well on High DPI screens).
  33986. *
  33987. * Firefox prefers no rounding for positioning and does not have blurriness on
  33988. * high DPI screens.
  33989. *
  33990. * Only horizontal placement and left/right values need to be considered.
  33991. */
  33992. function getRoundedOffsets(data, shouldRound) {
  33993. var _data$offsets = data.offsets,
  33994. popper = _data$offsets.popper,
  33995. reference = _data$offsets.reference;
  33996. var round = Math.round,
  33997. floor = Math.floor;
  33998. var noRound = function noRound(v) {
  33999. return v;
  34000. };
  34001. var referenceWidth = round(reference.width);
  34002. var popperWidth = round(popper.width);
  34003. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34004. var isVariation = data.placement.indexOf('-') !== -1;
  34005. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34006. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34007. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34008. var verticalToInteger = !shouldRound ? noRound : round;
  34009. return {
  34010. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34011. top: verticalToInteger(popper.top),
  34012. bottom: verticalToInteger(popper.bottom),
  34013. right: horizontalToInteger(popper.right)
  34014. };
  34015. }
  34016. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34017. /**
  34018. * @function
  34019. * @memberof Modifiers
  34020. * @argument {Object} data - The data object generated by `update` method
  34021. * @argument {Object} options - Modifiers configuration and options
  34022. * @returns {Object} The data object, properly modified
  34023. */
  34024. function computeStyle(data, options) {
  34025. var x = options.x,
  34026. y = options.y;
  34027. var popper = data.offsets.popper;
  34028. // Remove this legacy support in Popper.js v2
  34029. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34030. return modifier.name === 'applyStyle';
  34031. }).gpuAcceleration;
  34032. if (legacyGpuAccelerationOption !== undefined) {
  34033. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34034. }
  34035. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34036. var offsetParent = getOffsetParent(data.instance.popper);
  34037. var offsetParentRect = getBoundingClientRect(offsetParent);
  34038. // Styles
  34039. var styles = {
  34040. position: popper.position
  34041. };
  34042. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34043. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34044. var sideB = y === 'right' ? 'left' : 'right';
  34045. // if gpuAcceleration is set to `true` and transform is supported,
  34046. // we use `translate3d` to apply the position to the popper we
  34047. // automatically use the supported prefixed version if needed
  34048. var prefixedProperty = getSupportedPropertyName('transform');
  34049. // now, let's make a step back and look at this code closely (wtf?)
  34050. // If the content of the popper grows once it's been positioned, it
  34051. // may happen that the popper gets misplaced because of the new content
  34052. // overflowing its reference element
  34053. // To avoid this problem, we provide two options (x and y), which allow
  34054. // the consumer to define the offset origin.
  34055. // If we position a popper on top of a reference element, we can set
  34056. // `x` to `top` to make the popper grow towards its top instead of
  34057. // its bottom.
  34058. var left = void 0,
  34059. top = void 0;
  34060. if (sideA === 'bottom') {
  34061. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34062. // and not the bottom of the html element
  34063. if (offsetParent.nodeName === 'HTML') {
  34064. top = -offsetParent.clientHeight + offsets.bottom;
  34065. } else {
  34066. top = -offsetParentRect.height + offsets.bottom;
  34067. }
  34068. } else {
  34069. top = offsets.top;
  34070. }
  34071. if (sideB === 'right') {
  34072. if (offsetParent.nodeName === 'HTML') {
  34073. left = -offsetParent.clientWidth + offsets.right;
  34074. } else {
  34075. left = -offsetParentRect.width + offsets.right;
  34076. }
  34077. } else {
  34078. left = offsets.left;
  34079. }
  34080. if (gpuAcceleration && prefixedProperty) {
  34081. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34082. styles[sideA] = 0;
  34083. styles[sideB] = 0;
  34084. styles.willChange = 'transform';
  34085. } else {
  34086. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34087. var invertTop = sideA === 'bottom' ? -1 : 1;
  34088. var invertLeft = sideB === 'right' ? -1 : 1;
  34089. styles[sideA] = top * invertTop;
  34090. styles[sideB] = left * invertLeft;
  34091. styles.willChange = sideA + ', ' + sideB;
  34092. }
  34093. // Attributes
  34094. var attributes = {
  34095. 'x-placement': data.placement
  34096. };
  34097. // Update `data` attributes, styles and arrowStyles
  34098. data.attributes = _extends({}, attributes, data.attributes);
  34099. data.styles = _extends({}, styles, data.styles);
  34100. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34101. return data;
  34102. }
  34103. /**
  34104. * Helper used to know if the given modifier depends from another one.<br />
  34105. * It checks if the needed modifier is listed and enabled.
  34106. * @method
  34107. * @memberof Popper.Utils
  34108. * @param {Array} modifiers - list of modifiers
  34109. * @param {String} requestingName - name of requesting modifier
  34110. * @param {String} requestedName - name of requested modifier
  34111. * @returns {Boolean}
  34112. */
  34113. function isModifierRequired(modifiers, requestingName, requestedName) {
  34114. var requesting = find(modifiers, function (_ref) {
  34115. var name = _ref.name;
  34116. return name === requestingName;
  34117. });
  34118. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34119. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34120. });
  34121. if (!isRequired) {
  34122. var _requesting = '`' + requestingName + '`';
  34123. var requested = '`' + requestedName + '`';
  34124. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34125. }
  34126. return isRequired;
  34127. }
  34128. /**
  34129. * @function
  34130. * @memberof Modifiers
  34131. * @argument {Object} data - The data object generated by update method
  34132. * @argument {Object} options - Modifiers configuration and options
  34133. * @returns {Object} The data object, properly modified
  34134. */
  34135. function arrow(data, options) {
  34136. var _data$offsets$arrow;
  34137. // arrow depends on keepTogether in order to work
  34138. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34139. return data;
  34140. }
  34141. var arrowElement = options.element;
  34142. // if arrowElement is a string, suppose it's a CSS selector
  34143. if (typeof arrowElement === 'string') {
  34144. arrowElement = data.instance.popper.querySelector(arrowElement);
  34145. // if arrowElement is not found, don't run the modifier
  34146. if (!arrowElement) {
  34147. return data;
  34148. }
  34149. } else {
  34150. // if the arrowElement isn't a query selector we must check that the
  34151. // provided DOM node is child of its popper node
  34152. if (!data.instance.popper.contains(arrowElement)) {
  34153. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34154. return data;
  34155. }
  34156. }
  34157. var placement = data.placement.split('-')[0];
  34158. var _data$offsets = data.offsets,
  34159. popper = _data$offsets.popper,
  34160. reference = _data$offsets.reference;
  34161. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34162. var len = isVertical ? 'height' : 'width';
  34163. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34164. var side = sideCapitalized.toLowerCase();
  34165. var altSide = isVertical ? 'left' : 'top';
  34166. var opSide = isVertical ? 'bottom' : 'right';
  34167. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34168. //
  34169. // extends keepTogether behavior making sure the popper and its
  34170. // reference have enough pixels in conjunction
  34171. //
  34172. // top/left side
  34173. if (reference[opSide] - arrowElementSize < popper[side]) {
  34174. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34175. }
  34176. // bottom/right side
  34177. if (reference[side] + arrowElementSize > popper[opSide]) {
  34178. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34179. }
  34180. data.offsets.popper = getClientRect(data.offsets.popper);
  34181. // compute center of the popper
  34182. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34183. // Compute the sideValue using the updated popper offsets
  34184. // take popper margin in account because we don't have this info available
  34185. var css = getStyleComputedProperty(data.instance.popper);
  34186. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34187. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34188. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34189. // prevent arrowElement from being placed not contiguously to its popper
  34190. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34191. data.arrowElement = arrowElement;
  34192. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34193. return data;
  34194. }
  34195. /**
  34196. * Get the opposite placement variation of the given one
  34197. * @method
  34198. * @memberof Popper.Utils
  34199. * @argument {String} placement variation
  34200. * @returns {String} flipped placement variation
  34201. */
  34202. function getOppositeVariation(variation) {
  34203. if (variation === 'end') {
  34204. return 'start';
  34205. } else if (variation === 'start') {
  34206. return 'end';
  34207. }
  34208. return variation;
  34209. }
  34210. /**
  34211. * List of accepted placements to use as values of the `placement` option.<br />
  34212. * Valid placements are:
  34213. * - `auto`
  34214. * - `top`
  34215. * - `right`
  34216. * - `bottom`
  34217. * - `left`
  34218. *
  34219. * Each placement can have a variation from this list:
  34220. * - `-start`
  34221. * - `-end`
  34222. *
  34223. * Variations are interpreted easily if you think of them as the left to right
  34224. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34225. * is right.<br />
  34226. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34227. *
  34228. * Some valid examples are:
  34229. * - `top-end` (on top of reference, right aligned)
  34230. * - `right-start` (on right of reference, top aligned)
  34231. * - `bottom` (on bottom, centered)
  34232. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34233. *
  34234. * @static
  34235. * @type {Array}
  34236. * @enum {String}
  34237. * @readonly
  34238. * @method placements
  34239. * @memberof Popper
  34240. */
  34241. 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'];
  34242. // Get rid of `auto` `auto-start` and `auto-end`
  34243. var validPlacements = placements.slice(3);
  34244. /**
  34245. * Given an initial placement, returns all the subsequent placements
  34246. * clockwise (or counter-clockwise).
  34247. *
  34248. * @method
  34249. * @memberof Popper.Utils
  34250. * @argument {String} placement - A valid placement (it accepts variations)
  34251. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34252. * @returns {Array} placements including their variations
  34253. */
  34254. function clockwise(placement) {
  34255. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34256. var index = validPlacements.indexOf(placement);
  34257. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34258. return counter ? arr.reverse() : arr;
  34259. }
  34260. var BEHAVIORS = {
  34261. FLIP: 'flip',
  34262. CLOCKWISE: 'clockwise',
  34263. COUNTERCLOCKWISE: 'counterclockwise'
  34264. };
  34265. /**
  34266. * @function
  34267. * @memberof Modifiers
  34268. * @argument {Object} data - The data object generated by update method
  34269. * @argument {Object} options - Modifiers configuration and options
  34270. * @returns {Object} The data object, properly modified
  34271. */
  34272. function flip(data, options) {
  34273. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34274. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34275. return data;
  34276. }
  34277. if (data.flipped && data.placement === data.originalPlacement) {
  34278. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34279. return data;
  34280. }
  34281. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34282. var placement = data.placement.split('-')[0];
  34283. var placementOpposite = getOppositePlacement(placement);
  34284. var variation = data.placement.split('-')[1] || '';
  34285. var flipOrder = [];
  34286. switch (options.behavior) {
  34287. case BEHAVIORS.FLIP:
  34288. flipOrder = [placement, placementOpposite];
  34289. break;
  34290. case BEHAVIORS.CLOCKWISE:
  34291. flipOrder = clockwise(placement);
  34292. break;
  34293. case BEHAVIORS.COUNTERCLOCKWISE:
  34294. flipOrder = clockwise(placement, true);
  34295. break;
  34296. default:
  34297. flipOrder = options.behavior;
  34298. }
  34299. flipOrder.forEach(function (step, index) {
  34300. if (placement !== step || flipOrder.length === index + 1) {
  34301. return data;
  34302. }
  34303. placement = data.placement.split('-')[0];
  34304. placementOpposite = getOppositePlacement(placement);
  34305. var popperOffsets = data.offsets.popper;
  34306. var refOffsets = data.offsets.reference;
  34307. // using floor because the reference offsets may contain decimals we are not going to consider here
  34308. var floor = Math.floor;
  34309. 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);
  34310. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34311. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34312. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34313. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34314. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34315. // flip the variation if required
  34316. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34317. // flips variation if reference element overflows boundaries
  34318. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34319. // flips variation if popper content overflows boundaries
  34320. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34321. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34322. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34323. // this boolean to detect any flip loop
  34324. data.flipped = true;
  34325. if (overlapsRef || overflowsBoundaries) {
  34326. placement = flipOrder[index + 1];
  34327. }
  34328. if (flippedVariation) {
  34329. variation = getOppositeVariation(variation);
  34330. }
  34331. data.placement = placement + (variation ? '-' + variation : '');
  34332. // this object contains `position`, we want to preserve it along with
  34333. // any additional property we may add in the future
  34334. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34335. data = runModifiers(data.instance.modifiers, data, 'flip');
  34336. }
  34337. });
  34338. return data;
  34339. }
  34340. /**
  34341. * @function
  34342. * @memberof Modifiers
  34343. * @argument {Object} data - The data object generated by update method
  34344. * @argument {Object} options - Modifiers configuration and options
  34345. * @returns {Object} The data object, properly modified
  34346. */
  34347. function keepTogether(data) {
  34348. var _data$offsets = data.offsets,
  34349. popper = _data$offsets.popper,
  34350. reference = _data$offsets.reference;
  34351. var placement = data.placement.split('-')[0];
  34352. var floor = Math.floor;
  34353. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34354. var side = isVertical ? 'right' : 'bottom';
  34355. var opSide = isVertical ? 'left' : 'top';
  34356. var measurement = isVertical ? 'width' : 'height';
  34357. if (popper[side] < floor(reference[opSide])) {
  34358. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34359. }
  34360. if (popper[opSide] > floor(reference[side])) {
  34361. data.offsets.popper[opSide] = floor(reference[side]);
  34362. }
  34363. return data;
  34364. }
  34365. /**
  34366. * Converts a string containing value + unit into a px value number
  34367. * @function
  34368. * @memberof {modifiers~offset}
  34369. * @private
  34370. * @argument {String} str - Value + unit string
  34371. * @argument {String} measurement - `height` or `width`
  34372. * @argument {Object} popperOffsets
  34373. * @argument {Object} referenceOffsets
  34374. * @returns {Number|String}
  34375. * Value in pixels, or original string if no values were extracted
  34376. */
  34377. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34378. // separate value from unit
  34379. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34380. var value = +split[1];
  34381. var unit = split[2];
  34382. // If it's not a number it's an operator, I guess
  34383. if (!value) {
  34384. return str;
  34385. }
  34386. if (unit.indexOf('%') === 0) {
  34387. var element = void 0;
  34388. switch (unit) {
  34389. case '%p':
  34390. element = popperOffsets;
  34391. break;
  34392. case '%':
  34393. case '%r':
  34394. default:
  34395. element = referenceOffsets;
  34396. }
  34397. var rect = getClientRect(element);
  34398. return rect[measurement] / 100 * value;
  34399. } else if (unit === 'vh' || unit === 'vw') {
  34400. // if is a vh or vw, we calculate the size based on the viewport
  34401. var size = void 0;
  34402. if (unit === 'vh') {
  34403. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34404. } else {
  34405. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34406. }
  34407. return size / 100 * value;
  34408. } else {
  34409. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34410. // if is an implicit unit, it's px, and we return just the value
  34411. return value;
  34412. }
  34413. }
  34414. /**
  34415. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34416. * @function
  34417. * @memberof {modifiers~offset}
  34418. * @private
  34419. * @argument {String} offset
  34420. * @argument {Object} popperOffsets
  34421. * @argument {Object} referenceOffsets
  34422. * @argument {String} basePlacement
  34423. * @returns {Array} a two cells array with x and y offsets in numbers
  34424. */
  34425. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34426. var offsets = [0, 0];
  34427. // Use height if placement is left or right and index is 0 otherwise use width
  34428. // in this way the first offset will use an axis and the second one
  34429. // will use the other one
  34430. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34431. // Split the offset string to obtain a list of values and operands
  34432. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34433. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34434. return frag.trim();
  34435. });
  34436. // Detect if the offset string contains a pair of values or a single one
  34437. // they could be separated by comma or space
  34438. var divider = fragments.indexOf(find(fragments, function (frag) {
  34439. return frag.search(/,|\s/) !== -1;
  34440. }));
  34441. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34442. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34443. }
  34444. // If divider is found, we divide the list of values and operands to divide
  34445. // them by ofset X and Y.
  34446. var splitRegex = /\s*,\s*|\s+/;
  34447. 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];
  34448. // Convert the values with units to absolute pixels to allow our computations
  34449. ops = ops.map(function (op, index) {
  34450. // Most of the units rely on the orientation of the popper
  34451. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34452. var mergeWithPrevious = false;
  34453. return op
  34454. // This aggregates any `+` or `-` sign that aren't considered operators
  34455. // e.g.: 10 + +5 => [10, +, +5]
  34456. .reduce(function (a, b) {
  34457. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34458. a[a.length - 1] = b;
  34459. mergeWithPrevious = true;
  34460. return a;
  34461. } else if (mergeWithPrevious) {
  34462. a[a.length - 1] += b;
  34463. mergeWithPrevious = false;
  34464. return a;
  34465. } else {
  34466. return a.concat(b);
  34467. }
  34468. }, [])
  34469. // Here we convert the string values into number values (in px)
  34470. .map(function (str) {
  34471. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34472. });
  34473. });
  34474. // Loop trough the offsets arrays and execute the operations
  34475. ops.forEach(function (op, index) {
  34476. op.forEach(function (frag, index2) {
  34477. if (isNumeric(frag)) {
  34478. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34479. }
  34480. });
  34481. });
  34482. return offsets;
  34483. }
  34484. /**
  34485. * @function
  34486. * @memberof Modifiers
  34487. * @argument {Object} data - The data object generated by update method
  34488. * @argument {Object} options - Modifiers configuration and options
  34489. * @argument {Number|String} options.offset=0
  34490. * The offset value as described in the modifier description
  34491. * @returns {Object} The data object, properly modified
  34492. */
  34493. function offset(data, _ref) {
  34494. var offset = _ref.offset;
  34495. var placement = data.placement,
  34496. _data$offsets = data.offsets,
  34497. popper = _data$offsets.popper,
  34498. reference = _data$offsets.reference;
  34499. var basePlacement = placement.split('-')[0];
  34500. var offsets = void 0;
  34501. if (isNumeric(+offset)) {
  34502. offsets = [+offset, 0];
  34503. } else {
  34504. offsets = parseOffset(offset, popper, reference, basePlacement);
  34505. }
  34506. if (basePlacement === 'left') {
  34507. popper.top += offsets[0];
  34508. popper.left -= offsets[1];
  34509. } else if (basePlacement === 'right') {
  34510. popper.top += offsets[0];
  34511. popper.left += offsets[1];
  34512. } else if (basePlacement === 'top') {
  34513. popper.left += offsets[0];
  34514. popper.top -= offsets[1];
  34515. } else if (basePlacement === 'bottom') {
  34516. popper.left += offsets[0];
  34517. popper.top += offsets[1];
  34518. }
  34519. data.popper = popper;
  34520. return data;
  34521. }
  34522. /**
  34523. * @function
  34524. * @memberof Modifiers
  34525. * @argument {Object} data - The data object generated by `update` method
  34526. * @argument {Object} options - Modifiers configuration and options
  34527. * @returns {Object} The data object, properly modified
  34528. */
  34529. function preventOverflow(data, options) {
  34530. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34531. // If offsetParent is the reference element, we really want to
  34532. // go one step up and use the next offsetParent as reference to
  34533. // avoid to make this modifier completely useless and look like broken
  34534. if (data.instance.reference === boundariesElement) {
  34535. boundariesElement = getOffsetParent(boundariesElement);
  34536. }
  34537. // NOTE: DOM access here
  34538. // resets the popper's position so that the document size can be calculated excluding
  34539. // the size of the popper element itself
  34540. var transformProp = getSupportedPropertyName('transform');
  34541. var popperStyles = data.instance.popper.style; // assignment to help minification
  34542. var top = popperStyles.top,
  34543. left = popperStyles.left,
  34544. transform = popperStyles[transformProp];
  34545. popperStyles.top = '';
  34546. popperStyles.left = '';
  34547. popperStyles[transformProp] = '';
  34548. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34549. // NOTE: DOM access here
  34550. // restores the original style properties after the offsets have been computed
  34551. popperStyles.top = top;
  34552. popperStyles.left = left;
  34553. popperStyles[transformProp] = transform;
  34554. options.boundaries = boundaries;
  34555. var order = options.priority;
  34556. var popper = data.offsets.popper;
  34557. var check = {
  34558. primary: function primary(placement) {
  34559. var value = popper[placement];
  34560. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34561. value = Math.max(popper[placement], boundaries[placement]);
  34562. }
  34563. return defineProperty({}, placement, value);
  34564. },
  34565. secondary: function secondary(placement) {
  34566. var mainSide = placement === 'right' ? 'left' : 'top';
  34567. var value = popper[mainSide];
  34568. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34569. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34570. }
  34571. return defineProperty({}, mainSide, value);
  34572. }
  34573. };
  34574. order.forEach(function (placement) {
  34575. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34576. popper = _extends({}, popper, check[side](placement));
  34577. });
  34578. data.offsets.popper = popper;
  34579. return data;
  34580. }
  34581. /**
  34582. * @function
  34583. * @memberof Modifiers
  34584. * @argument {Object} data - The data object generated by `update` method
  34585. * @argument {Object} options - Modifiers configuration and options
  34586. * @returns {Object} The data object, properly modified
  34587. */
  34588. function shift(data) {
  34589. var placement = data.placement;
  34590. var basePlacement = placement.split('-')[0];
  34591. var shiftvariation = placement.split('-')[1];
  34592. // if shift shiftvariation is specified, run the modifier
  34593. if (shiftvariation) {
  34594. var _data$offsets = data.offsets,
  34595. reference = _data$offsets.reference,
  34596. popper = _data$offsets.popper;
  34597. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34598. var side = isVertical ? 'left' : 'top';
  34599. var measurement = isVertical ? 'width' : 'height';
  34600. var shiftOffsets = {
  34601. start: defineProperty({}, side, reference[side]),
  34602. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34603. };
  34604. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  34605. }
  34606. return data;
  34607. }
  34608. /**
  34609. * @function
  34610. * @memberof Modifiers
  34611. * @argument {Object} data - The data object generated by update method
  34612. * @argument {Object} options - Modifiers configuration and options
  34613. * @returns {Object} The data object, properly modified
  34614. */
  34615. function hide(data) {
  34616. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34617. return data;
  34618. }
  34619. var refRect = data.offsets.reference;
  34620. var bound = find(data.instance.modifiers, function (modifier) {
  34621. return modifier.name === 'preventOverflow';
  34622. }).boundaries;
  34623. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34624. // Avoid unnecessary DOM access if visibility hasn't changed
  34625. if (data.hide === true) {
  34626. return data;
  34627. }
  34628. data.hide = true;
  34629. data.attributes['x-out-of-boundaries'] = '';
  34630. } else {
  34631. // Avoid unnecessary DOM access if visibility hasn't changed
  34632. if (data.hide === false) {
  34633. return data;
  34634. }
  34635. data.hide = false;
  34636. data.attributes['x-out-of-boundaries'] = false;
  34637. }
  34638. return data;
  34639. }
  34640. /**
  34641. * @function
  34642. * @memberof Modifiers
  34643. * @argument {Object} data - The data object generated by `update` method
  34644. * @argument {Object} options - Modifiers configuration and options
  34645. * @returns {Object} The data object, properly modified
  34646. */
  34647. function inner(data) {
  34648. var placement = data.placement;
  34649. var basePlacement = placement.split('-')[0];
  34650. var _data$offsets = data.offsets,
  34651. popper = _data$offsets.popper,
  34652. reference = _data$offsets.reference;
  34653. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34654. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34655. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34656. data.placement = getOppositePlacement(placement);
  34657. data.offsets.popper = getClientRect(popper);
  34658. return data;
  34659. }
  34660. /**
  34661. * Modifier function, each modifier can have a function of this type assigned
  34662. * to its `fn` property.<br />
  34663. * These functions will be called on each update, this means that you must
  34664. * make sure they are performant enough to avoid performance bottlenecks.
  34665. *
  34666. * @function ModifierFn
  34667. * @argument {dataObject} data - The data object generated by `update` method
  34668. * @argument {Object} options - Modifiers configuration and options
  34669. * @returns {dataObject} The data object, properly modified
  34670. */
  34671. /**
  34672. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34673. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34674. * needed by the library.
  34675. *
  34676. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34677. * All the other properties are configurations that could be tweaked.
  34678. * @namespace modifiers
  34679. */
  34680. var modifiers = {
  34681. /**
  34682. * Modifier used to shift the popper on the start or end of its reference
  34683. * element.<br />
  34684. * It will read the variation of the `placement` property.<br />
  34685. * It can be one either `-end` or `-start`.
  34686. * @memberof modifiers
  34687. * @inner
  34688. */
  34689. shift: {
  34690. /** @prop {number} order=100 - Index used to define the order of execution */
  34691. order: 100,
  34692. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34693. enabled: true,
  34694. /** @prop {ModifierFn} */
  34695. fn: shift
  34696. },
  34697. /**
  34698. * The `offset` modifier can shift your popper on both its axis.
  34699. *
  34700. * It accepts the following units:
  34701. * - `px` or unit-less, interpreted as pixels
  34702. * - `%` or `%r`, percentage relative to the length of the reference element
  34703. * - `%p`, percentage relative to the length of the popper element
  34704. * - `vw`, CSS viewport width unit
  34705. * - `vh`, CSS viewport height unit
  34706. *
  34707. * For length is intended the main axis relative to the placement of the popper.<br />
  34708. * This means that if the placement is `top` or `bottom`, the length will be the
  34709. * `width`. In case of `left` or `right`, it will be the `height`.
  34710. *
  34711. * You can provide a single value (as `Number` or `String`), or a pair of values
  34712. * as `String` divided by a comma or one (or more) white spaces.<br />
  34713. * The latter is a deprecated method because it leads to confusion and will be
  34714. * removed in v2.<br />
  34715. * Additionally, it accepts additions and subtractions between different units.
  34716. * Note that multiplications and divisions aren't supported.
  34717. *
  34718. * Valid examples are:
  34719. * ```
  34720. * 10
  34721. * '10%'
  34722. * '10, 10'
  34723. * '10%, 10'
  34724. * '10 + 10%'
  34725. * '10 - 5vh + 3%'
  34726. * '-10px + 5vh, 5px - 6%'
  34727. * ```
  34728. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34729. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34730. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34731. *
  34732. * @memberof modifiers
  34733. * @inner
  34734. */
  34735. offset: {
  34736. /** @prop {number} order=200 - Index used to define the order of execution */
  34737. order: 200,
  34738. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34739. enabled: true,
  34740. /** @prop {ModifierFn} */
  34741. fn: offset,
  34742. /** @prop {Number|String} offset=0
  34743. * The offset value as described in the modifier description
  34744. */
  34745. offset: 0
  34746. },
  34747. /**
  34748. * Modifier used to prevent the popper from being positioned outside the boundary.
  34749. *
  34750. * A scenario exists where the reference itself is not within the boundaries.<br />
  34751. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34752. * In this case we need to decide whether the popper should either:
  34753. *
  34754. * - detach from the reference and remain "trapped" in the boundaries, or
  34755. * - if it should ignore the boundary and "escape with its reference"
  34756. *
  34757. * When `escapeWithReference` is set to`true` and reference is completely
  34758. * outside its boundaries, the popper will overflow (or completely leave)
  34759. * the boundaries in order to remain attached to the edge of the reference.
  34760. *
  34761. * @memberof modifiers
  34762. * @inner
  34763. */
  34764. preventOverflow: {
  34765. /** @prop {number} order=300 - Index used to define the order of execution */
  34766. order: 300,
  34767. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34768. enabled: true,
  34769. /** @prop {ModifierFn} */
  34770. fn: preventOverflow,
  34771. /**
  34772. * @prop {Array} [priority=['left','right','top','bottom']]
  34773. * Popper will try to prevent overflow following these priorities by default,
  34774. * then, it could overflow on the left and on top of the `boundariesElement`
  34775. */
  34776. priority: ['left', 'right', 'top', 'bottom'],
  34777. /**
  34778. * @prop {number} padding=5
  34779. * Amount of pixel used to define a minimum distance between the boundaries
  34780. * and the popper. This makes sure the popper always has a little padding
  34781. * between the edges of its container
  34782. */
  34783. padding: 5,
  34784. /**
  34785. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34786. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34787. * `viewport` or any DOM element.
  34788. */
  34789. boundariesElement: 'scrollParent'
  34790. },
  34791. /**
  34792. * Modifier used to make sure the reference and its popper stay near each other
  34793. * without leaving any gap between the two. Especially useful when the arrow is
  34794. * enabled and you want to ensure that it points to its reference element.
  34795. * It cares only about the first axis. You can still have poppers with margin
  34796. * between the popper and its reference element.
  34797. * @memberof modifiers
  34798. * @inner
  34799. */
  34800. keepTogether: {
  34801. /** @prop {number} order=400 - Index used to define the order of execution */
  34802. order: 400,
  34803. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34804. enabled: true,
  34805. /** @prop {ModifierFn} */
  34806. fn: keepTogether
  34807. },
  34808. /**
  34809. * This modifier is used to move the `arrowElement` of the popper to make
  34810. * sure it is positioned between the reference element and its popper element.
  34811. * It will read the outer size of the `arrowElement` node to detect how many
  34812. * pixels of conjunction are needed.
  34813. *
  34814. * It has no effect if no `arrowElement` is provided.
  34815. * @memberof modifiers
  34816. * @inner
  34817. */
  34818. arrow: {
  34819. /** @prop {number} order=500 - Index used to define the order of execution */
  34820. order: 500,
  34821. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34822. enabled: true,
  34823. /** @prop {ModifierFn} */
  34824. fn: arrow,
  34825. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34826. element: '[x-arrow]'
  34827. },
  34828. /**
  34829. * Modifier used to flip the popper's placement when it starts to overlap its
  34830. * reference element.
  34831. *
  34832. * Requires the `preventOverflow` modifier before it in order to work.
  34833. *
  34834. * **NOTE:** this modifier will interrupt the current update cycle and will
  34835. * restart it if it detects the need to flip the placement.
  34836. * @memberof modifiers
  34837. * @inner
  34838. */
  34839. flip: {
  34840. /** @prop {number} order=600 - Index used to define the order of execution */
  34841. order: 600,
  34842. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34843. enabled: true,
  34844. /** @prop {ModifierFn} */
  34845. fn: flip,
  34846. /**
  34847. * @prop {String|Array} behavior='flip'
  34848. * The behavior used to change the popper's placement. It can be one of
  34849. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34850. * placements (with optional variations)
  34851. */
  34852. behavior: 'flip',
  34853. /**
  34854. * @prop {number} padding=5
  34855. * The popper will flip if it hits the edges of the `boundariesElement`
  34856. */
  34857. padding: 5,
  34858. /**
  34859. * @prop {String|HTMLElement} boundariesElement='viewport'
  34860. * The element which will define the boundaries of the popper position.
  34861. * The popper will never be placed outside of the defined boundaries
  34862. * (except if `keepTogether` is enabled)
  34863. */
  34864. boundariesElement: 'viewport',
  34865. /**
  34866. * @prop {Boolean} flipVariations=false
  34867. * The popper will switch placement variation between `-start` and `-end` when
  34868. * the reference element overlaps its boundaries.
  34869. *
  34870. * The original placement should have a set variation.
  34871. */
  34872. flipVariations: false,
  34873. /**
  34874. * @prop {Boolean} flipVariationsByContent=false
  34875. * The popper will switch placement variation between `-start` and `-end` when
  34876. * the popper element overlaps its reference boundaries.
  34877. *
  34878. * The original placement should have a set variation.
  34879. */
  34880. flipVariationsByContent: false
  34881. },
  34882. /**
  34883. * Modifier used to make the popper flow toward the inner of the reference element.
  34884. * By default, when this modifier is disabled, the popper will be placed outside
  34885. * the reference element.
  34886. * @memberof modifiers
  34887. * @inner
  34888. */
  34889. inner: {
  34890. /** @prop {number} order=700 - Index used to define the order of execution */
  34891. order: 700,
  34892. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34893. enabled: false,
  34894. /** @prop {ModifierFn} */
  34895. fn: inner
  34896. },
  34897. /**
  34898. * Modifier used to hide the popper when its reference element is outside of the
  34899. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34900. * be used to hide with a CSS selector the popper when its reference is
  34901. * out of boundaries.
  34902. *
  34903. * Requires the `preventOverflow` modifier before it in order to work.
  34904. * @memberof modifiers
  34905. * @inner
  34906. */
  34907. hide: {
  34908. /** @prop {number} order=800 - Index used to define the order of execution */
  34909. order: 800,
  34910. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34911. enabled: true,
  34912. /** @prop {ModifierFn} */
  34913. fn: hide
  34914. },
  34915. /**
  34916. * Computes the style that will be applied to the popper element to gets
  34917. * properly positioned.
  34918. *
  34919. * Note that this modifier will not touch the DOM, it just prepares the styles
  34920. * so that `applyStyle` modifier can apply it. This separation is useful
  34921. * in case you need to replace `applyStyle` with a custom implementation.
  34922. *
  34923. * This modifier has `850` as `order` value to maintain backward compatibility
  34924. * with previous versions of Popper.js. Expect the modifiers ordering method
  34925. * to change in future major versions of the library.
  34926. *
  34927. * @memberof modifiers
  34928. * @inner
  34929. */
  34930. computeStyle: {
  34931. /** @prop {number} order=850 - Index used to define the order of execution */
  34932. order: 850,
  34933. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34934. enabled: true,
  34935. /** @prop {ModifierFn} */
  34936. fn: computeStyle,
  34937. /**
  34938. * @prop {Boolean} gpuAcceleration=true
  34939. * If true, it uses the CSS 3D transformation to position the popper.
  34940. * Otherwise, it will use the `top` and `left` properties
  34941. */
  34942. gpuAcceleration: true,
  34943. /**
  34944. * @prop {string} [x='bottom']
  34945. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34946. * Change this if your popper should grow in a direction different from `bottom`
  34947. */
  34948. x: 'bottom',
  34949. /**
  34950. * @prop {string} [x='left']
  34951. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34952. * Change this if your popper should grow in a direction different from `right`
  34953. */
  34954. y: 'right'
  34955. },
  34956. /**
  34957. * Applies the computed styles to the popper element.
  34958. *
  34959. * All the DOM manipulations are limited to this modifier. This is useful in case
  34960. * you want to integrate Popper.js inside a framework or view library and you
  34961. * want to delegate all the DOM manipulations to it.
  34962. *
  34963. * Note that if you disable this modifier, you must make sure the popper element
  34964. * has its position set to `absolute` before Popper.js can do its work!
  34965. *
  34966. * Just disable this modifier and define your own to achieve the desired effect.
  34967. *
  34968. * @memberof modifiers
  34969. * @inner
  34970. */
  34971. applyStyle: {
  34972. /** @prop {number} order=900 - Index used to define the order of execution */
  34973. order: 900,
  34974. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34975. enabled: true,
  34976. /** @prop {ModifierFn} */
  34977. fn: applyStyle,
  34978. /** @prop {Function} */
  34979. onLoad: applyStyleOnLoad,
  34980. /**
  34981. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  34982. * @prop {Boolean} gpuAcceleration=true
  34983. * If true, it uses the CSS 3D transformation to position the popper.
  34984. * Otherwise, it will use the `top` and `left` properties
  34985. */
  34986. gpuAcceleration: undefined
  34987. }
  34988. };
  34989. /**
  34990. * The `dataObject` is an object containing all the information used by Popper.js.
  34991. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  34992. * @name dataObject
  34993. * @property {Object} data.instance The Popper.js instance
  34994. * @property {String} data.placement Placement applied to popper
  34995. * @property {String} data.originalPlacement Placement originally defined on init
  34996. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  34997. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  34998. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  34999. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35000. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35001. * @property {Object} data.boundaries Offsets of the popper boundaries
  35002. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35003. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35004. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35005. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35006. */
  35007. /**
  35008. * Default options provided to Popper.js constructor.<br />
  35009. * These can be overridden using the `options` argument of Popper.js.<br />
  35010. * To override an option, simply pass an object with the same
  35011. * structure of the `options` object, as the 3rd argument. For example:
  35012. * ```
  35013. * new Popper(ref, pop, {
  35014. * modifiers: {
  35015. * preventOverflow: { enabled: false }
  35016. * }
  35017. * })
  35018. * ```
  35019. * @type {Object}
  35020. * @static
  35021. * @memberof Popper
  35022. */
  35023. var Defaults = {
  35024. /**
  35025. * Popper's placement.
  35026. * @prop {Popper.placements} placement='bottom'
  35027. */
  35028. placement: 'bottom',
  35029. /**
  35030. * Set this to true if you want popper to position it self in 'fixed' mode
  35031. * @prop {Boolean} positionFixed=false
  35032. */
  35033. positionFixed: false,
  35034. /**
  35035. * Whether events (resize, scroll) are initially enabled.
  35036. * @prop {Boolean} eventsEnabled=true
  35037. */
  35038. eventsEnabled: true,
  35039. /**
  35040. * Set to true if you want to automatically remove the popper when
  35041. * you call the `destroy` method.
  35042. * @prop {Boolean} removeOnDestroy=false
  35043. */
  35044. removeOnDestroy: false,
  35045. /**
  35046. * Callback called when the popper is created.<br />
  35047. * By default, it is set to no-op.<br />
  35048. * Access Popper.js instance with `data.instance`.
  35049. * @prop {onCreate}
  35050. */
  35051. onCreate: function onCreate() {},
  35052. /**
  35053. * Callback called when the popper is updated. This callback is not called
  35054. * on the initialization/creation of the popper, but only on subsequent
  35055. * updates.<br />
  35056. * By default, it is set to no-op.<br />
  35057. * Access Popper.js instance with `data.instance`.
  35058. * @prop {onUpdate}
  35059. */
  35060. onUpdate: function onUpdate() {},
  35061. /**
  35062. * List of modifiers used to modify the offsets before they are applied to the popper.
  35063. * They provide most of the functionalities of Popper.js.
  35064. * @prop {modifiers}
  35065. */
  35066. modifiers: modifiers
  35067. };
  35068. /**
  35069. * @callback onCreate
  35070. * @param {dataObject} data
  35071. */
  35072. /**
  35073. * @callback onUpdate
  35074. * @param {dataObject} data
  35075. */
  35076. // Utils
  35077. // Methods
  35078. var Popper = function () {
  35079. /**
  35080. * Creates a new Popper.js instance.
  35081. * @class Popper
  35082. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35083. * @param {Element} popper - The HTML / XML element used as the popper
  35084. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35085. * @return {Object} instance - The generated Popper.js instance
  35086. */
  35087. function Popper(reference, popper) {
  35088. var _this = this;
  35089. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35090. classCallCheck(this, Popper);
  35091. this.scheduleUpdate = function () {
  35092. return requestAnimationFrame(_this.update);
  35093. };
  35094. // make update() debounced, so that it only runs at most once-per-tick
  35095. this.update = debounce(this.update.bind(this));
  35096. // with {} we create a new object with the options inside it
  35097. this.options = _extends({}, Popper.Defaults, options);
  35098. // init state
  35099. this.state = {
  35100. isDestroyed: false,
  35101. isCreated: false,
  35102. scrollParents: []
  35103. };
  35104. // get reference and popper elements (allow jQuery wrappers)
  35105. this.reference = reference && reference.jquery ? reference[0] : reference;
  35106. this.popper = popper && popper.jquery ? popper[0] : popper;
  35107. // Deep merge modifiers options
  35108. this.options.modifiers = {};
  35109. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35110. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35111. });
  35112. // Refactoring modifiers' list (Object => Array)
  35113. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35114. return _extends({
  35115. name: name
  35116. }, _this.options.modifiers[name]);
  35117. })
  35118. // sort the modifiers by order
  35119. .sort(function (a, b) {
  35120. return a.order - b.order;
  35121. });
  35122. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35123. // such code is executed in the same order of its modifier
  35124. // they could add new properties to their options configuration
  35125. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35126. this.modifiers.forEach(function (modifierOptions) {
  35127. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35128. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35129. }
  35130. });
  35131. // fire the first update to position the popper in the right place
  35132. this.update();
  35133. var eventsEnabled = this.options.eventsEnabled;
  35134. if (eventsEnabled) {
  35135. // setup event listeners, they will take care of update the position in specific situations
  35136. this.enableEventListeners();
  35137. }
  35138. this.state.eventsEnabled = eventsEnabled;
  35139. }
  35140. // We can't use class properties because they don't get listed in the
  35141. // class prototype and break stuff like Sinon stubs
  35142. createClass(Popper, [{
  35143. key: 'update',
  35144. value: function update$$1() {
  35145. return update.call(this);
  35146. }
  35147. }, {
  35148. key: 'destroy',
  35149. value: function destroy$$1() {
  35150. return destroy.call(this);
  35151. }
  35152. }, {
  35153. key: 'enableEventListeners',
  35154. value: function enableEventListeners$$1() {
  35155. return enableEventListeners.call(this);
  35156. }
  35157. }, {
  35158. key: 'disableEventListeners',
  35159. value: function disableEventListeners$$1() {
  35160. return disableEventListeners.call(this);
  35161. }
  35162. /**
  35163. * Schedules an update. It will run on the next UI update available.
  35164. * @method scheduleUpdate
  35165. * @memberof Popper
  35166. */
  35167. /**
  35168. * Collection of utilities useful when writing custom modifiers.
  35169. * Starting from version 1.7, this method is available only if you
  35170. * include `popper-utils.js` before `popper.js`.
  35171. *
  35172. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35173. * and will be removed in v2! Use the PopperUtils module directly instead.
  35174. * Due to the high instability of the methods contained in Utils, we can't
  35175. * guarantee them to follow semver. Use them at your own risk!
  35176. * @static
  35177. * @private
  35178. * @type {Object}
  35179. * @deprecated since version 1.8
  35180. * @member Utils
  35181. * @memberof Popper
  35182. */
  35183. }]);
  35184. return Popper;
  35185. }();
  35186. /**
  35187. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35188. * and lets you use it as replacement of a real DOM node.<br />
  35189. * You can use this method to position a popper relatively to a set of coordinates
  35190. * in case you don't have a DOM node to use as reference.
  35191. *
  35192. * ```
  35193. * new Popper(referenceObject, popperNode);
  35194. * ```
  35195. *
  35196. * NB: This feature isn't supported in Internet Explorer 10.
  35197. * @name referenceObject
  35198. * @property {Function} data.getBoundingClientRect
  35199. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35200. * @property {number} data.clientWidth
  35201. * An ES6 getter that will return the width of the virtual reference element.
  35202. * @property {number} data.clientHeight
  35203. * An ES6 getter that will return the height of the virtual reference element.
  35204. */
  35205. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35206. Popper.placements = placements;
  35207. Popper.Defaults = Defaults;
  35208. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35209. //# sourceMappingURL=popper.js.map
  35210. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35211. /***/ }),
  35212. /***/ "./node_modules/process/browser.js":
  35213. /*!*****************************************!*\
  35214. !*** ./node_modules/process/browser.js ***!
  35215. \*****************************************/
  35216. /*! no static exports found */
  35217. /***/ (function(module, exports) {
  35218. // shim for using process in browser
  35219. var process = module.exports = {};
  35220. // cached from whatever global is present so that test runners that stub it
  35221. // don't break things. But we need to wrap it in a try catch in case it is
  35222. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35223. // function because try/catches deoptimize in certain engines.
  35224. var cachedSetTimeout;
  35225. var cachedClearTimeout;
  35226. function defaultSetTimout() {
  35227. throw new Error('setTimeout has not been defined');
  35228. }
  35229. function defaultClearTimeout () {
  35230. throw new Error('clearTimeout has not been defined');
  35231. }
  35232. (function () {
  35233. try {
  35234. if (typeof setTimeout === 'function') {
  35235. cachedSetTimeout = setTimeout;
  35236. } else {
  35237. cachedSetTimeout = defaultSetTimout;
  35238. }
  35239. } catch (e) {
  35240. cachedSetTimeout = defaultSetTimout;
  35241. }
  35242. try {
  35243. if (typeof clearTimeout === 'function') {
  35244. cachedClearTimeout = clearTimeout;
  35245. } else {
  35246. cachedClearTimeout = defaultClearTimeout;
  35247. }
  35248. } catch (e) {
  35249. cachedClearTimeout = defaultClearTimeout;
  35250. }
  35251. } ())
  35252. function runTimeout(fun) {
  35253. if (cachedSetTimeout === setTimeout) {
  35254. //normal enviroments in sane situations
  35255. return setTimeout(fun, 0);
  35256. }
  35257. // if setTimeout wasn't available but was latter defined
  35258. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35259. cachedSetTimeout = setTimeout;
  35260. return setTimeout(fun, 0);
  35261. }
  35262. try {
  35263. // when when somebody has screwed with setTimeout but no I.E. maddness
  35264. return cachedSetTimeout(fun, 0);
  35265. } catch(e){
  35266. try {
  35267. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35268. return cachedSetTimeout.call(null, fun, 0);
  35269. } catch(e){
  35270. // 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
  35271. return cachedSetTimeout.call(this, fun, 0);
  35272. }
  35273. }
  35274. }
  35275. function runClearTimeout(marker) {
  35276. if (cachedClearTimeout === clearTimeout) {
  35277. //normal enviroments in sane situations
  35278. return clearTimeout(marker);
  35279. }
  35280. // if clearTimeout wasn't available but was latter defined
  35281. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35282. cachedClearTimeout = clearTimeout;
  35283. return clearTimeout(marker);
  35284. }
  35285. try {
  35286. // when when somebody has screwed with setTimeout but no I.E. maddness
  35287. return cachedClearTimeout(marker);
  35288. } catch (e){
  35289. try {
  35290. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35291. return cachedClearTimeout.call(null, marker);
  35292. } catch (e){
  35293. // 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.
  35294. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35295. return cachedClearTimeout.call(this, marker);
  35296. }
  35297. }
  35298. }
  35299. var queue = [];
  35300. var draining = false;
  35301. var currentQueue;
  35302. var queueIndex = -1;
  35303. function cleanUpNextTick() {
  35304. if (!draining || !currentQueue) {
  35305. return;
  35306. }
  35307. draining = false;
  35308. if (currentQueue.length) {
  35309. queue = currentQueue.concat(queue);
  35310. } else {
  35311. queueIndex = -1;
  35312. }
  35313. if (queue.length) {
  35314. drainQueue();
  35315. }
  35316. }
  35317. function drainQueue() {
  35318. if (draining) {
  35319. return;
  35320. }
  35321. var timeout = runTimeout(cleanUpNextTick);
  35322. draining = true;
  35323. var len = queue.length;
  35324. while(len) {
  35325. currentQueue = queue;
  35326. queue = [];
  35327. while (++queueIndex < len) {
  35328. if (currentQueue) {
  35329. currentQueue[queueIndex].run();
  35330. }
  35331. }
  35332. queueIndex = -1;
  35333. len = queue.length;
  35334. }
  35335. currentQueue = null;
  35336. draining = false;
  35337. runClearTimeout(timeout);
  35338. }
  35339. process.nextTick = function (fun) {
  35340. var args = new Array(arguments.length - 1);
  35341. if (arguments.length > 1) {
  35342. for (var i = 1; i < arguments.length; i++) {
  35343. args[i - 1] = arguments[i];
  35344. }
  35345. }
  35346. queue.push(new Item(fun, args));
  35347. if (queue.length === 1 && !draining) {
  35348. runTimeout(drainQueue);
  35349. }
  35350. };
  35351. // v8 likes predictible objects
  35352. function Item(fun, array) {
  35353. this.fun = fun;
  35354. this.array = array;
  35355. }
  35356. Item.prototype.run = function () {
  35357. this.fun.apply(null, this.array);
  35358. };
  35359. process.title = 'browser';
  35360. process.browser = true;
  35361. process.env = {};
  35362. process.argv = [];
  35363. process.version = ''; // empty string to avoid regexp issues
  35364. process.versions = {};
  35365. function noop() {}
  35366. process.on = noop;
  35367. process.addListener = noop;
  35368. process.once = noop;
  35369. process.off = noop;
  35370. process.removeListener = noop;
  35371. process.removeAllListeners = noop;
  35372. process.emit = noop;
  35373. process.prependListener = noop;
  35374. process.prependOnceListener = noop;
  35375. process.listeners = function (name) { return [] }
  35376. process.binding = function (name) {
  35377. throw new Error('process.binding is not supported');
  35378. };
  35379. process.cwd = function () { return '/' };
  35380. process.chdir = function (dir) {
  35381. throw new Error('process.chdir is not supported');
  35382. };
  35383. process.umask = function() { return 0; };
  35384. /***/ }),
  35385. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35386. /*!***************************************************!*\
  35387. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35388. \***************************************************/
  35389. /*! no static exports found */
  35390. /***/ (function(module, exports, __webpack_require__) {
  35391. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35392. * Pusher JavaScript Library v5.0.3
  35393. * https://pusher.com/
  35394. *
  35395. * Copyright 2017, Pusher
  35396. * Released under the MIT licence.
  35397. */
  35398. (function webpackUniversalModuleDefinition(root, factory) {
  35399. if(true)
  35400. module.exports = factory();
  35401. else {}
  35402. })(window, function() {
  35403. return /******/ (function(modules) { // webpackBootstrap
  35404. /******/ // The module cache
  35405. /******/ var installedModules = {};
  35406. /******/
  35407. /******/ // The require function
  35408. /******/ function __webpack_require__(moduleId) {
  35409. /******/
  35410. /******/ // Check if module is in cache
  35411. /******/ if(installedModules[moduleId]) {
  35412. /******/ return installedModules[moduleId].exports;
  35413. /******/ }
  35414. /******/ // Create a new module (and put it into the cache)
  35415. /******/ var module = installedModules[moduleId] = {
  35416. /******/ i: moduleId,
  35417. /******/ l: false,
  35418. /******/ exports: {}
  35419. /******/ };
  35420. /******/
  35421. /******/ // Execute the module function
  35422. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35423. /******/
  35424. /******/ // Flag the module as loaded
  35425. /******/ module.l = true;
  35426. /******/
  35427. /******/ // Return the exports of the module
  35428. /******/ return module.exports;
  35429. /******/ }
  35430. /******/
  35431. /******/
  35432. /******/ // expose the modules object (__webpack_modules__)
  35433. /******/ __webpack_require__.m = modules;
  35434. /******/
  35435. /******/ // expose the module cache
  35436. /******/ __webpack_require__.c = installedModules;
  35437. /******/
  35438. /******/ // define getter function for harmony exports
  35439. /******/ __webpack_require__.d = function(exports, name, getter) {
  35440. /******/ if(!__webpack_require__.o(exports, name)) {
  35441. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35442. /******/ }
  35443. /******/ };
  35444. /******/
  35445. /******/ // define __esModule on exports
  35446. /******/ __webpack_require__.r = function(exports) {
  35447. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35448. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35449. /******/ }
  35450. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35451. /******/ };
  35452. /******/
  35453. /******/ // create a fake namespace object
  35454. /******/ // mode & 1: value is a module id, require it
  35455. /******/ // mode & 2: merge all properties of value into the ns
  35456. /******/ // mode & 4: return value when already ns object
  35457. /******/ // mode & 8|1: behave like require
  35458. /******/ __webpack_require__.t = function(value, mode) {
  35459. /******/ if(mode & 1) value = __webpack_require__(value);
  35460. /******/ if(mode & 8) return value;
  35461. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35462. /******/ var ns = Object.create(null);
  35463. /******/ __webpack_require__.r(ns);
  35464. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35465. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35466. /******/ return ns;
  35467. /******/ };
  35468. /******/
  35469. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35470. /******/ __webpack_require__.n = function(module) {
  35471. /******/ var getter = module && module.__esModule ?
  35472. /******/ function getDefault() { return module['default']; } :
  35473. /******/ function getModuleExports() { return module; };
  35474. /******/ __webpack_require__.d(getter, 'a', getter);
  35475. /******/ return getter;
  35476. /******/ };
  35477. /******/
  35478. /******/ // Object.prototype.hasOwnProperty.call
  35479. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35480. /******/
  35481. /******/ // __webpack_public_path__
  35482. /******/ __webpack_require__.p = "";
  35483. /******/
  35484. /******/
  35485. /******/ // Load entry module and return exports
  35486. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35487. /******/ })
  35488. /************************************************************************/
  35489. /******/ ([
  35490. /* 0 */
  35491. /***/ (function(module, exports, __webpack_require__) {
  35492. (function(nacl) {
  35493. 'use strict';
  35494. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35495. // Public domain.
  35496. //
  35497. // Implementation derived from TweetNaCl version 20140427.
  35498. // See for details: http://tweetnacl.cr.yp.to/
  35499. var gf = function(init) {
  35500. var i, r = new Float64Array(16);
  35501. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35502. return r;
  35503. };
  35504. // Pluggable, initialized in high-level API below.
  35505. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35506. var _0 = new Uint8Array(16);
  35507. var _9 = new Uint8Array(32); _9[0] = 9;
  35508. var gf0 = gf(),
  35509. gf1 = gf([1]),
  35510. _121665 = gf([0xdb41, 1]),
  35511. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35512. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35513. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35514. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35515. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35516. function ts64(x, i, h, l) {
  35517. x[i] = (h >> 24) & 0xff;
  35518. x[i+1] = (h >> 16) & 0xff;
  35519. x[i+2] = (h >> 8) & 0xff;
  35520. x[i+3] = h & 0xff;
  35521. x[i+4] = (l >> 24) & 0xff;
  35522. x[i+5] = (l >> 16) & 0xff;
  35523. x[i+6] = (l >> 8) & 0xff;
  35524. x[i+7] = l & 0xff;
  35525. }
  35526. function vn(x, xi, y, yi, n) {
  35527. var i,d = 0;
  35528. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35529. return (1 & ((d - 1) >>> 8)) - 1;
  35530. }
  35531. function crypto_verify_16(x, xi, y, yi) {
  35532. return vn(x,xi,y,yi,16);
  35533. }
  35534. function crypto_verify_32(x, xi, y, yi) {
  35535. return vn(x,xi,y,yi,32);
  35536. }
  35537. function core_salsa20(o, p, k, c) {
  35538. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35539. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35540. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35541. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35542. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35543. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35544. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35545. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35546. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35547. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35548. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35549. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35550. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35551. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35552. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35553. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35554. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35555. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35556. x15 = j15, u;
  35557. for (var i = 0; i < 20; i += 2) {
  35558. u = x0 + x12 | 0;
  35559. x4 ^= u<<7 | u>>>(32-7);
  35560. u = x4 + x0 | 0;
  35561. x8 ^= u<<9 | u>>>(32-9);
  35562. u = x8 + x4 | 0;
  35563. x12 ^= u<<13 | u>>>(32-13);
  35564. u = x12 + x8 | 0;
  35565. x0 ^= u<<18 | u>>>(32-18);
  35566. u = x5 + x1 | 0;
  35567. x9 ^= u<<7 | u>>>(32-7);
  35568. u = x9 + x5 | 0;
  35569. x13 ^= u<<9 | u>>>(32-9);
  35570. u = x13 + x9 | 0;
  35571. x1 ^= u<<13 | u>>>(32-13);
  35572. u = x1 + x13 | 0;
  35573. x5 ^= u<<18 | u>>>(32-18);
  35574. u = x10 + x6 | 0;
  35575. x14 ^= u<<7 | u>>>(32-7);
  35576. u = x14 + x10 | 0;
  35577. x2 ^= u<<9 | u>>>(32-9);
  35578. u = x2 + x14 | 0;
  35579. x6 ^= u<<13 | u>>>(32-13);
  35580. u = x6 + x2 | 0;
  35581. x10 ^= u<<18 | u>>>(32-18);
  35582. u = x15 + x11 | 0;
  35583. x3 ^= u<<7 | u>>>(32-7);
  35584. u = x3 + x15 | 0;
  35585. x7 ^= u<<9 | u>>>(32-9);
  35586. u = x7 + x3 | 0;
  35587. x11 ^= u<<13 | u>>>(32-13);
  35588. u = x11 + x7 | 0;
  35589. x15 ^= u<<18 | u>>>(32-18);
  35590. u = x0 + x3 | 0;
  35591. x1 ^= u<<7 | u>>>(32-7);
  35592. u = x1 + x0 | 0;
  35593. x2 ^= u<<9 | u>>>(32-9);
  35594. u = x2 + x1 | 0;
  35595. x3 ^= u<<13 | u>>>(32-13);
  35596. u = x3 + x2 | 0;
  35597. x0 ^= u<<18 | u>>>(32-18);
  35598. u = x5 + x4 | 0;
  35599. x6 ^= u<<7 | u>>>(32-7);
  35600. u = x6 + x5 | 0;
  35601. x7 ^= u<<9 | u>>>(32-9);
  35602. u = x7 + x6 | 0;
  35603. x4 ^= u<<13 | u>>>(32-13);
  35604. u = x4 + x7 | 0;
  35605. x5 ^= u<<18 | u>>>(32-18);
  35606. u = x10 + x9 | 0;
  35607. x11 ^= u<<7 | u>>>(32-7);
  35608. u = x11 + x10 | 0;
  35609. x8 ^= u<<9 | u>>>(32-9);
  35610. u = x8 + x11 | 0;
  35611. x9 ^= u<<13 | u>>>(32-13);
  35612. u = x9 + x8 | 0;
  35613. x10 ^= u<<18 | u>>>(32-18);
  35614. u = x15 + x14 | 0;
  35615. x12 ^= u<<7 | u>>>(32-7);
  35616. u = x12 + x15 | 0;
  35617. x13 ^= u<<9 | u>>>(32-9);
  35618. u = x13 + x12 | 0;
  35619. x14 ^= u<<13 | u>>>(32-13);
  35620. u = x14 + x13 | 0;
  35621. x15 ^= u<<18 | u>>>(32-18);
  35622. }
  35623. x0 = x0 + j0 | 0;
  35624. x1 = x1 + j1 | 0;
  35625. x2 = x2 + j2 | 0;
  35626. x3 = x3 + j3 | 0;
  35627. x4 = x4 + j4 | 0;
  35628. x5 = x5 + j5 | 0;
  35629. x6 = x6 + j6 | 0;
  35630. x7 = x7 + j7 | 0;
  35631. x8 = x8 + j8 | 0;
  35632. x9 = x9 + j9 | 0;
  35633. x10 = x10 + j10 | 0;
  35634. x11 = x11 + j11 | 0;
  35635. x12 = x12 + j12 | 0;
  35636. x13 = x13 + j13 | 0;
  35637. x14 = x14 + j14 | 0;
  35638. x15 = x15 + j15 | 0;
  35639. o[ 0] = x0 >>> 0 & 0xff;
  35640. o[ 1] = x0 >>> 8 & 0xff;
  35641. o[ 2] = x0 >>> 16 & 0xff;
  35642. o[ 3] = x0 >>> 24 & 0xff;
  35643. o[ 4] = x1 >>> 0 & 0xff;
  35644. o[ 5] = x1 >>> 8 & 0xff;
  35645. o[ 6] = x1 >>> 16 & 0xff;
  35646. o[ 7] = x1 >>> 24 & 0xff;
  35647. o[ 8] = x2 >>> 0 & 0xff;
  35648. o[ 9] = x2 >>> 8 & 0xff;
  35649. o[10] = x2 >>> 16 & 0xff;
  35650. o[11] = x2 >>> 24 & 0xff;
  35651. o[12] = x3 >>> 0 & 0xff;
  35652. o[13] = x3 >>> 8 & 0xff;
  35653. o[14] = x3 >>> 16 & 0xff;
  35654. o[15] = x3 >>> 24 & 0xff;
  35655. o[16] = x4 >>> 0 & 0xff;
  35656. o[17] = x4 >>> 8 & 0xff;
  35657. o[18] = x4 >>> 16 & 0xff;
  35658. o[19] = x4 >>> 24 & 0xff;
  35659. o[20] = x5 >>> 0 & 0xff;
  35660. o[21] = x5 >>> 8 & 0xff;
  35661. o[22] = x5 >>> 16 & 0xff;
  35662. o[23] = x5 >>> 24 & 0xff;
  35663. o[24] = x6 >>> 0 & 0xff;
  35664. o[25] = x6 >>> 8 & 0xff;
  35665. o[26] = x6 >>> 16 & 0xff;
  35666. o[27] = x6 >>> 24 & 0xff;
  35667. o[28] = x7 >>> 0 & 0xff;
  35668. o[29] = x7 >>> 8 & 0xff;
  35669. o[30] = x7 >>> 16 & 0xff;
  35670. o[31] = x7 >>> 24 & 0xff;
  35671. o[32] = x8 >>> 0 & 0xff;
  35672. o[33] = x8 >>> 8 & 0xff;
  35673. o[34] = x8 >>> 16 & 0xff;
  35674. o[35] = x8 >>> 24 & 0xff;
  35675. o[36] = x9 >>> 0 & 0xff;
  35676. o[37] = x9 >>> 8 & 0xff;
  35677. o[38] = x9 >>> 16 & 0xff;
  35678. o[39] = x9 >>> 24 & 0xff;
  35679. o[40] = x10 >>> 0 & 0xff;
  35680. o[41] = x10 >>> 8 & 0xff;
  35681. o[42] = x10 >>> 16 & 0xff;
  35682. o[43] = x10 >>> 24 & 0xff;
  35683. o[44] = x11 >>> 0 & 0xff;
  35684. o[45] = x11 >>> 8 & 0xff;
  35685. o[46] = x11 >>> 16 & 0xff;
  35686. o[47] = x11 >>> 24 & 0xff;
  35687. o[48] = x12 >>> 0 & 0xff;
  35688. o[49] = x12 >>> 8 & 0xff;
  35689. o[50] = x12 >>> 16 & 0xff;
  35690. o[51] = x12 >>> 24 & 0xff;
  35691. o[52] = x13 >>> 0 & 0xff;
  35692. o[53] = x13 >>> 8 & 0xff;
  35693. o[54] = x13 >>> 16 & 0xff;
  35694. o[55] = x13 >>> 24 & 0xff;
  35695. o[56] = x14 >>> 0 & 0xff;
  35696. o[57] = x14 >>> 8 & 0xff;
  35697. o[58] = x14 >>> 16 & 0xff;
  35698. o[59] = x14 >>> 24 & 0xff;
  35699. o[60] = x15 >>> 0 & 0xff;
  35700. o[61] = x15 >>> 8 & 0xff;
  35701. o[62] = x15 >>> 16 & 0xff;
  35702. o[63] = x15 >>> 24 & 0xff;
  35703. }
  35704. function core_hsalsa20(o,p,k,c) {
  35705. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35706. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35707. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35708. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35709. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35710. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35711. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35712. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35713. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35714. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35715. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35716. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35717. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35718. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35719. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35720. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35721. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35722. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35723. x15 = j15, u;
  35724. for (var i = 0; i < 20; i += 2) {
  35725. u = x0 + x12 | 0;
  35726. x4 ^= u<<7 | u>>>(32-7);
  35727. u = x4 + x0 | 0;
  35728. x8 ^= u<<9 | u>>>(32-9);
  35729. u = x8 + x4 | 0;
  35730. x12 ^= u<<13 | u>>>(32-13);
  35731. u = x12 + x8 | 0;
  35732. x0 ^= u<<18 | u>>>(32-18);
  35733. u = x5 + x1 | 0;
  35734. x9 ^= u<<7 | u>>>(32-7);
  35735. u = x9 + x5 | 0;
  35736. x13 ^= u<<9 | u>>>(32-9);
  35737. u = x13 + x9 | 0;
  35738. x1 ^= u<<13 | u>>>(32-13);
  35739. u = x1 + x13 | 0;
  35740. x5 ^= u<<18 | u>>>(32-18);
  35741. u = x10 + x6 | 0;
  35742. x14 ^= u<<7 | u>>>(32-7);
  35743. u = x14 + x10 | 0;
  35744. x2 ^= u<<9 | u>>>(32-9);
  35745. u = x2 + x14 | 0;
  35746. x6 ^= u<<13 | u>>>(32-13);
  35747. u = x6 + x2 | 0;
  35748. x10 ^= u<<18 | u>>>(32-18);
  35749. u = x15 + x11 | 0;
  35750. x3 ^= u<<7 | u>>>(32-7);
  35751. u = x3 + x15 | 0;
  35752. x7 ^= u<<9 | u>>>(32-9);
  35753. u = x7 + x3 | 0;
  35754. x11 ^= u<<13 | u>>>(32-13);
  35755. u = x11 + x7 | 0;
  35756. x15 ^= u<<18 | u>>>(32-18);
  35757. u = x0 + x3 | 0;
  35758. x1 ^= u<<7 | u>>>(32-7);
  35759. u = x1 + x0 | 0;
  35760. x2 ^= u<<9 | u>>>(32-9);
  35761. u = x2 + x1 | 0;
  35762. x3 ^= u<<13 | u>>>(32-13);
  35763. u = x3 + x2 | 0;
  35764. x0 ^= u<<18 | u>>>(32-18);
  35765. u = x5 + x4 | 0;
  35766. x6 ^= u<<7 | u>>>(32-7);
  35767. u = x6 + x5 | 0;
  35768. x7 ^= u<<9 | u>>>(32-9);
  35769. u = x7 + x6 | 0;
  35770. x4 ^= u<<13 | u>>>(32-13);
  35771. u = x4 + x7 | 0;
  35772. x5 ^= u<<18 | u>>>(32-18);
  35773. u = x10 + x9 | 0;
  35774. x11 ^= u<<7 | u>>>(32-7);
  35775. u = x11 + x10 | 0;
  35776. x8 ^= u<<9 | u>>>(32-9);
  35777. u = x8 + x11 | 0;
  35778. x9 ^= u<<13 | u>>>(32-13);
  35779. u = x9 + x8 | 0;
  35780. x10 ^= u<<18 | u>>>(32-18);
  35781. u = x15 + x14 | 0;
  35782. x12 ^= u<<7 | u>>>(32-7);
  35783. u = x12 + x15 | 0;
  35784. x13 ^= u<<9 | u>>>(32-9);
  35785. u = x13 + x12 | 0;
  35786. x14 ^= u<<13 | u>>>(32-13);
  35787. u = x14 + x13 | 0;
  35788. x15 ^= u<<18 | u>>>(32-18);
  35789. }
  35790. o[ 0] = x0 >>> 0 & 0xff;
  35791. o[ 1] = x0 >>> 8 & 0xff;
  35792. o[ 2] = x0 >>> 16 & 0xff;
  35793. o[ 3] = x0 >>> 24 & 0xff;
  35794. o[ 4] = x5 >>> 0 & 0xff;
  35795. o[ 5] = x5 >>> 8 & 0xff;
  35796. o[ 6] = x5 >>> 16 & 0xff;
  35797. o[ 7] = x5 >>> 24 & 0xff;
  35798. o[ 8] = x10 >>> 0 & 0xff;
  35799. o[ 9] = x10 >>> 8 & 0xff;
  35800. o[10] = x10 >>> 16 & 0xff;
  35801. o[11] = x10 >>> 24 & 0xff;
  35802. o[12] = x15 >>> 0 & 0xff;
  35803. o[13] = x15 >>> 8 & 0xff;
  35804. o[14] = x15 >>> 16 & 0xff;
  35805. o[15] = x15 >>> 24 & 0xff;
  35806. o[16] = x6 >>> 0 & 0xff;
  35807. o[17] = x6 >>> 8 & 0xff;
  35808. o[18] = x6 >>> 16 & 0xff;
  35809. o[19] = x6 >>> 24 & 0xff;
  35810. o[20] = x7 >>> 0 & 0xff;
  35811. o[21] = x7 >>> 8 & 0xff;
  35812. o[22] = x7 >>> 16 & 0xff;
  35813. o[23] = x7 >>> 24 & 0xff;
  35814. o[24] = x8 >>> 0 & 0xff;
  35815. o[25] = x8 >>> 8 & 0xff;
  35816. o[26] = x8 >>> 16 & 0xff;
  35817. o[27] = x8 >>> 24 & 0xff;
  35818. o[28] = x9 >>> 0 & 0xff;
  35819. o[29] = x9 >>> 8 & 0xff;
  35820. o[30] = x9 >>> 16 & 0xff;
  35821. o[31] = x9 >>> 24 & 0xff;
  35822. }
  35823. function crypto_core_salsa20(out,inp,k,c) {
  35824. core_salsa20(out,inp,k,c);
  35825. }
  35826. function crypto_core_hsalsa20(out,inp,k,c) {
  35827. core_hsalsa20(out,inp,k,c);
  35828. }
  35829. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35830. // "expand 32-byte k"
  35831. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35832. var z = new Uint8Array(16), x = new Uint8Array(64);
  35833. var u, i;
  35834. for (i = 0; i < 16; i++) z[i] = 0;
  35835. for (i = 0; i < 8; i++) z[i] = n[i];
  35836. while (b >= 64) {
  35837. crypto_core_salsa20(x,z,k,sigma);
  35838. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35839. u = 1;
  35840. for (i = 8; i < 16; i++) {
  35841. u = u + (z[i] & 0xff) | 0;
  35842. z[i] = u & 0xff;
  35843. u >>>= 8;
  35844. }
  35845. b -= 64;
  35846. cpos += 64;
  35847. mpos += 64;
  35848. }
  35849. if (b > 0) {
  35850. crypto_core_salsa20(x,z,k,sigma);
  35851. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35852. }
  35853. return 0;
  35854. }
  35855. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35856. var z = new Uint8Array(16), x = new Uint8Array(64);
  35857. var u, i;
  35858. for (i = 0; i < 16; i++) z[i] = 0;
  35859. for (i = 0; i < 8; i++) z[i] = n[i];
  35860. while (b >= 64) {
  35861. crypto_core_salsa20(x,z,k,sigma);
  35862. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35863. u = 1;
  35864. for (i = 8; i < 16; i++) {
  35865. u = u + (z[i] & 0xff) | 0;
  35866. z[i] = u & 0xff;
  35867. u >>>= 8;
  35868. }
  35869. b -= 64;
  35870. cpos += 64;
  35871. }
  35872. if (b > 0) {
  35873. crypto_core_salsa20(x,z,k,sigma);
  35874. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35875. }
  35876. return 0;
  35877. }
  35878. function crypto_stream(c,cpos,d,n,k) {
  35879. var s = new Uint8Array(32);
  35880. crypto_core_hsalsa20(s,n,k,sigma);
  35881. var sn = new Uint8Array(8);
  35882. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35883. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35884. }
  35885. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35886. var s = new Uint8Array(32);
  35887. crypto_core_hsalsa20(s,n,k,sigma);
  35888. var sn = new Uint8Array(8);
  35889. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35890. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35891. }
  35892. /*
  35893. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35894. * https://github.com/floodyberry/poly1305-donna
  35895. */
  35896. var poly1305 = function(key) {
  35897. this.buffer = new Uint8Array(16);
  35898. this.r = new Uint16Array(10);
  35899. this.h = new Uint16Array(10);
  35900. this.pad = new Uint16Array(8);
  35901. this.leftover = 0;
  35902. this.fin = 0;
  35903. var t0, t1, t2, t3, t4, t5, t6, t7;
  35904. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35905. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35906. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35907. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35908. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35909. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35910. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35911. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35912. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35913. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35914. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35915. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35916. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35917. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35918. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35919. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35920. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35921. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35922. };
  35923. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35924. var hibit = this.fin ? 0 : (1 << 11);
  35925. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35926. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35927. var h0 = this.h[0],
  35928. h1 = this.h[1],
  35929. h2 = this.h[2],
  35930. h3 = this.h[3],
  35931. h4 = this.h[4],
  35932. h5 = this.h[5],
  35933. h6 = this.h[6],
  35934. h7 = this.h[7],
  35935. h8 = this.h[8],
  35936. h9 = this.h[9];
  35937. var r0 = this.r[0],
  35938. r1 = this.r[1],
  35939. r2 = this.r[2],
  35940. r3 = this.r[3],
  35941. r4 = this.r[4],
  35942. r5 = this.r[5],
  35943. r6 = this.r[6],
  35944. r7 = this.r[7],
  35945. r8 = this.r[8],
  35946. r9 = this.r[9];
  35947. while (bytes >= 16) {
  35948. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35949. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35950. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35951. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35952. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35953. h5 += ((t4 >>> 1)) & 0x1fff;
  35954. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35955. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35956. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35957. h9 += ((t7 >>> 5)) | hibit;
  35958. c = 0;
  35959. d0 = c;
  35960. d0 += h0 * r0;
  35961. d0 += h1 * (5 * r9);
  35962. d0 += h2 * (5 * r8);
  35963. d0 += h3 * (5 * r7);
  35964. d0 += h4 * (5 * r6);
  35965. c = (d0 >>> 13); d0 &= 0x1fff;
  35966. d0 += h5 * (5 * r5);
  35967. d0 += h6 * (5 * r4);
  35968. d0 += h7 * (5 * r3);
  35969. d0 += h8 * (5 * r2);
  35970. d0 += h9 * (5 * r1);
  35971. c += (d0 >>> 13); d0 &= 0x1fff;
  35972. d1 = c;
  35973. d1 += h0 * r1;
  35974. d1 += h1 * r0;
  35975. d1 += h2 * (5 * r9);
  35976. d1 += h3 * (5 * r8);
  35977. d1 += h4 * (5 * r7);
  35978. c = (d1 >>> 13); d1 &= 0x1fff;
  35979. d1 += h5 * (5 * r6);
  35980. d1 += h6 * (5 * r5);
  35981. d1 += h7 * (5 * r4);
  35982. d1 += h8 * (5 * r3);
  35983. d1 += h9 * (5 * r2);
  35984. c += (d1 >>> 13); d1 &= 0x1fff;
  35985. d2 = c;
  35986. d2 += h0 * r2;
  35987. d2 += h1 * r1;
  35988. d2 += h2 * r0;
  35989. d2 += h3 * (5 * r9);
  35990. d2 += h4 * (5 * r8);
  35991. c = (d2 >>> 13); d2 &= 0x1fff;
  35992. d2 += h5 * (5 * r7);
  35993. d2 += h6 * (5 * r6);
  35994. d2 += h7 * (5 * r5);
  35995. d2 += h8 * (5 * r4);
  35996. d2 += h9 * (5 * r3);
  35997. c += (d2 >>> 13); d2 &= 0x1fff;
  35998. d3 = c;
  35999. d3 += h0 * r3;
  36000. d3 += h1 * r2;
  36001. d3 += h2 * r1;
  36002. d3 += h3 * r0;
  36003. d3 += h4 * (5 * r9);
  36004. c = (d3 >>> 13); d3 &= 0x1fff;
  36005. d3 += h5 * (5 * r8);
  36006. d3 += h6 * (5 * r7);
  36007. d3 += h7 * (5 * r6);
  36008. d3 += h8 * (5 * r5);
  36009. d3 += h9 * (5 * r4);
  36010. c += (d3 >>> 13); d3 &= 0x1fff;
  36011. d4 = c;
  36012. d4 += h0 * r4;
  36013. d4 += h1 * r3;
  36014. d4 += h2 * r2;
  36015. d4 += h3 * r1;
  36016. d4 += h4 * r0;
  36017. c = (d4 >>> 13); d4 &= 0x1fff;
  36018. d4 += h5 * (5 * r9);
  36019. d4 += h6 * (5 * r8);
  36020. d4 += h7 * (5 * r7);
  36021. d4 += h8 * (5 * r6);
  36022. d4 += h9 * (5 * r5);
  36023. c += (d4 >>> 13); d4 &= 0x1fff;
  36024. d5 = c;
  36025. d5 += h0 * r5;
  36026. d5 += h1 * r4;
  36027. d5 += h2 * r3;
  36028. d5 += h3 * r2;
  36029. d5 += h4 * r1;
  36030. c = (d5 >>> 13); d5 &= 0x1fff;
  36031. d5 += h5 * r0;
  36032. d5 += h6 * (5 * r9);
  36033. d5 += h7 * (5 * r8);
  36034. d5 += h8 * (5 * r7);
  36035. d5 += h9 * (5 * r6);
  36036. c += (d5 >>> 13); d5 &= 0x1fff;
  36037. d6 = c;
  36038. d6 += h0 * r6;
  36039. d6 += h1 * r5;
  36040. d6 += h2 * r4;
  36041. d6 += h3 * r3;
  36042. d6 += h4 * r2;
  36043. c = (d6 >>> 13); d6 &= 0x1fff;
  36044. d6 += h5 * r1;
  36045. d6 += h6 * r0;
  36046. d6 += h7 * (5 * r9);
  36047. d6 += h8 * (5 * r8);
  36048. d6 += h9 * (5 * r7);
  36049. c += (d6 >>> 13); d6 &= 0x1fff;
  36050. d7 = c;
  36051. d7 += h0 * r7;
  36052. d7 += h1 * r6;
  36053. d7 += h2 * r5;
  36054. d7 += h3 * r4;
  36055. d7 += h4 * r3;
  36056. c = (d7 >>> 13); d7 &= 0x1fff;
  36057. d7 += h5 * r2;
  36058. d7 += h6 * r1;
  36059. d7 += h7 * r0;
  36060. d7 += h8 * (5 * r9);
  36061. d7 += h9 * (5 * r8);
  36062. c += (d7 >>> 13); d7 &= 0x1fff;
  36063. d8 = c;
  36064. d8 += h0 * r8;
  36065. d8 += h1 * r7;
  36066. d8 += h2 * r6;
  36067. d8 += h3 * r5;
  36068. d8 += h4 * r4;
  36069. c = (d8 >>> 13); d8 &= 0x1fff;
  36070. d8 += h5 * r3;
  36071. d8 += h6 * r2;
  36072. d8 += h7 * r1;
  36073. d8 += h8 * r0;
  36074. d8 += h9 * (5 * r9);
  36075. c += (d8 >>> 13); d8 &= 0x1fff;
  36076. d9 = c;
  36077. d9 += h0 * r9;
  36078. d9 += h1 * r8;
  36079. d9 += h2 * r7;
  36080. d9 += h3 * r6;
  36081. d9 += h4 * r5;
  36082. c = (d9 >>> 13); d9 &= 0x1fff;
  36083. d9 += h5 * r4;
  36084. d9 += h6 * r3;
  36085. d9 += h7 * r2;
  36086. d9 += h8 * r1;
  36087. d9 += h9 * r0;
  36088. c += (d9 >>> 13); d9 &= 0x1fff;
  36089. c = (((c << 2) + c)) | 0;
  36090. c = (c + d0) | 0;
  36091. d0 = c & 0x1fff;
  36092. c = (c >>> 13);
  36093. d1 += c;
  36094. h0 = d0;
  36095. h1 = d1;
  36096. h2 = d2;
  36097. h3 = d3;
  36098. h4 = d4;
  36099. h5 = d5;
  36100. h6 = d6;
  36101. h7 = d7;
  36102. h8 = d8;
  36103. h9 = d9;
  36104. mpos += 16;
  36105. bytes -= 16;
  36106. }
  36107. this.h[0] = h0;
  36108. this.h[1] = h1;
  36109. this.h[2] = h2;
  36110. this.h[3] = h3;
  36111. this.h[4] = h4;
  36112. this.h[5] = h5;
  36113. this.h[6] = h6;
  36114. this.h[7] = h7;
  36115. this.h[8] = h8;
  36116. this.h[9] = h9;
  36117. };
  36118. poly1305.prototype.finish = function(mac, macpos) {
  36119. var g = new Uint16Array(10);
  36120. var c, mask, f, i;
  36121. if (this.leftover) {
  36122. i = this.leftover;
  36123. this.buffer[i++] = 1;
  36124. for (; i < 16; i++) this.buffer[i] = 0;
  36125. this.fin = 1;
  36126. this.blocks(this.buffer, 0, 16);
  36127. }
  36128. c = this.h[1] >>> 13;
  36129. this.h[1] &= 0x1fff;
  36130. for (i = 2; i < 10; i++) {
  36131. this.h[i] += c;
  36132. c = this.h[i] >>> 13;
  36133. this.h[i] &= 0x1fff;
  36134. }
  36135. this.h[0] += (c * 5);
  36136. c = this.h[0] >>> 13;
  36137. this.h[0] &= 0x1fff;
  36138. this.h[1] += c;
  36139. c = this.h[1] >>> 13;
  36140. this.h[1] &= 0x1fff;
  36141. this.h[2] += c;
  36142. g[0] = this.h[0] + 5;
  36143. c = g[0] >>> 13;
  36144. g[0] &= 0x1fff;
  36145. for (i = 1; i < 10; i++) {
  36146. g[i] = this.h[i] + c;
  36147. c = g[i] >>> 13;
  36148. g[i] &= 0x1fff;
  36149. }
  36150. g[9] -= (1 << 13);
  36151. mask = (c ^ 1) - 1;
  36152. for (i = 0; i < 10; i++) g[i] &= mask;
  36153. mask = ~mask;
  36154. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36155. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36156. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36157. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36158. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36159. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36160. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36161. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36162. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36163. f = this.h[0] + this.pad[0];
  36164. this.h[0] = f & 0xffff;
  36165. for (i = 1; i < 8; i++) {
  36166. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36167. this.h[i] = f & 0xffff;
  36168. }
  36169. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36170. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36171. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36172. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36173. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36174. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36175. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36176. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36177. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36178. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36179. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36180. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36181. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36182. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36183. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36184. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36185. };
  36186. poly1305.prototype.update = function(m, mpos, bytes) {
  36187. var i, want;
  36188. if (this.leftover) {
  36189. want = (16 - this.leftover);
  36190. if (want > bytes)
  36191. want = bytes;
  36192. for (i = 0; i < want; i++)
  36193. this.buffer[this.leftover + i] = m[mpos+i];
  36194. bytes -= want;
  36195. mpos += want;
  36196. this.leftover += want;
  36197. if (this.leftover < 16)
  36198. return;
  36199. this.blocks(this.buffer, 0, 16);
  36200. this.leftover = 0;
  36201. }
  36202. if (bytes >= 16) {
  36203. want = bytes - (bytes % 16);
  36204. this.blocks(m, mpos, want);
  36205. mpos += want;
  36206. bytes -= want;
  36207. }
  36208. if (bytes) {
  36209. for (i = 0; i < bytes; i++)
  36210. this.buffer[this.leftover + i] = m[mpos+i];
  36211. this.leftover += bytes;
  36212. }
  36213. };
  36214. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36215. var s = new poly1305(k);
  36216. s.update(m, mpos, n);
  36217. s.finish(out, outpos);
  36218. return 0;
  36219. }
  36220. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36221. var x = new Uint8Array(16);
  36222. crypto_onetimeauth(x,0,m,mpos,n,k);
  36223. return crypto_verify_16(h,hpos,x,0);
  36224. }
  36225. function crypto_secretbox(c,m,d,n,k) {
  36226. var i;
  36227. if (d < 32) return -1;
  36228. crypto_stream_xor(c,0,m,0,d,n,k);
  36229. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36230. for (i = 0; i < 16; i++) c[i] = 0;
  36231. return 0;
  36232. }
  36233. function crypto_secretbox_open(m,c,d,n,k) {
  36234. var i;
  36235. var x = new Uint8Array(32);
  36236. if (d < 32) return -1;
  36237. crypto_stream(x,0,32,n,k);
  36238. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36239. crypto_stream_xor(m,0,c,0,d,n,k);
  36240. for (i = 0; i < 32; i++) m[i] = 0;
  36241. return 0;
  36242. }
  36243. function set25519(r, a) {
  36244. var i;
  36245. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36246. }
  36247. function car25519(o) {
  36248. var i, v, c = 1;
  36249. for (i = 0; i < 16; i++) {
  36250. v = o[i] + c + 65535;
  36251. c = Math.floor(v / 65536);
  36252. o[i] = v - c * 65536;
  36253. }
  36254. o[0] += c-1 + 37 * (c-1);
  36255. }
  36256. function sel25519(p, q, b) {
  36257. var t, c = ~(b-1);
  36258. for (var i = 0; i < 16; i++) {
  36259. t = c & (p[i] ^ q[i]);
  36260. p[i] ^= t;
  36261. q[i] ^= t;
  36262. }
  36263. }
  36264. function pack25519(o, n) {
  36265. var i, j, b;
  36266. var m = gf(), t = gf();
  36267. for (i = 0; i < 16; i++) t[i] = n[i];
  36268. car25519(t);
  36269. car25519(t);
  36270. car25519(t);
  36271. for (j = 0; j < 2; j++) {
  36272. m[0] = t[0] - 0xffed;
  36273. for (i = 1; i < 15; i++) {
  36274. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36275. m[i-1] &= 0xffff;
  36276. }
  36277. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36278. b = (m[15]>>16) & 1;
  36279. m[14] &= 0xffff;
  36280. sel25519(t, m, 1-b);
  36281. }
  36282. for (i = 0; i < 16; i++) {
  36283. o[2*i] = t[i] & 0xff;
  36284. o[2*i+1] = t[i]>>8;
  36285. }
  36286. }
  36287. function neq25519(a, b) {
  36288. var c = new Uint8Array(32), d = new Uint8Array(32);
  36289. pack25519(c, a);
  36290. pack25519(d, b);
  36291. return crypto_verify_32(c, 0, d, 0);
  36292. }
  36293. function par25519(a) {
  36294. var d = new Uint8Array(32);
  36295. pack25519(d, a);
  36296. return d[0] & 1;
  36297. }
  36298. function unpack25519(o, n) {
  36299. var i;
  36300. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36301. o[15] &= 0x7fff;
  36302. }
  36303. function A(o, a, b) {
  36304. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36305. }
  36306. function Z(o, a, b) {
  36307. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36308. }
  36309. function M(o, a, b) {
  36310. var v, c,
  36311. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36312. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36313. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36314. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36315. b0 = b[0],
  36316. b1 = b[1],
  36317. b2 = b[2],
  36318. b3 = b[3],
  36319. b4 = b[4],
  36320. b5 = b[5],
  36321. b6 = b[6],
  36322. b7 = b[7],
  36323. b8 = b[8],
  36324. b9 = b[9],
  36325. b10 = b[10],
  36326. b11 = b[11],
  36327. b12 = b[12],
  36328. b13 = b[13],
  36329. b14 = b[14],
  36330. b15 = b[15];
  36331. v = a[0];
  36332. t0 += v * b0;
  36333. t1 += v * b1;
  36334. t2 += v * b2;
  36335. t3 += v * b3;
  36336. t4 += v * b4;
  36337. t5 += v * b5;
  36338. t6 += v * b6;
  36339. t7 += v * b7;
  36340. t8 += v * b8;
  36341. t9 += v * b9;
  36342. t10 += v * b10;
  36343. t11 += v * b11;
  36344. t12 += v * b12;
  36345. t13 += v * b13;
  36346. t14 += v * b14;
  36347. t15 += v * b15;
  36348. v = a[1];
  36349. t1 += v * b0;
  36350. t2 += v * b1;
  36351. t3 += v * b2;
  36352. t4 += v * b3;
  36353. t5 += v * b4;
  36354. t6 += v * b5;
  36355. t7 += v * b6;
  36356. t8 += v * b7;
  36357. t9 += v * b8;
  36358. t10 += v * b9;
  36359. t11 += v * b10;
  36360. t12 += v * b11;
  36361. t13 += v * b12;
  36362. t14 += v * b13;
  36363. t15 += v * b14;
  36364. t16 += v * b15;
  36365. v = a[2];
  36366. t2 += v * b0;
  36367. t3 += v * b1;
  36368. t4 += v * b2;
  36369. t5 += v * b3;
  36370. t6 += v * b4;
  36371. t7 += v * b5;
  36372. t8 += v * b6;
  36373. t9 += v * b7;
  36374. t10 += v * b8;
  36375. t11 += v * b9;
  36376. t12 += v * b10;
  36377. t13 += v * b11;
  36378. t14 += v * b12;
  36379. t15 += v * b13;
  36380. t16 += v * b14;
  36381. t17 += v * b15;
  36382. v = a[3];
  36383. t3 += v * b0;
  36384. t4 += v * b1;
  36385. t5 += v * b2;
  36386. t6 += v * b3;
  36387. t7 += v * b4;
  36388. t8 += v * b5;
  36389. t9 += v * b6;
  36390. t10 += v * b7;
  36391. t11 += v * b8;
  36392. t12 += v * b9;
  36393. t13 += v * b10;
  36394. t14 += v * b11;
  36395. t15 += v * b12;
  36396. t16 += v * b13;
  36397. t17 += v * b14;
  36398. t18 += v * b15;
  36399. v = a[4];
  36400. t4 += v * b0;
  36401. t5 += v * b1;
  36402. t6 += v * b2;
  36403. t7 += v * b3;
  36404. t8 += v * b4;
  36405. t9 += v * b5;
  36406. t10 += v * b6;
  36407. t11 += v * b7;
  36408. t12 += v * b8;
  36409. t13 += v * b9;
  36410. t14 += v * b10;
  36411. t15 += v * b11;
  36412. t16 += v * b12;
  36413. t17 += v * b13;
  36414. t18 += v * b14;
  36415. t19 += v * b15;
  36416. v = a[5];
  36417. t5 += v * b0;
  36418. t6 += v * b1;
  36419. t7 += v * b2;
  36420. t8 += v * b3;
  36421. t9 += v * b4;
  36422. t10 += v * b5;
  36423. t11 += v * b6;
  36424. t12 += v * b7;
  36425. t13 += v * b8;
  36426. t14 += v * b9;
  36427. t15 += v * b10;
  36428. t16 += v * b11;
  36429. t17 += v * b12;
  36430. t18 += v * b13;
  36431. t19 += v * b14;
  36432. t20 += v * b15;
  36433. v = a[6];
  36434. t6 += v * b0;
  36435. t7 += v * b1;
  36436. t8 += v * b2;
  36437. t9 += v * b3;
  36438. t10 += v * b4;
  36439. t11 += v * b5;
  36440. t12 += v * b6;
  36441. t13 += v * b7;
  36442. t14 += v * b8;
  36443. t15 += v * b9;
  36444. t16 += v * b10;
  36445. t17 += v * b11;
  36446. t18 += v * b12;
  36447. t19 += v * b13;
  36448. t20 += v * b14;
  36449. t21 += v * b15;
  36450. v = a[7];
  36451. t7 += v * b0;
  36452. t8 += v * b1;
  36453. t9 += v * b2;
  36454. t10 += v * b3;
  36455. t11 += v * b4;
  36456. t12 += v * b5;
  36457. t13 += v * b6;
  36458. t14 += v * b7;
  36459. t15 += v * b8;
  36460. t16 += v * b9;
  36461. t17 += v * b10;
  36462. t18 += v * b11;
  36463. t19 += v * b12;
  36464. t20 += v * b13;
  36465. t21 += v * b14;
  36466. t22 += v * b15;
  36467. v = a[8];
  36468. t8 += v * b0;
  36469. t9 += v * b1;
  36470. t10 += v * b2;
  36471. t11 += v * b3;
  36472. t12 += v * b4;
  36473. t13 += v * b5;
  36474. t14 += v * b6;
  36475. t15 += v * b7;
  36476. t16 += v * b8;
  36477. t17 += v * b9;
  36478. t18 += v * b10;
  36479. t19 += v * b11;
  36480. t20 += v * b12;
  36481. t21 += v * b13;
  36482. t22 += v * b14;
  36483. t23 += v * b15;
  36484. v = a[9];
  36485. t9 += v * b0;
  36486. t10 += v * b1;
  36487. t11 += v * b2;
  36488. t12 += v * b3;
  36489. t13 += v * b4;
  36490. t14 += v * b5;
  36491. t15 += v * b6;
  36492. t16 += v * b7;
  36493. t17 += v * b8;
  36494. t18 += v * b9;
  36495. t19 += v * b10;
  36496. t20 += v * b11;
  36497. t21 += v * b12;
  36498. t22 += v * b13;
  36499. t23 += v * b14;
  36500. t24 += v * b15;
  36501. v = a[10];
  36502. t10 += v * b0;
  36503. t11 += v * b1;
  36504. t12 += v * b2;
  36505. t13 += v * b3;
  36506. t14 += v * b4;
  36507. t15 += v * b5;
  36508. t16 += v * b6;
  36509. t17 += v * b7;
  36510. t18 += v * b8;
  36511. t19 += v * b9;
  36512. t20 += v * b10;
  36513. t21 += v * b11;
  36514. t22 += v * b12;
  36515. t23 += v * b13;
  36516. t24 += v * b14;
  36517. t25 += v * b15;
  36518. v = a[11];
  36519. t11 += v * b0;
  36520. t12 += v * b1;
  36521. t13 += v * b2;
  36522. t14 += v * b3;
  36523. t15 += v * b4;
  36524. t16 += v * b5;
  36525. t17 += v * b6;
  36526. t18 += v * b7;
  36527. t19 += v * b8;
  36528. t20 += v * b9;
  36529. t21 += v * b10;
  36530. t22 += v * b11;
  36531. t23 += v * b12;
  36532. t24 += v * b13;
  36533. t25 += v * b14;
  36534. t26 += v * b15;
  36535. v = a[12];
  36536. t12 += v * b0;
  36537. t13 += v * b1;
  36538. t14 += v * b2;
  36539. t15 += v * b3;
  36540. t16 += v * b4;
  36541. t17 += v * b5;
  36542. t18 += v * b6;
  36543. t19 += v * b7;
  36544. t20 += v * b8;
  36545. t21 += v * b9;
  36546. t22 += v * b10;
  36547. t23 += v * b11;
  36548. t24 += v * b12;
  36549. t25 += v * b13;
  36550. t26 += v * b14;
  36551. t27 += v * b15;
  36552. v = a[13];
  36553. t13 += v * b0;
  36554. t14 += v * b1;
  36555. t15 += v * b2;
  36556. t16 += v * b3;
  36557. t17 += v * b4;
  36558. t18 += v * b5;
  36559. t19 += v * b6;
  36560. t20 += v * b7;
  36561. t21 += v * b8;
  36562. t22 += v * b9;
  36563. t23 += v * b10;
  36564. t24 += v * b11;
  36565. t25 += v * b12;
  36566. t26 += v * b13;
  36567. t27 += v * b14;
  36568. t28 += v * b15;
  36569. v = a[14];
  36570. t14 += v * b0;
  36571. t15 += v * b1;
  36572. t16 += v * b2;
  36573. t17 += v * b3;
  36574. t18 += v * b4;
  36575. t19 += v * b5;
  36576. t20 += v * b6;
  36577. t21 += v * b7;
  36578. t22 += v * b8;
  36579. t23 += v * b9;
  36580. t24 += v * b10;
  36581. t25 += v * b11;
  36582. t26 += v * b12;
  36583. t27 += v * b13;
  36584. t28 += v * b14;
  36585. t29 += v * b15;
  36586. v = a[15];
  36587. t15 += v * b0;
  36588. t16 += v * b1;
  36589. t17 += v * b2;
  36590. t18 += v * b3;
  36591. t19 += v * b4;
  36592. t20 += v * b5;
  36593. t21 += v * b6;
  36594. t22 += v * b7;
  36595. t23 += v * b8;
  36596. t24 += v * b9;
  36597. t25 += v * b10;
  36598. t26 += v * b11;
  36599. t27 += v * b12;
  36600. t28 += v * b13;
  36601. t29 += v * b14;
  36602. t30 += v * b15;
  36603. t0 += 38 * t16;
  36604. t1 += 38 * t17;
  36605. t2 += 38 * t18;
  36606. t3 += 38 * t19;
  36607. t4 += 38 * t20;
  36608. t5 += 38 * t21;
  36609. t6 += 38 * t22;
  36610. t7 += 38 * t23;
  36611. t8 += 38 * t24;
  36612. t9 += 38 * t25;
  36613. t10 += 38 * t26;
  36614. t11 += 38 * t27;
  36615. t12 += 38 * t28;
  36616. t13 += 38 * t29;
  36617. t14 += 38 * t30;
  36618. // t15 left as is
  36619. // first car
  36620. c = 1;
  36621. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36622. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36623. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36624. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36625. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36626. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36627. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36628. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36629. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36630. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36631. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36632. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36633. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36634. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36635. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36636. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36637. t0 += c-1 + 37 * (c-1);
  36638. // second car
  36639. c = 1;
  36640. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36641. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36642. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36643. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36644. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36645. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36646. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36647. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36648. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36649. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36650. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36651. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36652. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36653. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36654. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36655. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36656. t0 += c-1 + 37 * (c-1);
  36657. o[ 0] = t0;
  36658. o[ 1] = t1;
  36659. o[ 2] = t2;
  36660. o[ 3] = t3;
  36661. o[ 4] = t4;
  36662. o[ 5] = t5;
  36663. o[ 6] = t6;
  36664. o[ 7] = t7;
  36665. o[ 8] = t8;
  36666. o[ 9] = t9;
  36667. o[10] = t10;
  36668. o[11] = t11;
  36669. o[12] = t12;
  36670. o[13] = t13;
  36671. o[14] = t14;
  36672. o[15] = t15;
  36673. }
  36674. function S(o, a) {
  36675. M(o, a, a);
  36676. }
  36677. function inv25519(o, i) {
  36678. var c = gf();
  36679. var a;
  36680. for (a = 0; a < 16; a++) c[a] = i[a];
  36681. for (a = 253; a >= 0; a--) {
  36682. S(c, c);
  36683. if(a !== 2 && a !== 4) M(c, c, i);
  36684. }
  36685. for (a = 0; a < 16; a++) o[a] = c[a];
  36686. }
  36687. function pow2523(o, i) {
  36688. var c = gf();
  36689. var a;
  36690. for (a = 0; a < 16; a++) c[a] = i[a];
  36691. for (a = 250; a >= 0; a--) {
  36692. S(c, c);
  36693. if(a !== 1) M(c, c, i);
  36694. }
  36695. for (a = 0; a < 16; a++) o[a] = c[a];
  36696. }
  36697. function crypto_scalarmult(q, n, p) {
  36698. var z = new Uint8Array(32);
  36699. var x = new Float64Array(80), r, i;
  36700. var a = gf(), b = gf(), c = gf(),
  36701. d = gf(), e = gf(), f = gf();
  36702. for (i = 0; i < 31; i++) z[i] = n[i];
  36703. z[31]=(n[31]&127)|64;
  36704. z[0]&=248;
  36705. unpack25519(x,p);
  36706. for (i = 0; i < 16; i++) {
  36707. b[i]=x[i];
  36708. d[i]=a[i]=c[i]=0;
  36709. }
  36710. a[0]=d[0]=1;
  36711. for (i=254; i>=0; --i) {
  36712. r=(z[i>>>3]>>>(i&7))&1;
  36713. sel25519(a,b,r);
  36714. sel25519(c,d,r);
  36715. A(e,a,c);
  36716. Z(a,a,c);
  36717. A(c,b,d);
  36718. Z(b,b,d);
  36719. S(d,e);
  36720. S(f,a);
  36721. M(a,c,a);
  36722. M(c,b,e);
  36723. A(e,a,c);
  36724. Z(a,a,c);
  36725. S(b,a);
  36726. Z(c,d,f);
  36727. M(a,c,_121665);
  36728. A(a,a,d);
  36729. M(c,c,a);
  36730. M(a,d,f);
  36731. M(d,b,x);
  36732. S(b,e);
  36733. sel25519(a,b,r);
  36734. sel25519(c,d,r);
  36735. }
  36736. for (i = 0; i < 16; i++) {
  36737. x[i+16]=a[i];
  36738. x[i+32]=c[i];
  36739. x[i+48]=b[i];
  36740. x[i+64]=d[i];
  36741. }
  36742. var x32 = x.subarray(32);
  36743. var x16 = x.subarray(16);
  36744. inv25519(x32,x32);
  36745. M(x16,x16,x32);
  36746. pack25519(q,x16);
  36747. return 0;
  36748. }
  36749. function crypto_scalarmult_base(q, n) {
  36750. return crypto_scalarmult(q, n, _9);
  36751. }
  36752. function crypto_box_keypair(y, x) {
  36753. randombytes(x, 32);
  36754. return crypto_scalarmult_base(y, x);
  36755. }
  36756. function crypto_box_beforenm(k, y, x) {
  36757. var s = new Uint8Array(32);
  36758. crypto_scalarmult(s, x, y);
  36759. return crypto_core_hsalsa20(k, _0, s, sigma);
  36760. }
  36761. var crypto_box_afternm = crypto_secretbox;
  36762. var crypto_box_open_afternm = crypto_secretbox_open;
  36763. function crypto_box(c, m, d, n, y, x) {
  36764. var k = new Uint8Array(32);
  36765. crypto_box_beforenm(k, y, x);
  36766. return crypto_box_afternm(c, m, d, n, k);
  36767. }
  36768. function crypto_box_open(m, c, d, n, y, x) {
  36769. var k = new Uint8Array(32);
  36770. crypto_box_beforenm(k, y, x);
  36771. return crypto_box_open_afternm(m, c, d, n, k);
  36772. }
  36773. var K = [
  36774. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36775. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36776. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36777. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36778. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36779. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36780. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36781. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36782. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36783. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36784. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36785. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36786. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36787. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36788. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36789. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36790. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36791. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36792. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36793. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36794. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36795. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36796. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36797. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36798. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36799. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36800. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36801. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36802. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36803. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36804. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36805. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36806. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36807. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36808. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36809. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36810. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36811. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36812. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36813. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36814. ];
  36815. function crypto_hashblocks_hl(hh, hl, m, n) {
  36816. var wh = new Int32Array(16), wl = new Int32Array(16),
  36817. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36818. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36819. th, tl, i, j, h, l, a, b, c, d;
  36820. var ah0 = hh[0],
  36821. ah1 = hh[1],
  36822. ah2 = hh[2],
  36823. ah3 = hh[3],
  36824. ah4 = hh[4],
  36825. ah5 = hh[5],
  36826. ah6 = hh[6],
  36827. ah7 = hh[7],
  36828. al0 = hl[0],
  36829. al1 = hl[1],
  36830. al2 = hl[2],
  36831. al3 = hl[3],
  36832. al4 = hl[4],
  36833. al5 = hl[5],
  36834. al6 = hl[6],
  36835. al7 = hl[7];
  36836. var pos = 0;
  36837. while (n >= 128) {
  36838. for (i = 0; i < 16; i++) {
  36839. j = 8 * i + pos;
  36840. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36841. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36842. }
  36843. for (i = 0; i < 80; i++) {
  36844. bh0 = ah0;
  36845. bh1 = ah1;
  36846. bh2 = ah2;
  36847. bh3 = ah3;
  36848. bh4 = ah4;
  36849. bh5 = ah5;
  36850. bh6 = ah6;
  36851. bh7 = ah7;
  36852. bl0 = al0;
  36853. bl1 = al1;
  36854. bl2 = al2;
  36855. bl3 = al3;
  36856. bl4 = al4;
  36857. bl5 = al5;
  36858. bl6 = al6;
  36859. bl7 = al7;
  36860. // add
  36861. h = ah7;
  36862. l = al7;
  36863. a = l & 0xffff; b = l >>> 16;
  36864. c = h & 0xffff; d = h >>> 16;
  36865. // Sigma1
  36866. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36867. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36868. a += l & 0xffff; b += l >>> 16;
  36869. c += h & 0xffff; d += h >>> 16;
  36870. // Ch
  36871. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36872. l = (al4 & al5) ^ (~al4 & al6);
  36873. a += l & 0xffff; b += l >>> 16;
  36874. c += h & 0xffff; d += h >>> 16;
  36875. // K
  36876. h = K[i*2];
  36877. l = K[i*2+1];
  36878. a += l & 0xffff; b += l >>> 16;
  36879. c += h & 0xffff; d += h >>> 16;
  36880. // w
  36881. h = wh[i%16];
  36882. l = wl[i%16];
  36883. a += l & 0xffff; b += l >>> 16;
  36884. c += h & 0xffff; d += h >>> 16;
  36885. b += a >>> 16;
  36886. c += b >>> 16;
  36887. d += c >>> 16;
  36888. th = c & 0xffff | d << 16;
  36889. tl = a & 0xffff | b << 16;
  36890. // add
  36891. h = th;
  36892. l = tl;
  36893. a = l & 0xffff; b = l >>> 16;
  36894. c = h & 0xffff; d = h >>> 16;
  36895. // Sigma0
  36896. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36897. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36898. a += l & 0xffff; b += l >>> 16;
  36899. c += h & 0xffff; d += h >>> 16;
  36900. // Maj
  36901. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36902. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36903. a += l & 0xffff; b += l >>> 16;
  36904. c += h & 0xffff; d += h >>> 16;
  36905. b += a >>> 16;
  36906. c += b >>> 16;
  36907. d += c >>> 16;
  36908. bh7 = (c & 0xffff) | (d << 16);
  36909. bl7 = (a & 0xffff) | (b << 16);
  36910. // add
  36911. h = bh3;
  36912. l = bl3;
  36913. a = l & 0xffff; b = l >>> 16;
  36914. c = h & 0xffff; d = h >>> 16;
  36915. h = th;
  36916. l = tl;
  36917. a += l & 0xffff; b += l >>> 16;
  36918. c += h & 0xffff; d += h >>> 16;
  36919. b += a >>> 16;
  36920. c += b >>> 16;
  36921. d += c >>> 16;
  36922. bh3 = (c & 0xffff) | (d << 16);
  36923. bl3 = (a & 0xffff) | (b << 16);
  36924. ah1 = bh0;
  36925. ah2 = bh1;
  36926. ah3 = bh2;
  36927. ah4 = bh3;
  36928. ah5 = bh4;
  36929. ah6 = bh5;
  36930. ah7 = bh6;
  36931. ah0 = bh7;
  36932. al1 = bl0;
  36933. al2 = bl1;
  36934. al3 = bl2;
  36935. al4 = bl3;
  36936. al5 = bl4;
  36937. al6 = bl5;
  36938. al7 = bl6;
  36939. al0 = bl7;
  36940. if (i%16 === 15) {
  36941. for (j = 0; j < 16; j++) {
  36942. // add
  36943. h = wh[j];
  36944. l = wl[j];
  36945. a = l & 0xffff; b = l >>> 16;
  36946. c = h & 0xffff; d = h >>> 16;
  36947. h = wh[(j+9)%16];
  36948. l = wl[(j+9)%16];
  36949. a += l & 0xffff; b += l >>> 16;
  36950. c += h & 0xffff; d += h >>> 16;
  36951. // sigma0
  36952. th = wh[(j+1)%16];
  36953. tl = wl[(j+1)%16];
  36954. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36955. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36956. a += l & 0xffff; b += l >>> 16;
  36957. c += h & 0xffff; d += h >>> 16;
  36958. // sigma1
  36959. th = wh[(j+14)%16];
  36960. tl = wl[(j+14)%16];
  36961. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36962. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36963. a += l & 0xffff; b += l >>> 16;
  36964. c += h & 0xffff; d += h >>> 16;
  36965. b += a >>> 16;
  36966. c += b >>> 16;
  36967. d += c >>> 16;
  36968. wh[j] = (c & 0xffff) | (d << 16);
  36969. wl[j] = (a & 0xffff) | (b << 16);
  36970. }
  36971. }
  36972. }
  36973. // add
  36974. h = ah0;
  36975. l = al0;
  36976. a = l & 0xffff; b = l >>> 16;
  36977. c = h & 0xffff; d = h >>> 16;
  36978. h = hh[0];
  36979. l = hl[0];
  36980. a += l & 0xffff; b += l >>> 16;
  36981. c += h & 0xffff; d += h >>> 16;
  36982. b += a >>> 16;
  36983. c += b >>> 16;
  36984. d += c >>> 16;
  36985. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  36986. hl[0] = al0 = (a & 0xffff) | (b << 16);
  36987. h = ah1;
  36988. l = al1;
  36989. a = l & 0xffff; b = l >>> 16;
  36990. c = h & 0xffff; d = h >>> 16;
  36991. h = hh[1];
  36992. l = hl[1];
  36993. a += l & 0xffff; b += l >>> 16;
  36994. c += h & 0xffff; d += h >>> 16;
  36995. b += a >>> 16;
  36996. c += b >>> 16;
  36997. d += c >>> 16;
  36998. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  36999. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37000. h = ah2;
  37001. l = al2;
  37002. a = l & 0xffff; b = l >>> 16;
  37003. c = h & 0xffff; d = h >>> 16;
  37004. h = hh[2];
  37005. l = hl[2];
  37006. a += l & 0xffff; b += l >>> 16;
  37007. c += h & 0xffff; d += h >>> 16;
  37008. b += a >>> 16;
  37009. c += b >>> 16;
  37010. d += c >>> 16;
  37011. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37012. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37013. h = ah3;
  37014. l = al3;
  37015. a = l & 0xffff; b = l >>> 16;
  37016. c = h & 0xffff; d = h >>> 16;
  37017. h = hh[3];
  37018. l = hl[3];
  37019. a += l & 0xffff; b += l >>> 16;
  37020. c += h & 0xffff; d += h >>> 16;
  37021. b += a >>> 16;
  37022. c += b >>> 16;
  37023. d += c >>> 16;
  37024. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37025. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37026. h = ah4;
  37027. l = al4;
  37028. a = l & 0xffff; b = l >>> 16;
  37029. c = h & 0xffff; d = h >>> 16;
  37030. h = hh[4];
  37031. l = hl[4];
  37032. a += l & 0xffff; b += l >>> 16;
  37033. c += h & 0xffff; d += h >>> 16;
  37034. b += a >>> 16;
  37035. c += b >>> 16;
  37036. d += c >>> 16;
  37037. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37038. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37039. h = ah5;
  37040. l = al5;
  37041. a = l & 0xffff; b = l >>> 16;
  37042. c = h & 0xffff; d = h >>> 16;
  37043. h = hh[5];
  37044. l = hl[5];
  37045. a += l & 0xffff; b += l >>> 16;
  37046. c += h & 0xffff; d += h >>> 16;
  37047. b += a >>> 16;
  37048. c += b >>> 16;
  37049. d += c >>> 16;
  37050. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37051. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37052. h = ah6;
  37053. l = al6;
  37054. a = l & 0xffff; b = l >>> 16;
  37055. c = h & 0xffff; d = h >>> 16;
  37056. h = hh[6];
  37057. l = hl[6];
  37058. a += l & 0xffff; b += l >>> 16;
  37059. c += h & 0xffff; d += h >>> 16;
  37060. b += a >>> 16;
  37061. c += b >>> 16;
  37062. d += c >>> 16;
  37063. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37064. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37065. h = ah7;
  37066. l = al7;
  37067. a = l & 0xffff; b = l >>> 16;
  37068. c = h & 0xffff; d = h >>> 16;
  37069. h = hh[7];
  37070. l = hl[7];
  37071. a += l & 0xffff; b += l >>> 16;
  37072. c += h & 0xffff; d += h >>> 16;
  37073. b += a >>> 16;
  37074. c += b >>> 16;
  37075. d += c >>> 16;
  37076. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37077. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37078. pos += 128;
  37079. n -= 128;
  37080. }
  37081. return n;
  37082. }
  37083. function crypto_hash(out, m, n) {
  37084. var hh = new Int32Array(8),
  37085. hl = new Int32Array(8),
  37086. x = new Uint8Array(256),
  37087. i, b = n;
  37088. hh[0] = 0x6a09e667;
  37089. hh[1] = 0xbb67ae85;
  37090. hh[2] = 0x3c6ef372;
  37091. hh[3] = 0xa54ff53a;
  37092. hh[4] = 0x510e527f;
  37093. hh[5] = 0x9b05688c;
  37094. hh[6] = 0x1f83d9ab;
  37095. hh[7] = 0x5be0cd19;
  37096. hl[0] = 0xf3bcc908;
  37097. hl[1] = 0x84caa73b;
  37098. hl[2] = 0xfe94f82b;
  37099. hl[3] = 0x5f1d36f1;
  37100. hl[4] = 0xade682d1;
  37101. hl[5] = 0x2b3e6c1f;
  37102. hl[6] = 0xfb41bd6b;
  37103. hl[7] = 0x137e2179;
  37104. crypto_hashblocks_hl(hh, hl, m, n);
  37105. n %= 128;
  37106. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37107. x[n] = 128;
  37108. n = 256-128*(n<112?1:0);
  37109. x[n-9] = 0;
  37110. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37111. crypto_hashblocks_hl(hh, hl, x, n);
  37112. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37113. return 0;
  37114. }
  37115. function add(p, q) {
  37116. var a = gf(), b = gf(), c = gf(),
  37117. d = gf(), e = gf(), f = gf(),
  37118. g = gf(), h = gf(), t = gf();
  37119. Z(a, p[1], p[0]);
  37120. Z(t, q[1], q[0]);
  37121. M(a, a, t);
  37122. A(b, p[0], p[1]);
  37123. A(t, q[0], q[1]);
  37124. M(b, b, t);
  37125. M(c, p[3], q[3]);
  37126. M(c, c, D2);
  37127. M(d, p[2], q[2]);
  37128. A(d, d, d);
  37129. Z(e, b, a);
  37130. Z(f, d, c);
  37131. A(g, d, c);
  37132. A(h, b, a);
  37133. M(p[0], e, f);
  37134. M(p[1], h, g);
  37135. M(p[2], g, f);
  37136. M(p[3], e, h);
  37137. }
  37138. function cswap(p, q, b) {
  37139. var i;
  37140. for (i = 0; i < 4; i++) {
  37141. sel25519(p[i], q[i], b);
  37142. }
  37143. }
  37144. function pack(r, p) {
  37145. var tx = gf(), ty = gf(), zi = gf();
  37146. inv25519(zi, p[2]);
  37147. M(tx, p[0], zi);
  37148. M(ty, p[1], zi);
  37149. pack25519(r, ty);
  37150. r[31] ^= par25519(tx) << 7;
  37151. }
  37152. function scalarmult(p, q, s) {
  37153. var b, i;
  37154. set25519(p[0], gf0);
  37155. set25519(p[1], gf1);
  37156. set25519(p[2], gf1);
  37157. set25519(p[3], gf0);
  37158. for (i = 255; i >= 0; --i) {
  37159. b = (s[(i/8)|0] >> (i&7)) & 1;
  37160. cswap(p, q, b);
  37161. add(q, p);
  37162. add(p, p);
  37163. cswap(p, q, b);
  37164. }
  37165. }
  37166. function scalarbase(p, s) {
  37167. var q = [gf(), gf(), gf(), gf()];
  37168. set25519(q[0], X);
  37169. set25519(q[1], Y);
  37170. set25519(q[2], gf1);
  37171. M(q[3], X, Y);
  37172. scalarmult(p, q, s);
  37173. }
  37174. function crypto_sign_keypair(pk, sk, seeded) {
  37175. var d = new Uint8Array(64);
  37176. var p = [gf(), gf(), gf(), gf()];
  37177. var i;
  37178. if (!seeded) randombytes(sk, 32);
  37179. crypto_hash(d, sk, 32);
  37180. d[0] &= 248;
  37181. d[31] &= 127;
  37182. d[31] |= 64;
  37183. scalarbase(p, d);
  37184. pack(pk, p);
  37185. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37186. return 0;
  37187. }
  37188. 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]);
  37189. function modL(r, x) {
  37190. var carry, i, j, k;
  37191. for (i = 63; i >= 32; --i) {
  37192. carry = 0;
  37193. for (j = i - 32, k = i - 12; j < k; ++j) {
  37194. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37195. carry = (x[j] + 128) >> 8;
  37196. x[j] -= carry * 256;
  37197. }
  37198. x[j] += carry;
  37199. x[i] = 0;
  37200. }
  37201. carry = 0;
  37202. for (j = 0; j < 32; j++) {
  37203. x[j] += carry - (x[31] >> 4) * L[j];
  37204. carry = x[j] >> 8;
  37205. x[j] &= 255;
  37206. }
  37207. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37208. for (i = 0; i < 32; i++) {
  37209. x[i+1] += x[i] >> 8;
  37210. r[i] = x[i] & 255;
  37211. }
  37212. }
  37213. function reduce(r) {
  37214. var x = new Float64Array(64), i;
  37215. for (i = 0; i < 64; i++) x[i] = r[i];
  37216. for (i = 0; i < 64; i++) r[i] = 0;
  37217. modL(r, x);
  37218. }
  37219. // Note: difference from C - smlen returned, not passed as argument.
  37220. function crypto_sign(sm, m, n, sk) {
  37221. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37222. var i, j, x = new Float64Array(64);
  37223. var p = [gf(), gf(), gf(), gf()];
  37224. crypto_hash(d, sk, 32);
  37225. d[0] &= 248;
  37226. d[31] &= 127;
  37227. d[31] |= 64;
  37228. var smlen = n + 64;
  37229. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37230. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37231. crypto_hash(r, sm.subarray(32), n+32);
  37232. reduce(r);
  37233. scalarbase(p, r);
  37234. pack(sm, p);
  37235. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37236. crypto_hash(h, sm, n + 64);
  37237. reduce(h);
  37238. for (i = 0; i < 64; i++) x[i] = 0;
  37239. for (i = 0; i < 32; i++) x[i] = r[i];
  37240. for (i = 0; i < 32; i++) {
  37241. for (j = 0; j < 32; j++) {
  37242. x[i+j] += h[i] * d[j];
  37243. }
  37244. }
  37245. modL(sm.subarray(32), x);
  37246. return smlen;
  37247. }
  37248. function unpackneg(r, p) {
  37249. var t = gf(), chk = gf(), num = gf(),
  37250. den = gf(), den2 = gf(), den4 = gf(),
  37251. den6 = gf();
  37252. set25519(r[2], gf1);
  37253. unpack25519(r[1], p);
  37254. S(num, r[1]);
  37255. M(den, num, D);
  37256. Z(num, num, r[2]);
  37257. A(den, r[2], den);
  37258. S(den2, den);
  37259. S(den4, den2);
  37260. M(den6, den4, den2);
  37261. M(t, den6, num);
  37262. M(t, t, den);
  37263. pow2523(t, t);
  37264. M(t, t, num);
  37265. M(t, t, den);
  37266. M(t, t, den);
  37267. M(r[0], t, den);
  37268. S(chk, r[0]);
  37269. M(chk, chk, den);
  37270. if (neq25519(chk, num)) M(r[0], r[0], I);
  37271. S(chk, r[0]);
  37272. M(chk, chk, den);
  37273. if (neq25519(chk, num)) return -1;
  37274. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37275. M(r[3], r[0], r[1]);
  37276. return 0;
  37277. }
  37278. function crypto_sign_open(m, sm, n, pk) {
  37279. var i, mlen;
  37280. var t = new Uint8Array(32), h = new Uint8Array(64);
  37281. var p = [gf(), gf(), gf(), gf()],
  37282. q = [gf(), gf(), gf(), gf()];
  37283. mlen = -1;
  37284. if (n < 64) return -1;
  37285. if (unpackneg(q, pk)) return -1;
  37286. for (i = 0; i < n; i++) m[i] = sm[i];
  37287. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37288. crypto_hash(h, m, n);
  37289. reduce(h);
  37290. scalarmult(p, q, h);
  37291. scalarbase(q, sm.subarray(32));
  37292. add(p, q);
  37293. pack(t, p);
  37294. n -= 64;
  37295. if (crypto_verify_32(sm, 0, t, 0)) {
  37296. for (i = 0; i < n; i++) m[i] = 0;
  37297. return -1;
  37298. }
  37299. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37300. mlen = n;
  37301. return mlen;
  37302. }
  37303. var crypto_secretbox_KEYBYTES = 32,
  37304. crypto_secretbox_NONCEBYTES = 24,
  37305. crypto_secretbox_ZEROBYTES = 32,
  37306. crypto_secretbox_BOXZEROBYTES = 16,
  37307. crypto_scalarmult_BYTES = 32,
  37308. crypto_scalarmult_SCALARBYTES = 32,
  37309. crypto_box_PUBLICKEYBYTES = 32,
  37310. crypto_box_SECRETKEYBYTES = 32,
  37311. crypto_box_BEFORENMBYTES = 32,
  37312. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37313. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37314. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37315. crypto_sign_BYTES = 64,
  37316. crypto_sign_PUBLICKEYBYTES = 32,
  37317. crypto_sign_SECRETKEYBYTES = 64,
  37318. crypto_sign_SEEDBYTES = 32,
  37319. crypto_hash_BYTES = 64;
  37320. nacl.lowlevel = {
  37321. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37322. crypto_stream_xor: crypto_stream_xor,
  37323. crypto_stream: crypto_stream,
  37324. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37325. crypto_stream_salsa20: crypto_stream_salsa20,
  37326. crypto_onetimeauth: crypto_onetimeauth,
  37327. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37328. crypto_verify_16: crypto_verify_16,
  37329. crypto_verify_32: crypto_verify_32,
  37330. crypto_secretbox: crypto_secretbox,
  37331. crypto_secretbox_open: crypto_secretbox_open,
  37332. crypto_scalarmult: crypto_scalarmult,
  37333. crypto_scalarmult_base: crypto_scalarmult_base,
  37334. crypto_box_beforenm: crypto_box_beforenm,
  37335. crypto_box_afternm: crypto_box_afternm,
  37336. crypto_box: crypto_box,
  37337. crypto_box_open: crypto_box_open,
  37338. crypto_box_keypair: crypto_box_keypair,
  37339. crypto_hash: crypto_hash,
  37340. crypto_sign: crypto_sign,
  37341. crypto_sign_keypair: crypto_sign_keypair,
  37342. crypto_sign_open: crypto_sign_open,
  37343. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37344. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37345. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37346. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37347. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37348. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37349. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37350. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37351. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37352. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37353. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37354. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37355. crypto_sign_BYTES: crypto_sign_BYTES,
  37356. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37357. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37358. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37359. crypto_hash_BYTES: crypto_hash_BYTES
  37360. };
  37361. /* High-level API */
  37362. function checkLengths(k, n) {
  37363. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37364. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37365. }
  37366. function checkBoxLengths(pk, sk) {
  37367. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37368. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37369. }
  37370. function checkArrayTypes() {
  37371. for (var i = 0; i < arguments.length; i++) {
  37372. if (!(arguments[i] instanceof Uint8Array))
  37373. throw new TypeError('unexpected type, use Uint8Array');
  37374. }
  37375. }
  37376. function cleanup(arr) {
  37377. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37378. }
  37379. nacl.randomBytes = function(n) {
  37380. var b = new Uint8Array(n);
  37381. randombytes(b, n);
  37382. return b;
  37383. };
  37384. nacl.secretbox = function(msg, nonce, key) {
  37385. checkArrayTypes(msg, nonce, key);
  37386. checkLengths(key, nonce);
  37387. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37388. var c = new Uint8Array(m.length);
  37389. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37390. crypto_secretbox(c, m, m.length, nonce, key);
  37391. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37392. };
  37393. nacl.secretbox.open = function(box, nonce, key) {
  37394. checkArrayTypes(box, nonce, key);
  37395. checkLengths(key, nonce);
  37396. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37397. var m = new Uint8Array(c.length);
  37398. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37399. if (c.length < 32) return null;
  37400. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37401. return m.subarray(crypto_secretbox_ZEROBYTES);
  37402. };
  37403. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37404. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37405. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37406. nacl.scalarMult = function(n, p) {
  37407. checkArrayTypes(n, p);
  37408. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37409. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37410. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37411. crypto_scalarmult(q, n, p);
  37412. return q;
  37413. };
  37414. nacl.scalarMult.base = function(n) {
  37415. checkArrayTypes(n);
  37416. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37417. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37418. crypto_scalarmult_base(q, n);
  37419. return q;
  37420. };
  37421. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37422. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37423. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37424. var k = nacl.box.before(publicKey, secretKey);
  37425. return nacl.secretbox(msg, nonce, k);
  37426. };
  37427. nacl.box.before = function(publicKey, secretKey) {
  37428. checkArrayTypes(publicKey, secretKey);
  37429. checkBoxLengths(publicKey, secretKey);
  37430. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37431. crypto_box_beforenm(k, publicKey, secretKey);
  37432. return k;
  37433. };
  37434. nacl.box.after = nacl.secretbox;
  37435. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37436. var k = nacl.box.before(publicKey, secretKey);
  37437. return nacl.secretbox.open(msg, nonce, k);
  37438. };
  37439. nacl.box.open.after = nacl.secretbox.open;
  37440. nacl.box.keyPair = function() {
  37441. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37442. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37443. crypto_box_keypair(pk, sk);
  37444. return {publicKey: pk, secretKey: sk};
  37445. };
  37446. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37447. checkArrayTypes(secretKey);
  37448. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37449. throw new Error('bad secret key size');
  37450. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37451. crypto_scalarmult_base(pk, secretKey);
  37452. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37453. };
  37454. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37455. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37456. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37457. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37458. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37459. nacl.sign = function(msg, secretKey) {
  37460. checkArrayTypes(msg, secretKey);
  37461. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37462. throw new Error('bad secret key size');
  37463. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37464. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37465. return signedMsg;
  37466. };
  37467. nacl.sign.open = function(signedMsg, publicKey) {
  37468. checkArrayTypes(signedMsg, publicKey);
  37469. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37470. throw new Error('bad public key size');
  37471. var tmp = new Uint8Array(signedMsg.length);
  37472. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37473. if (mlen < 0) return null;
  37474. var m = new Uint8Array(mlen);
  37475. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37476. return m;
  37477. };
  37478. nacl.sign.detached = function(msg, secretKey) {
  37479. var signedMsg = nacl.sign(msg, secretKey);
  37480. var sig = new Uint8Array(crypto_sign_BYTES);
  37481. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37482. return sig;
  37483. };
  37484. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37485. checkArrayTypes(msg, sig, publicKey);
  37486. if (sig.length !== crypto_sign_BYTES)
  37487. throw new Error('bad signature size');
  37488. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37489. throw new Error('bad public key size');
  37490. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37491. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37492. var i;
  37493. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37494. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37495. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37496. };
  37497. nacl.sign.keyPair = function() {
  37498. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37499. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37500. crypto_sign_keypair(pk, sk);
  37501. return {publicKey: pk, secretKey: sk};
  37502. };
  37503. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37504. checkArrayTypes(secretKey);
  37505. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37506. throw new Error('bad secret key size');
  37507. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37508. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37509. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37510. };
  37511. nacl.sign.keyPair.fromSeed = function(seed) {
  37512. checkArrayTypes(seed);
  37513. if (seed.length !== crypto_sign_SEEDBYTES)
  37514. throw new Error('bad seed size');
  37515. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37516. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37517. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37518. crypto_sign_keypair(pk, sk, true);
  37519. return {publicKey: pk, secretKey: sk};
  37520. };
  37521. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37522. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37523. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37524. nacl.sign.signatureLength = crypto_sign_BYTES;
  37525. nacl.hash = function(msg) {
  37526. checkArrayTypes(msg);
  37527. var h = new Uint8Array(crypto_hash_BYTES);
  37528. crypto_hash(h, msg, msg.length);
  37529. return h;
  37530. };
  37531. nacl.hash.hashLength = crypto_hash_BYTES;
  37532. nacl.verify = function(x, y) {
  37533. checkArrayTypes(x, y);
  37534. // Zero length arguments are considered not equal.
  37535. if (x.length === 0 || y.length === 0) return false;
  37536. if (x.length !== y.length) return false;
  37537. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37538. };
  37539. nacl.setPRNG = function(fn) {
  37540. randombytes = fn;
  37541. };
  37542. (function() {
  37543. // Initialize PRNG if environment provides CSPRNG.
  37544. // If not, methods calling randombytes will throw.
  37545. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37546. if (crypto && crypto.getRandomValues) {
  37547. // Browsers.
  37548. var QUOTA = 65536;
  37549. nacl.setPRNG(function(x, n) {
  37550. var i, v = new Uint8Array(n);
  37551. for (i = 0; i < n; i += QUOTA) {
  37552. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37553. }
  37554. for (i = 0; i < n; i++) x[i] = v[i];
  37555. cleanup(v);
  37556. });
  37557. } else if (true) {
  37558. // Node.js.
  37559. crypto = __webpack_require__(3);
  37560. if (crypto && crypto.randomBytes) {
  37561. nacl.setPRNG(function(x, n) {
  37562. var i, v = crypto.randomBytes(n);
  37563. for (i = 0; i < n; i++) x[i] = v[i];
  37564. cleanup(v);
  37565. });
  37566. }
  37567. }
  37568. })();
  37569. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37570. /***/ }),
  37571. /* 1 */
  37572. /***/ (function(module, exports, __webpack_require__) {
  37573. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37574. // Public domain.
  37575. (function(root, f) {
  37576. 'use strict';
  37577. if ( true && module.exports) module.exports = f();
  37578. else if (root.nacl) root.nacl.util = f();
  37579. else {
  37580. root.nacl = {};
  37581. root.nacl.util = f();
  37582. }
  37583. }(this, function() {
  37584. 'use strict';
  37585. var util = {};
  37586. function validateBase64(s) {
  37587. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37588. throw new TypeError('invalid encoding');
  37589. }
  37590. }
  37591. util.decodeUTF8 = function(s) {
  37592. if (typeof s !== 'string') throw new TypeError('expected string');
  37593. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37594. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37595. return b;
  37596. };
  37597. util.encodeUTF8 = function(arr) {
  37598. var i, s = [];
  37599. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37600. return decodeURIComponent(escape(s.join('')));
  37601. };
  37602. if (typeof atob === 'undefined') {
  37603. // Node.js
  37604. if (typeof Buffer.from !== 'undefined') {
  37605. // Node v6 and later
  37606. util.encodeBase64 = function (arr) { // v6 and later
  37607. return Buffer.from(arr).toString('base64');
  37608. };
  37609. util.decodeBase64 = function (s) {
  37610. validateBase64(s);
  37611. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37612. };
  37613. } else {
  37614. // Node earlier than v6
  37615. util.encodeBase64 = function (arr) { // v6 and later
  37616. return (new Buffer(arr)).toString('base64');
  37617. };
  37618. util.decodeBase64 = function(s) {
  37619. validateBase64(s);
  37620. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37621. };
  37622. }
  37623. } else {
  37624. // Browsers
  37625. util.encodeBase64 = function(arr) {
  37626. var i, s = [], len = arr.length;
  37627. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37628. return btoa(s.join(''));
  37629. };
  37630. util.decodeBase64 = function(s) {
  37631. validateBase64(s);
  37632. var i, d = atob(s), b = new Uint8Array(d.length);
  37633. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37634. return b;
  37635. };
  37636. }
  37637. return util;
  37638. }));
  37639. /***/ }),
  37640. /* 2 */
  37641. /***/ (function(module, exports, __webpack_require__) {
  37642. // required so we don't have to do require('pusher').default etc.
  37643. module.exports = __webpack_require__(4).default;
  37644. /***/ }),
  37645. /* 3 */
  37646. /***/ (function(module, exports) {
  37647. /* (ignored) */
  37648. /***/ }),
  37649. /* 4 */
  37650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37651. "use strict";
  37652. __webpack_require__.r(__webpack_exports__);
  37653. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37654. var ScriptReceiverFactory = (function () {
  37655. function ScriptReceiverFactory(prefix, name) {
  37656. this.lastId = 0;
  37657. this.prefix = prefix;
  37658. this.name = name;
  37659. }
  37660. ScriptReceiverFactory.prototype.create = function (callback) {
  37661. this.lastId++;
  37662. var number = this.lastId;
  37663. var id = this.prefix + number;
  37664. var name = this.name + "[" + number + "]";
  37665. var called = false;
  37666. var callbackWrapper = function () {
  37667. if (!called) {
  37668. callback.apply(null, arguments);
  37669. called = true;
  37670. }
  37671. };
  37672. this[number] = callbackWrapper;
  37673. return { number: number, id: id, name: name, callback: callbackWrapper };
  37674. };
  37675. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37676. delete this[receiver.number];
  37677. };
  37678. return ScriptReceiverFactory;
  37679. }());
  37680. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37681. // CONCATENATED MODULE: ./src/core/defaults.ts
  37682. var Defaults = {
  37683. VERSION: "5.0.3",
  37684. PROTOCOL: 7,
  37685. host: 'ws.pusherapp.com',
  37686. ws_port: 80,
  37687. wss_port: 443,
  37688. ws_path: '',
  37689. sockjs_host: 'sockjs.pusher.com',
  37690. sockjs_http_port: 80,
  37691. sockjs_https_port: 443,
  37692. sockjs_path: '/pusher',
  37693. stats_host: 'stats.pusher.com',
  37694. channel_auth_endpoint: '/pusher/auth',
  37695. channel_auth_transport: 'ajax',
  37696. activity_timeout: 120000,
  37697. pong_timeout: 30000,
  37698. unavailable_timeout: 10000,
  37699. cdn_http: "http://js.pusher.com",
  37700. cdn_https: "https://js.pusher.com",
  37701. dependency_suffix: ""
  37702. };
  37703. /* harmony default export */ var defaults = (Defaults);
  37704. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37705. var dependency_loader_DependencyLoader = (function () {
  37706. function DependencyLoader(options) {
  37707. this.options = options;
  37708. this.receivers = options.receivers || ScriptReceivers;
  37709. this.loading = {};
  37710. }
  37711. DependencyLoader.prototype.load = function (name, options, callback) {
  37712. var self = this;
  37713. if (self.loading[name] && self.loading[name].length > 0) {
  37714. self.loading[name].push(callback);
  37715. }
  37716. else {
  37717. self.loading[name] = [callback];
  37718. var request = runtime.createScriptRequest(self.getPath(name, options));
  37719. var receiver = self.receivers.create(function (error) {
  37720. self.receivers.remove(receiver);
  37721. if (self.loading[name]) {
  37722. var callbacks = self.loading[name];
  37723. delete self.loading[name];
  37724. var successCallback = function (wasSuccessful) {
  37725. if (!wasSuccessful) {
  37726. request.cleanup();
  37727. }
  37728. };
  37729. for (var i = 0; i < callbacks.length; i++) {
  37730. callbacks[i](error, successCallback);
  37731. }
  37732. }
  37733. });
  37734. request.send(receiver);
  37735. }
  37736. };
  37737. DependencyLoader.prototype.getRoot = function (options) {
  37738. var cdn;
  37739. var protocol = runtime.getDocument().location.protocol;
  37740. if ((options && options.useTLS) || protocol === "https:") {
  37741. cdn = this.options.cdn_https;
  37742. }
  37743. else {
  37744. cdn = this.options.cdn_http;
  37745. }
  37746. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37747. };
  37748. DependencyLoader.prototype.getPath = function (name, options) {
  37749. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37750. };
  37751. ;
  37752. return DependencyLoader;
  37753. }());
  37754. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37755. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37756. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37757. var Dependencies = new dependency_loader({
  37758. cdn_http: defaults.cdn_http,
  37759. cdn_https: defaults.cdn_https,
  37760. version: defaults.VERSION,
  37761. suffix: defaults.dependency_suffix,
  37762. receivers: DependenciesReceivers
  37763. });
  37764. // CONCATENATED MODULE: ./src/core/base64.ts
  37765. function encode(s) {
  37766. return btoa(utob(s));
  37767. }
  37768. var fromCharCode = String.fromCharCode;
  37769. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37770. var b64tab = {};
  37771. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37772. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37773. }
  37774. var cb_utob = function (c) {
  37775. var cc = c.charCodeAt(0);
  37776. return cc < 0x80
  37777. ? c
  37778. : cc < 0x800
  37779. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37780. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37781. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37782. fromCharCode(0x80 | (cc & 0x3f));
  37783. };
  37784. var utob = function (u) {
  37785. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37786. };
  37787. var cb_encode = function (ccc) {
  37788. var padlen = [0, 2, 1][ccc.length % 3];
  37789. var ord = (ccc.charCodeAt(0) << 16) |
  37790. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37791. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37792. var chars = [
  37793. b64chars.charAt(ord >>> 18),
  37794. b64chars.charAt((ord >>> 12) & 63),
  37795. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37796. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37797. ];
  37798. return chars.join('');
  37799. };
  37800. var btoa = window.btoa ||
  37801. function (b) {
  37802. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37803. };
  37804. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37805. var Timer = (function () {
  37806. function Timer(set, clear, delay, callback) {
  37807. var _this = this;
  37808. this.clear = clear;
  37809. this.timer = set(function () {
  37810. if (_this.timer) {
  37811. _this.timer = callback(_this.timer);
  37812. }
  37813. }, delay);
  37814. }
  37815. Timer.prototype.isRunning = function () {
  37816. return this.timer !== null;
  37817. };
  37818. Timer.prototype.ensureAborted = function () {
  37819. if (this.timer) {
  37820. this.clear(this.timer);
  37821. this.timer = null;
  37822. }
  37823. };
  37824. return Timer;
  37825. }());
  37826. /* harmony default export */ var abstract_timer = (Timer);
  37827. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37828. var __extends = (undefined && undefined.__extends) || (function () {
  37829. var extendStatics = function (d, b) {
  37830. extendStatics = Object.setPrototypeOf ||
  37831. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37832. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37833. return extendStatics(d, b);
  37834. };
  37835. return function (d, b) {
  37836. extendStatics(d, b);
  37837. function __() { this.constructor = d; }
  37838. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37839. };
  37840. })();
  37841. function timers_clearTimeout(timer) {
  37842. window.clearTimeout(timer);
  37843. }
  37844. function timers_clearInterval(timer) {
  37845. window.clearInterval(timer);
  37846. }
  37847. var OneOffTimer = (function (_super) {
  37848. __extends(OneOffTimer, _super);
  37849. function OneOffTimer(delay, callback) {
  37850. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37851. callback();
  37852. return null;
  37853. }) || this;
  37854. }
  37855. return OneOffTimer;
  37856. }(abstract_timer));
  37857. var PeriodicTimer = (function (_super) {
  37858. __extends(PeriodicTimer, _super);
  37859. function PeriodicTimer(delay, callback) {
  37860. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37861. callback();
  37862. return timer;
  37863. }) || this;
  37864. }
  37865. return PeriodicTimer;
  37866. }(abstract_timer));
  37867. // CONCATENATED MODULE: ./src/core/util.ts
  37868. var Util = {
  37869. now: function () {
  37870. if (Date.now) {
  37871. return Date.now();
  37872. }
  37873. else {
  37874. return new Date().valueOf();
  37875. }
  37876. },
  37877. defer: function (callback) {
  37878. return new OneOffTimer(0, callback);
  37879. },
  37880. method: function (name) {
  37881. var args = [];
  37882. for (var _i = 1; _i < arguments.length; _i++) {
  37883. args[_i - 1] = arguments[_i];
  37884. }
  37885. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37886. return function (object) {
  37887. return object[name].apply(object, boundArguments.concat(arguments));
  37888. };
  37889. }
  37890. };
  37891. /* harmony default export */ var util = (Util);
  37892. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37893. function extend(target) {
  37894. var sources = [];
  37895. for (var _i = 1; _i < arguments.length; _i++) {
  37896. sources[_i - 1] = arguments[_i];
  37897. }
  37898. for (var i = 0; i < sources.length; i++) {
  37899. var extensions = sources[i];
  37900. for (var property in extensions) {
  37901. if (extensions[property] && extensions[property].constructor &&
  37902. extensions[property].constructor === Object) {
  37903. target[property] = extend(target[property] || {}, extensions[property]);
  37904. }
  37905. else {
  37906. target[property] = extensions[property];
  37907. }
  37908. }
  37909. }
  37910. return target;
  37911. }
  37912. function stringify() {
  37913. var m = ["Pusher"];
  37914. for (var i = 0; i < arguments.length; i++) {
  37915. if (typeof arguments[i] === "string") {
  37916. m.push(arguments[i]);
  37917. }
  37918. else {
  37919. m.push(safeJSONStringify(arguments[i]));
  37920. }
  37921. }
  37922. return m.join(" : ");
  37923. }
  37924. function arrayIndexOf(array, item) {
  37925. var nativeIndexOf = Array.prototype.indexOf;
  37926. if (array === null) {
  37927. return -1;
  37928. }
  37929. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37930. return array.indexOf(item);
  37931. }
  37932. for (var i = 0, l = array.length; i < l; i++) {
  37933. if (array[i] === item) {
  37934. return i;
  37935. }
  37936. }
  37937. return -1;
  37938. }
  37939. function objectApply(object, f) {
  37940. for (var key in object) {
  37941. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37942. f(object[key], key, object);
  37943. }
  37944. }
  37945. }
  37946. function keys(object) {
  37947. var keys = [];
  37948. objectApply(object, function (_, key) {
  37949. keys.push(key);
  37950. });
  37951. return keys;
  37952. }
  37953. function values(object) {
  37954. var values = [];
  37955. objectApply(object, function (value) {
  37956. values.push(value);
  37957. });
  37958. return values;
  37959. }
  37960. function apply(array, f, context) {
  37961. for (var i = 0; i < array.length; i++) {
  37962. f.call(context || window, array[i], i, array);
  37963. }
  37964. }
  37965. function map(array, f) {
  37966. var result = [];
  37967. for (var i = 0; i < array.length; i++) {
  37968. result.push(f(array[i], i, array, result));
  37969. }
  37970. return result;
  37971. }
  37972. function mapObject(object, f) {
  37973. var result = {};
  37974. objectApply(object, function (value, key) {
  37975. result[key] = f(value);
  37976. });
  37977. return result;
  37978. }
  37979. function filter(array, test) {
  37980. test = test || function (value) { return !!value; };
  37981. var result = [];
  37982. for (var i = 0; i < array.length; i++) {
  37983. if (test(array[i], i, array, result)) {
  37984. result.push(array[i]);
  37985. }
  37986. }
  37987. return result;
  37988. }
  37989. function filterObject(object, test) {
  37990. var result = {};
  37991. objectApply(object, function (value, key) {
  37992. if ((test && test(value, key, object, result)) || Boolean(value)) {
  37993. result[key] = value;
  37994. }
  37995. });
  37996. return result;
  37997. }
  37998. function flatten(object) {
  37999. var result = [];
  38000. objectApply(object, function (value, key) {
  38001. result.push([key, value]);
  38002. });
  38003. return result;
  38004. }
  38005. function any(array, test) {
  38006. for (var i = 0; i < array.length; i++) {
  38007. if (test(array[i], i, array)) {
  38008. return true;
  38009. }
  38010. }
  38011. return false;
  38012. }
  38013. function collections_all(array, test) {
  38014. for (var i = 0; i < array.length; i++) {
  38015. if (!test(array[i], i, array)) {
  38016. return false;
  38017. }
  38018. }
  38019. return true;
  38020. }
  38021. function encodeParamsObject(data) {
  38022. return mapObject(data, function (value) {
  38023. if (typeof value === "object") {
  38024. value = safeJSONStringify(value);
  38025. }
  38026. return encodeURIComponent(encode(value.toString()));
  38027. });
  38028. }
  38029. function buildQueryString(data) {
  38030. var params = filterObject(data, function (value) {
  38031. return value !== undefined;
  38032. });
  38033. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38034. return query;
  38035. }
  38036. function decycleObject(object) {
  38037. var objects = [], paths = [];
  38038. return (function derez(value, path) {
  38039. var i, name, nu;
  38040. switch (typeof value) {
  38041. case 'object':
  38042. if (!value) {
  38043. return null;
  38044. }
  38045. for (i = 0; i < objects.length; i += 1) {
  38046. if (objects[i] === value) {
  38047. return { $ref: paths[i] };
  38048. }
  38049. }
  38050. objects.push(value);
  38051. paths.push(path);
  38052. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38053. nu = [];
  38054. for (i = 0; i < value.length; i += 1) {
  38055. nu[i] = derez(value[i], path + '[' + i + ']');
  38056. }
  38057. }
  38058. else {
  38059. nu = {};
  38060. for (name in value) {
  38061. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38062. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38063. }
  38064. }
  38065. }
  38066. return nu;
  38067. case 'number':
  38068. case 'string':
  38069. case 'boolean':
  38070. return value;
  38071. }
  38072. }(object, '$'));
  38073. }
  38074. function safeJSONStringify(source) {
  38075. try {
  38076. return JSON.stringify(source);
  38077. }
  38078. catch (e) {
  38079. return JSON.stringify(decycleObject(source));
  38080. }
  38081. }
  38082. // CONCATENATED MODULE: ./src/core/logger.ts
  38083. var logger_Logger = (function () {
  38084. function Logger() {
  38085. this.globalLog = function (message) {
  38086. if (window.console && window.console.log) {
  38087. window.console.log(message);
  38088. }
  38089. };
  38090. }
  38091. Logger.prototype.debug = function () {
  38092. var args = [];
  38093. for (var _i = 0; _i < arguments.length; _i++) {
  38094. args[_i] = arguments[_i];
  38095. }
  38096. this.log(this.globalLog, args);
  38097. };
  38098. Logger.prototype.warn = function () {
  38099. var args = [];
  38100. for (var _i = 0; _i < arguments.length; _i++) {
  38101. args[_i] = arguments[_i];
  38102. }
  38103. this.log(this.globalLogWarn, args);
  38104. };
  38105. Logger.prototype.error = function () {
  38106. var args = [];
  38107. for (var _i = 0; _i < arguments.length; _i++) {
  38108. args[_i] = arguments[_i];
  38109. }
  38110. this.log(this.globalLogError, args);
  38111. };
  38112. Logger.prototype.globalLogWarn = function (message) {
  38113. if (window.console && window.console.warn) {
  38114. window.console.warn(message);
  38115. }
  38116. else {
  38117. this.globalLog(message);
  38118. }
  38119. };
  38120. Logger.prototype.globalLogError = function (message) {
  38121. if (window.console && window.console.error) {
  38122. window.console.error(message);
  38123. }
  38124. else {
  38125. this.globalLogWarn(message);
  38126. }
  38127. };
  38128. Logger.prototype.log = function (defaultLoggingFunction) {
  38129. var args = [];
  38130. for (var _i = 1; _i < arguments.length; _i++) {
  38131. args[_i - 1] = arguments[_i];
  38132. }
  38133. var message = stringify.apply(this, arguments);
  38134. if (core_pusher.log) {
  38135. core_pusher.log(message);
  38136. }
  38137. else if (core_pusher.logToConsole) {
  38138. var log = defaultLoggingFunction.bind(this);
  38139. log(message);
  38140. }
  38141. };
  38142. return Logger;
  38143. }());
  38144. /* harmony default export */ var logger = (new logger_Logger());
  38145. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38146. var urlStore = {
  38147. baseUrl: "https://pusher.com",
  38148. urls: {
  38149. authenticationEndpoint: {
  38150. path: "/docs/authenticating_users",
  38151. },
  38152. javascriptQuickStart: {
  38153. path: "/docs/javascript_quick_start"
  38154. },
  38155. triggeringClientEvents: {
  38156. path: "/docs/client_api_guide/client_events#trigger-events"
  38157. }
  38158. }
  38159. };
  38160. var buildLogSuffix = function (key) {
  38161. var urlPrefix = "See:";
  38162. var urlObj = urlStore.urls[key];
  38163. if (!urlObj)
  38164. return "";
  38165. var url;
  38166. if (urlObj.fullUrl) {
  38167. url = urlObj.fullUrl;
  38168. }
  38169. else if (urlObj.path) {
  38170. url = urlStore.baseUrl + urlObj.path;
  38171. }
  38172. if (!url)
  38173. return "";
  38174. return urlPrefix + " " + url;
  38175. };
  38176. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38177. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38178. var ajax = function (context, socketId, callback) {
  38179. var self = this, xhr;
  38180. xhr = runtime.createXHR();
  38181. xhr.open("POST", self.options.authEndpoint, true);
  38182. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38183. for (var headerName in this.authOptions.headers) {
  38184. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38185. }
  38186. xhr.onreadystatechange = function () {
  38187. if (xhr.readyState === 4) {
  38188. if (xhr.status === 200) {
  38189. var data, parsed = false;
  38190. try {
  38191. data = JSON.parse(xhr.responseText);
  38192. parsed = true;
  38193. }
  38194. catch (e) {
  38195. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38196. }
  38197. if (parsed) {
  38198. callback(false, data);
  38199. }
  38200. }
  38201. else {
  38202. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38203. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38204. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38205. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38206. callback(true, xhr.status);
  38207. }
  38208. }
  38209. };
  38210. xhr.send(this.composeQuery(socketId));
  38211. return xhr;
  38212. };
  38213. /* harmony default export */ var xhr_auth = (ajax);
  38214. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38215. var jsonp = function (context, socketId, callback) {
  38216. if (this.authOptions.headers !== undefined) {
  38217. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38218. }
  38219. var callbackName = context.nextAuthCallbackID.toString();
  38220. context.nextAuthCallbackID++;
  38221. var document = context.getDocument();
  38222. var script = document.createElement("script");
  38223. context.auth_callbacks[callbackName] = function (data) {
  38224. callback(false, data);
  38225. };
  38226. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38227. script.src = this.options.authEndpoint +
  38228. '?callback=' +
  38229. encodeURIComponent(callback_name) +
  38230. '&' +
  38231. this.composeQuery(socketId);
  38232. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38233. head.insertBefore(script, head.firstChild);
  38234. };
  38235. /* harmony default export */ var jsonp_auth = (jsonp);
  38236. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38237. var ScriptRequest = (function () {
  38238. function ScriptRequest(src) {
  38239. this.src = src;
  38240. }
  38241. ScriptRequest.prototype.send = function (receiver) {
  38242. var self = this;
  38243. var errorString = "Error loading " + self.src;
  38244. self.script = document.createElement("script");
  38245. self.script.id = receiver.id;
  38246. self.script.src = self.src;
  38247. self.script.type = "text/javascript";
  38248. self.script.charset = "UTF-8";
  38249. if (self.script.addEventListener) {
  38250. self.script.onerror = function () {
  38251. receiver.callback(errorString);
  38252. };
  38253. self.script.onload = function () {
  38254. receiver.callback(null);
  38255. };
  38256. }
  38257. else {
  38258. self.script.onreadystatechange = function () {
  38259. if (self.script.readyState === 'loaded' ||
  38260. self.script.readyState === 'complete') {
  38261. receiver.callback(null);
  38262. }
  38263. };
  38264. }
  38265. if (self.script.async === undefined && document.attachEvent &&
  38266. /opera/i.test(navigator.userAgent)) {
  38267. self.errorScript = document.createElement("script");
  38268. self.errorScript.id = receiver.id + "_error";
  38269. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38270. self.script.async = self.errorScript.async = false;
  38271. }
  38272. else {
  38273. self.script.async = true;
  38274. }
  38275. var head = document.getElementsByTagName('head')[0];
  38276. head.insertBefore(self.script, head.firstChild);
  38277. if (self.errorScript) {
  38278. head.insertBefore(self.errorScript, self.script.nextSibling);
  38279. }
  38280. };
  38281. ScriptRequest.prototype.cleanup = function () {
  38282. if (this.script) {
  38283. this.script.onload = this.script.onerror = null;
  38284. this.script.onreadystatechange = null;
  38285. }
  38286. if (this.script && this.script.parentNode) {
  38287. this.script.parentNode.removeChild(this.script);
  38288. }
  38289. if (this.errorScript && this.errorScript.parentNode) {
  38290. this.errorScript.parentNode.removeChild(this.errorScript);
  38291. }
  38292. this.script = null;
  38293. this.errorScript = null;
  38294. };
  38295. return ScriptRequest;
  38296. }());
  38297. /* harmony default export */ var script_request = (ScriptRequest);
  38298. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38299. var jsonp_request_JSONPRequest = (function () {
  38300. function JSONPRequest(url, data) {
  38301. this.url = url;
  38302. this.data = data;
  38303. }
  38304. JSONPRequest.prototype.send = function (receiver) {
  38305. if (this.request) {
  38306. return;
  38307. }
  38308. var query = buildQueryString(this.data);
  38309. var url = this.url + "/" + receiver.number + "?" + query;
  38310. this.request = runtime.createScriptRequest(url);
  38311. this.request.send(receiver);
  38312. };
  38313. JSONPRequest.prototype.cleanup = function () {
  38314. if (this.request) {
  38315. this.request.cleanup();
  38316. }
  38317. };
  38318. return JSONPRequest;
  38319. }());
  38320. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38321. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38322. var getAgent = function (sender, useTLS) {
  38323. return function (data, callback) {
  38324. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38325. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38326. var request = runtime.createJSONPRequest(url, data);
  38327. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38328. ScriptReceivers.remove(receiver);
  38329. request.cleanup();
  38330. if (result && result.host) {
  38331. sender.host = result.host;
  38332. }
  38333. if (callback) {
  38334. callback(error, result);
  38335. }
  38336. });
  38337. request.send(receiver);
  38338. };
  38339. };
  38340. var jsonp_timeline_jsonp = {
  38341. name: 'jsonp',
  38342. getAgent: getAgent
  38343. };
  38344. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38345. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38346. function getGenericURL(baseScheme, params, path) {
  38347. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38348. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38349. return scheme + "://" + host + path;
  38350. }
  38351. function getGenericPath(key, queryString) {
  38352. var path = "/app/" + key;
  38353. var query = "?protocol=" + defaults.PROTOCOL +
  38354. "&client=js" +
  38355. "&version=" + defaults.VERSION +
  38356. (queryString ? ("&" + queryString) : "");
  38357. return path + query;
  38358. }
  38359. var ws = {
  38360. getInitial: function (key, params) {
  38361. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38362. return getGenericURL("ws", params, path);
  38363. }
  38364. };
  38365. var http = {
  38366. getInitial: function (key, params) {
  38367. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38368. return getGenericURL("http", params, path);
  38369. }
  38370. };
  38371. var sockjs = {
  38372. getInitial: function (key, params) {
  38373. return getGenericURL("http", params, params.httpPath || "/pusher");
  38374. },
  38375. getPath: function (key, params) {
  38376. return getGenericPath(key);
  38377. }
  38378. };
  38379. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38380. var callback_registry_CallbackRegistry = (function () {
  38381. function CallbackRegistry() {
  38382. this._callbacks = {};
  38383. }
  38384. CallbackRegistry.prototype.get = function (name) {
  38385. return this._callbacks[prefix(name)];
  38386. };
  38387. CallbackRegistry.prototype.add = function (name, callback, context) {
  38388. var prefixedEventName = prefix(name);
  38389. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38390. this._callbacks[prefixedEventName].push({
  38391. fn: callback,
  38392. context: context
  38393. });
  38394. };
  38395. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38396. if (!name && !callback && !context) {
  38397. this._callbacks = {};
  38398. return;
  38399. }
  38400. var names = name ? [prefix(name)] : keys(this._callbacks);
  38401. if (callback || context) {
  38402. this.removeCallback(names, callback, context);
  38403. }
  38404. else {
  38405. this.removeAllCallbacks(names);
  38406. }
  38407. };
  38408. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38409. apply(names, function (name) {
  38410. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38411. return (callback && callback !== binding.fn) ||
  38412. (context && context !== binding.context);
  38413. });
  38414. if (this._callbacks[name].length === 0) {
  38415. delete this._callbacks[name];
  38416. }
  38417. }, this);
  38418. };
  38419. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38420. apply(names, function (name) {
  38421. delete this._callbacks[name];
  38422. }, this);
  38423. };
  38424. return CallbackRegistry;
  38425. }());
  38426. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38427. function prefix(name) {
  38428. return "_" + name;
  38429. }
  38430. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38431. var dispatcher_Dispatcher = (function () {
  38432. function Dispatcher(failThrough) {
  38433. this.callbacks = new callback_registry();
  38434. this.global_callbacks = [];
  38435. this.failThrough = failThrough;
  38436. }
  38437. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38438. this.callbacks.add(eventName, callback, context);
  38439. return this;
  38440. };
  38441. Dispatcher.prototype.bind_global = function (callback) {
  38442. this.global_callbacks.push(callback);
  38443. return this;
  38444. };
  38445. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38446. this.callbacks.remove(eventName, callback, context);
  38447. return this;
  38448. };
  38449. Dispatcher.prototype.unbind_global = function (callback) {
  38450. if (!callback) {
  38451. this.global_callbacks = [];
  38452. return this;
  38453. }
  38454. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38455. return this;
  38456. };
  38457. Dispatcher.prototype.unbind_all = function () {
  38458. this.unbind();
  38459. this.unbind_global();
  38460. return this;
  38461. };
  38462. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38463. for (var i = 0; i < this.global_callbacks.length; i++) {
  38464. this.global_callbacks[i](eventName, data);
  38465. }
  38466. var callbacks = this.callbacks.get(eventName);
  38467. var args = [];
  38468. if (metadata) {
  38469. args.push(data, metadata);
  38470. }
  38471. else if (data) {
  38472. args.push(data);
  38473. }
  38474. if (callbacks && callbacks.length > 0) {
  38475. for (var i = 0; i < callbacks.length; i++) {
  38476. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38477. }
  38478. }
  38479. else if (this.failThrough) {
  38480. this.failThrough(eventName, data);
  38481. }
  38482. return this;
  38483. };
  38484. return Dispatcher;
  38485. }());
  38486. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38487. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38488. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38489. var extendStatics = function (d, b) {
  38490. extendStatics = Object.setPrototypeOf ||
  38491. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38492. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38493. return extendStatics(d, b);
  38494. };
  38495. return function (d, b) {
  38496. extendStatics(d, b);
  38497. function __() { this.constructor = d; }
  38498. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38499. };
  38500. })();
  38501. var transport_connection_TransportConnection = (function (_super) {
  38502. transport_connection_extends(TransportConnection, _super);
  38503. function TransportConnection(hooks, name, priority, key, options) {
  38504. var _this = _super.call(this) || this;
  38505. _this.initialize = runtime.transportConnectionInitializer;
  38506. _this.hooks = hooks;
  38507. _this.name = name;
  38508. _this.priority = priority;
  38509. _this.key = key;
  38510. _this.options = options;
  38511. _this.state = "new";
  38512. _this.timeline = options.timeline;
  38513. _this.activityTimeout = options.activityTimeout;
  38514. _this.id = _this.timeline.generateUniqueID();
  38515. return _this;
  38516. }
  38517. TransportConnection.prototype.handlesActivityChecks = function () {
  38518. return Boolean(this.hooks.handlesActivityChecks);
  38519. };
  38520. TransportConnection.prototype.supportsPing = function () {
  38521. return Boolean(this.hooks.supportsPing);
  38522. };
  38523. TransportConnection.prototype.connect = function () {
  38524. var _this = this;
  38525. if (this.socket || this.state !== "initialized") {
  38526. return false;
  38527. }
  38528. var url = this.hooks.urls.getInitial(this.key, this.options);
  38529. try {
  38530. this.socket = this.hooks.getSocket(url, this.options);
  38531. }
  38532. catch (e) {
  38533. util.defer(function () {
  38534. _this.onError(e);
  38535. _this.changeState("closed");
  38536. });
  38537. return false;
  38538. }
  38539. this.bindListeners();
  38540. logger.debug("Connecting", { transport: this.name, url: url });
  38541. this.changeState("connecting");
  38542. return true;
  38543. };
  38544. TransportConnection.prototype.close = function () {
  38545. if (this.socket) {
  38546. this.socket.close();
  38547. return true;
  38548. }
  38549. else {
  38550. return false;
  38551. }
  38552. };
  38553. TransportConnection.prototype.send = function (data) {
  38554. var _this = this;
  38555. if (this.state === "open") {
  38556. util.defer(function () {
  38557. if (_this.socket) {
  38558. _this.socket.send(data);
  38559. }
  38560. });
  38561. return true;
  38562. }
  38563. else {
  38564. return false;
  38565. }
  38566. };
  38567. TransportConnection.prototype.ping = function () {
  38568. if (this.state === "open" && this.supportsPing()) {
  38569. this.socket.ping();
  38570. }
  38571. };
  38572. TransportConnection.prototype.onOpen = function () {
  38573. if (this.hooks.beforeOpen) {
  38574. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38575. }
  38576. this.changeState("open");
  38577. this.socket.onopen = undefined;
  38578. };
  38579. TransportConnection.prototype.onError = function (error) {
  38580. this.emit("error", { type: 'WebSocketError', error: error });
  38581. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38582. };
  38583. TransportConnection.prototype.onClose = function (closeEvent) {
  38584. if (closeEvent) {
  38585. this.changeState("closed", {
  38586. code: closeEvent.code,
  38587. reason: closeEvent.reason,
  38588. wasClean: closeEvent.wasClean
  38589. });
  38590. }
  38591. else {
  38592. this.changeState("closed");
  38593. }
  38594. this.unbindListeners();
  38595. this.socket = undefined;
  38596. };
  38597. TransportConnection.prototype.onMessage = function (message) {
  38598. this.emit("message", message);
  38599. };
  38600. TransportConnection.prototype.onActivity = function () {
  38601. this.emit("activity");
  38602. };
  38603. TransportConnection.prototype.bindListeners = function () {
  38604. var _this = this;
  38605. this.socket.onopen = function () {
  38606. _this.onOpen();
  38607. };
  38608. this.socket.onerror = function (error) {
  38609. _this.onError(error);
  38610. };
  38611. this.socket.onclose = function (closeEvent) {
  38612. _this.onClose(closeEvent);
  38613. };
  38614. this.socket.onmessage = function (message) {
  38615. _this.onMessage(message);
  38616. };
  38617. if (this.supportsPing()) {
  38618. this.socket.onactivity = function () { _this.onActivity(); };
  38619. }
  38620. };
  38621. TransportConnection.prototype.unbindListeners = function () {
  38622. if (this.socket) {
  38623. this.socket.onopen = undefined;
  38624. this.socket.onerror = undefined;
  38625. this.socket.onclose = undefined;
  38626. this.socket.onmessage = undefined;
  38627. if (this.supportsPing()) {
  38628. this.socket.onactivity = undefined;
  38629. }
  38630. }
  38631. };
  38632. TransportConnection.prototype.changeState = function (state, params) {
  38633. this.state = state;
  38634. this.timeline.info(this.buildTimelineMessage({
  38635. state: state,
  38636. params: params
  38637. }));
  38638. this.emit(state, params);
  38639. };
  38640. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38641. return extend({ cid: this.id }, message);
  38642. };
  38643. return TransportConnection;
  38644. }(dispatcher));
  38645. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38646. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38647. var transport_Transport = (function () {
  38648. function Transport(hooks) {
  38649. this.hooks = hooks;
  38650. }
  38651. Transport.prototype.isSupported = function (environment) {
  38652. return this.hooks.isSupported(environment);
  38653. };
  38654. Transport.prototype.createConnection = function (name, priority, key, options) {
  38655. return new transport_connection(this.hooks, name, priority, key, options);
  38656. };
  38657. return Transport;
  38658. }());
  38659. /* harmony default export */ var transports_transport = (transport_Transport);
  38660. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38661. var WSTransport = new transports_transport({
  38662. urls: ws,
  38663. handlesActivityChecks: false,
  38664. supportsPing: false,
  38665. isInitialized: function () {
  38666. return Boolean(runtime.getWebSocketAPI());
  38667. },
  38668. isSupported: function () {
  38669. return Boolean(runtime.getWebSocketAPI());
  38670. },
  38671. getSocket: function (url) {
  38672. return runtime.createWebSocket(url);
  38673. }
  38674. });
  38675. var httpConfiguration = {
  38676. urls: http,
  38677. handlesActivityChecks: false,
  38678. supportsPing: true,
  38679. isInitialized: function () {
  38680. return true;
  38681. }
  38682. };
  38683. var streamingConfiguration = extend({ getSocket: function (url) {
  38684. return runtime.HTTPFactory.createStreamingSocket(url);
  38685. }
  38686. }, httpConfiguration);
  38687. var pollingConfiguration = extend({ getSocket: function (url) {
  38688. return runtime.HTTPFactory.createPollingSocket(url);
  38689. }
  38690. }, httpConfiguration);
  38691. var xhrConfiguration = {
  38692. isSupported: function () {
  38693. return runtime.isXHRSupported();
  38694. }
  38695. };
  38696. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38697. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38698. var Transports = {
  38699. ws: WSTransport,
  38700. xhr_streaming: XHRStreamingTransport,
  38701. xhr_polling: XHRPollingTransport
  38702. };
  38703. /* harmony default export */ var transports = (Transports);
  38704. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38705. var SockJSTransport = new transports_transport({
  38706. file: "sockjs",
  38707. urls: sockjs,
  38708. handlesActivityChecks: true,
  38709. supportsPing: false,
  38710. isSupported: function () {
  38711. return true;
  38712. },
  38713. isInitialized: function () {
  38714. return window.SockJS !== undefined;
  38715. },
  38716. getSocket: function (url, options) {
  38717. return new window.SockJS(url, null, {
  38718. js_path: Dependencies.getPath("sockjs", {
  38719. useTLS: options.useTLS
  38720. }),
  38721. ignore_null_origin: options.ignoreNullOrigin
  38722. });
  38723. },
  38724. beforeOpen: function (socket, path) {
  38725. socket.send(JSON.stringify({
  38726. path: path
  38727. }));
  38728. }
  38729. });
  38730. var xdrConfiguration = {
  38731. isSupported: function (environment) {
  38732. var yes = runtime.isXDRSupported(environment.useTLS);
  38733. return yes;
  38734. }
  38735. };
  38736. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38737. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38738. transports.xdr_streaming = XDRStreamingTransport;
  38739. transports.xdr_polling = XDRPollingTransport;
  38740. transports.sockjs = SockJSTransport;
  38741. /* harmony default export */ var transports_transports = (transports);
  38742. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38743. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38744. var extendStatics = function (d, b) {
  38745. extendStatics = Object.setPrototypeOf ||
  38746. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38747. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38748. return extendStatics(d, b);
  38749. };
  38750. return function (d, b) {
  38751. extendStatics(d, b);
  38752. function __() { this.constructor = d; }
  38753. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38754. };
  38755. })();
  38756. var NetInfo = (function (_super) {
  38757. net_info_extends(NetInfo, _super);
  38758. function NetInfo() {
  38759. var _this = _super.call(this) || this;
  38760. var self = _this;
  38761. if (window.addEventListener !== undefined) {
  38762. window.addEventListener("online", function () {
  38763. self.emit('online');
  38764. }, false);
  38765. window.addEventListener("offline", function () {
  38766. self.emit('offline');
  38767. }, false);
  38768. }
  38769. return _this;
  38770. }
  38771. NetInfo.prototype.isOnline = function () {
  38772. if (window.navigator.onLine === undefined) {
  38773. return true;
  38774. }
  38775. else {
  38776. return window.navigator.onLine;
  38777. }
  38778. };
  38779. return NetInfo;
  38780. }(dispatcher));
  38781. var net_info_Network = new NetInfo();
  38782. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38783. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38784. function AssistantToTheTransportManager(manager, transport, options) {
  38785. this.manager = manager;
  38786. this.transport = transport;
  38787. this.minPingDelay = options.minPingDelay;
  38788. this.maxPingDelay = options.maxPingDelay;
  38789. this.pingDelay = undefined;
  38790. }
  38791. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38792. var _this = this;
  38793. options = extend({}, options, {
  38794. activityTimeout: this.pingDelay
  38795. });
  38796. var connection = this.transport.createConnection(name, priority, key, options);
  38797. var openTimestamp = null;
  38798. var onOpen = function () {
  38799. connection.unbind("open", onOpen);
  38800. connection.bind("closed", onClosed);
  38801. openTimestamp = util.now();
  38802. };
  38803. var onClosed = function (closeEvent) {
  38804. connection.unbind("closed", onClosed);
  38805. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38806. _this.manager.reportDeath();
  38807. }
  38808. else if (!closeEvent.wasClean && openTimestamp) {
  38809. var lifespan = util.now() - openTimestamp;
  38810. if (lifespan < 2 * _this.maxPingDelay) {
  38811. _this.manager.reportDeath();
  38812. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38813. }
  38814. }
  38815. };
  38816. connection.bind("open", onOpen);
  38817. return connection;
  38818. };
  38819. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38820. return this.manager.isAlive() && this.transport.isSupported(environment);
  38821. };
  38822. return AssistantToTheTransportManager;
  38823. }());
  38824. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38825. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38826. var Protocol = {
  38827. decodeMessage: function (messageEvent) {
  38828. try {
  38829. var messageData = JSON.parse(messageEvent.data);
  38830. var pusherEventData = messageData.data;
  38831. if (typeof pusherEventData === 'string') {
  38832. try {
  38833. pusherEventData = JSON.parse(messageData.data);
  38834. }
  38835. catch (e) { }
  38836. }
  38837. var pusherEvent = {
  38838. event: messageData.event,
  38839. channel: messageData.channel,
  38840. data: pusherEventData,
  38841. };
  38842. if (messageData.user_id) {
  38843. pusherEvent.user_id = messageData.user_id;
  38844. }
  38845. return pusherEvent;
  38846. }
  38847. catch (e) {
  38848. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38849. }
  38850. },
  38851. encodeMessage: function (event) {
  38852. return JSON.stringify(event);
  38853. },
  38854. processHandshake: function (messageEvent) {
  38855. var message = Protocol.decodeMessage(messageEvent);
  38856. if (message.event === "pusher:connection_established") {
  38857. if (!message.data.activity_timeout) {
  38858. throw "No activity timeout specified in handshake";
  38859. }
  38860. return {
  38861. action: "connected",
  38862. id: message.data.socket_id,
  38863. activityTimeout: message.data.activity_timeout * 1000
  38864. };
  38865. }
  38866. else if (message.event === "pusher:error") {
  38867. return {
  38868. action: this.getCloseAction(message.data),
  38869. error: this.getCloseError(message.data)
  38870. };
  38871. }
  38872. else {
  38873. throw "Invalid handshake";
  38874. }
  38875. },
  38876. getCloseAction: function (closeEvent) {
  38877. if (closeEvent.code < 4000) {
  38878. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38879. return "backoff";
  38880. }
  38881. else {
  38882. return null;
  38883. }
  38884. }
  38885. else if (closeEvent.code === 4000) {
  38886. return "tls_only";
  38887. }
  38888. else if (closeEvent.code < 4100) {
  38889. return "refused";
  38890. }
  38891. else if (closeEvent.code < 4200) {
  38892. return "backoff";
  38893. }
  38894. else if (closeEvent.code < 4300) {
  38895. return "retry";
  38896. }
  38897. else {
  38898. return "refused";
  38899. }
  38900. },
  38901. getCloseError: function (closeEvent) {
  38902. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38903. return {
  38904. type: 'PusherError',
  38905. data: {
  38906. code: closeEvent.code,
  38907. message: closeEvent.reason || closeEvent.message
  38908. }
  38909. };
  38910. }
  38911. else {
  38912. return null;
  38913. }
  38914. }
  38915. };
  38916. /* harmony default export */ var protocol_protocol = (Protocol);
  38917. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38918. var connection_extends = (undefined && undefined.__extends) || (function () {
  38919. var extendStatics = function (d, b) {
  38920. extendStatics = Object.setPrototypeOf ||
  38921. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38922. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38923. return extendStatics(d, b);
  38924. };
  38925. return function (d, b) {
  38926. extendStatics(d, b);
  38927. function __() { this.constructor = d; }
  38928. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38929. };
  38930. })();
  38931. var connection_Connection = (function (_super) {
  38932. connection_extends(Connection, _super);
  38933. function Connection(id, transport) {
  38934. var _this = _super.call(this) || this;
  38935. _this.id = id;
  38936. _this.transport = transport;
  38937. _this.activityTimeout = transport.activityTimeout;
  38938. _this.bindListeners();
  38939. return _this;
  38940. }
  38941. Connection.prototype.handlesActivityChecks = function () {
  38942. return this.transport.handlesActivityChecks();
  38943. };
  38944. Connection.prototype.send = function (data) {
  38945. return this.transport.send(data);
  38946. };
  38947. Connection.prototype.send_event = function (name, data, channel) {
  38948. var event = { event: name, data: data };
  38949. if (channel) {
  38950. event.channel = channel;
  38951. }
  38952. logger.debug('Event sent', event);
  38953. return this.send(protocol_protocol.encodeMessage(event));
  38954. };
  38955. Connection.prototype.ping = function () {
  38956. if (this.transport.supportsPing()) {
  38957. this.transport.ping();
  38958. }
  38959. else {
  38960. this.send_event('pusher:ping', {});
  38961. }
  38962. };
  38963. Connection.prototype.close = function () {
  38964. this.transport.close();
  38965. };
  38966. Connection.prototype.bindListeners = function () {
  38967. var _this = this;
  38968. var listeners = {
  38969. message: function (messageEvent) {
  38970. var pusherEvent;
  38971. try {
  38972. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  38973. }
  38974. catch (e) {
  38975. _this.emit('error', {
  38976. type: 'MessageParseError',
  38977. error: e,
  38978. data: messageEvent.data
  38979. });
  38980. }
  38981. if (pusherEvent !== undefined) {
  38982. logger.debug('Event recd', pusherEvent);
  38983. switch (pusherEvent.event) {
  38984. case 'pusher:error':
  38985. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  38986. break;
  38987. case 'pusher:ping':
  38988. _this.emit("ping");
  38989. break;
  38990. case 'pusher:pong':
  38991. _this.emit("pong");
  38992. break;
  38993. }
  38994. _this.emit('message', pusherEvent);
  38995. }
  38996. },
  38997. activity: function () {
  38998. _this.emit("activity");
  38999. },
  39000. error: function (error) {
  39001. _this.emit("error", { type: "WebSocketError", error: error });
  39002. },
  39003. closed: function (closeEvent) {
  39004. unbindListeners();
  39005. if (closeEvent && closeEvent.code) {
  39006. _this.handleCloseEvent(closeEvent);
  39007. }
  39008. _this.transport = null;
  39009. _this.emit("closed");
  39010. }
  39011. };
  39012. var unbindListeners = function () {
  39013. objectApply(listeners, function (listener, event) {
  39014. _this.transport.unbind(event, listener);
  39015. });
  39016. };
  39017. objectApply(listeners, function (listener, event) {
  39018. _this.transport.bind(event, listener);
  39019. });
  39020. };
  39021. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39022. var action = protocol_protocol.getCloseAction(closeEvent);
  39023. var error = protocol_protocol.getCloseError(closeEvent);
  39024. if (error) {
  39025. this.emit('error', error);
  39026. }
  39027. if (action) {
  39028. this.emit(action, { action: action, error: error });
  39029. }
  39030. };
  39031. return Connection;
  39032. }(dispatcher));
  39033. /* harmony default export */ var connection_connection = (connection_Connection);
  39034. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39035. var handshake_Handshake = (function () {
  39036. function Handshake(transport, callback) {
  39037. this.transport = transport;
  39038. this.callback = callback;
  39039. this.bindListeners();
  39040. }
  39041. Handshake.prototype.close = function () {
  39042. this.unbindListeners();
  39043. this.transport.close();
  39044. };
  39045. Handshake.prototype.bindListeners = function () {
  39046. var _this = this;
  39047. this.onMessage = function (m) {
  39048. _this.unbindListeners();
  39049. var result;
  39050. try {
  39051. result = protocol_protocol.processHandshake(m);
  39052. }
  39053. catch (e) {
  39054. _this.finish("error", { error: e });
  39055. _this.transport.close();
  39056. return;
  39057. }
  39058. if (result.action === "connected") {
  39059. _this.finish("connected", {
  39060. connection: new connection_connection(result.id, _this.transport),
  39061. activityTimeout: result.activityTimeout
  39062. });
  39063. }
  39064. else {
  39065. _this.finish(result.action, { error: result.error });
  39066. _this.transport.close();
  39067. }
  39068. };
  39069. this.onClosed = function (closeEvent) {
  39070. _this.unbindListeners();
  39071. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39072. var error = protocol_protocol.getCloseError(closeEvent);
  39073. _this.finish(action, { error: error });
  39074. };
  39075. this.transport.bind("message", this.onMessage);
  39076. this.transport.bind("closed", this.onClosed);
  39077. };
  39078. Handshake.prototype.unbindListeners = function () {
  39079. this.transport.unbind("message", this.onMessage);
  39080. this.transport.unbind("closed", this.onClosed);
  39081. };
  39082. Handshake.prototype.finish = function (action, params) {
  39083. this.callback(extend({ transport: this.transport, action: action }, params));
  39084. };
  39085. return Handshake;
  39086. }());
  39087. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39088. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39089. var pusher_authorizer_PusherAuthorizer = (function () {
  39090. function PusherAuthorizer(channel, options) {
  39091. this.channel = channel;
  39092. var authTransport = options.authTransport;
  39093. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39094. throw "'" + authTransport + "' is not a recognized auth transport";
  39095. }
  39096. this.type = authTransport;
  39097. this.options = options;
  39098. this.authOptions = (options || {}).auth || {};
  39099. }
  39100. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39101. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39102. '&channel_name=' + encodeURIComponent(this.channel.name);
  39103. for (var i in this.authOptions.params) {
  39104. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39105. }
  39106. return query;
  39107. };
  39108. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39109. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39110. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39111. };
  39112. return PusherAuthorizer;
  39113. }());
  39114. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39115. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39116. var timeline_sender_TimelineSender = (function () {
  39117. function TimelineSender(timeline, options) {
  39118. this.timeline = timeline;
  39119. this.options = options || {};
  39120. }
  39121. TimelineSender.prototype.send = function (useTLS, callback) {
  39122. if (this.timeline.isEmpty()) {
  39123. return;
  39124. }
  39125. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39126. };
  39127. return TimelineSender;
  39128. }());
  39129. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39130. // CONCATENATED MODULE: ./src/core/errors.ts
  39131. var errors_extends = (undefined && undefined.__extends) || (function () {
  39132. var extendStatics = function (d, b) {
  39133. extendStatics = Object.setPrototypeOf ||
  39134. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39135. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39136. return extendStatics(d, b);
  39137. };
  39138. return function (d, b) {
  39139. extendStatics(d, b);
  39140. function __() { this.constructor = d; }
  39141. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39142. };
  39143. })();
  39144. var BadEventName = (function (_super) {
  39145. errors_extends(BadEventName, _super);
  39146. function BadEventName(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 BadEventName;
  39153. }(Error));
  39154. var RequestTimedOut = (function (_super) {
  39155. errors_extends(RequestTimedOut, _super);
  39156. function RequestTimedOut(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 RequestTimedOut;
  39163. }(Error));
  39164. var TransportPriorityTooLow = (function (_super) {
  39165. errors_extends(TransportPriorityTooLow, _super);
  39166. function TransportPriorityTooLow(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 TransportPriorityTooLow;
  39173. }(Error));
  39174. var TransportClosed = (function (_super) {
  39175. errors_extends(TransportClosed, _super);
  39176. function TransportClosed(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 TransportClosed;
  39183. }(Error));
  39184. var UnsupportedFeature = (function (_super) {
  39185. errors_extends(UnsupportedFeature, _super);
  39186. function UnsupportedFeature(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 UnsupportedFeature;
  39193. }(Error));
  39194. var UnsupportedTransport = (function (_super) {
  39195. errors_extends(UnsupportedTransport, _super);
  39196. function UnsupportedTransport(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 UnsupportedTransport;
  39203. }(Error));
  39204. var UnsupportedStrategy = (function (_super) {
  39205. errors_extends(UnsupportedStrategy, _super);
  39206. function UnsupportedStrategy(msg) {
  39207. var _newTarget = this.constructor;
  39208. var _this = _super.call(this, msg) || this;
  39209. Object.setPrototypeOf(_this, _newTarget.prototype);
  39210. return _this;
  39211. }
  39212. return UnsupportedStrategy;
  39213. }(Error));
  39214. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39215. var channel_extends = (undefined && undefined.__extends) || (function () {
  39216. var extendStatics = function (d, b) {
  39217. extendStatics = Object.setPrototypeOf ||
  39218. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39219. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39220. return extendStatics(d, b);
  39221. };
  39222. return function (d, b) {
  39223. extendStatics(d, b);
  39224. function __() { this.constructor = d; }
  39225. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39226. };
  39227. })();
  39228. var channel_Channel = (function (_super) {
  39229. channel_extends(Channel, _super);
  39230. function Channel(name, pusher) {
  39231. var _this = _super.call(this, function (event, data) {
  39232. logger.debug('No callbacks on ' + name + ' for ' + event);
  39233. }) || this;
  39234. _this.name = name;
  39235. _this.pusher = pusher;
  39236. _this.subscribed = false;
  39237. _this.subscriptionPending = false;
  39238. _this.subscriptionCancelled = false;
  39239. return _this;
  39240. }
  39241. Channel.prototype.authorize = function (socketId, callback) {
  39242. return callback(false, {});
  39243. };
  39244. Channel.prototype.trigger = function (event, data) {
  39245. if (event.indexOf("client-") !== 0) {
  39246. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39247. }
  39248. if (!this.subscribed) {
  39249. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39250. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39251. }
  39252. return this.pusher.send_event(event, data, this.name);
  39253. };
  39254. Channel.prototype.disconnect = function () {
  39255. this.subscribed = false;
  39256. this.subscriptionPending = false;
  39257. };
  39258. Channel.prototype.handleEvent = function (event) {
  39259. var eventName = event.event;
  39260. var data = event.data;
  39261. if (eventName === "pusher_internal:subscription_succeeded") {
  39262. this.handleSubscriptionSucceededEvent(event);
  39263. }
  39264. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39265. var metadata = {};
  39266. this.emit(eventName, data, metadata);
  39267. }
  39268. };
  39269. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39270. this.subscriptionPending = false;
  39271. this.subscribed = true;
  39272. if (this.subscriptionCancelled) {
  39273. this.pusher.unsubscribe(this.name);
  39274. }
  39275. else {
  39276. this.emit("pusher:subscription_succeeded", event.data);
  39277. }
  39278. };
  39279. Channel.prototype.subscribe = function () {
  39280. var _this = this;
  39281. if (this.subscribed) {
  39282. return;
  39283. }
  39284. this.subscriptionPending = true;
  39285. this.subscriptionCancelled = false;
  39286. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39287. if (error) {
  39288. logger.error(data);
  39289. _this.emit('pusher:subscription_error', data);
  39290. }
  39291. else {
  39292. _this.pusher.send_event('pusher:subscribe', {
  39293. auth: data.auth,
  39294. channel_data: data.channel_data,
  39295. channel: _this.name
  39296. });
  39297. }
  39298. });
  39299. };
  39300. Channel.prototype.unsubscribe = function () {
  39301. this.subscribed = false;
  39302. this.pusher.send_event('pusher:unsubscribe', {
  39303. channel: this.name
  39304. });
  39305. };
  39306. Channel.prototype.cancelSubscription = function () {
  39307. this.subscriptionCancelled = true;
  39308. };
  39309. Channel.prototype.reinstateSubscription = function () {
  39310. this.subscriptionCancelled = false;
  39311. };
  39312. return Channel;
  39313. }(dispatcher));
  39314. /* harmony default export */ var channels_channel = (channel_Channel);
  39315. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39316. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39317. var extendStatics = function (d, b) {
  39318. extendStatics = Object.setPrototypeOf ||
  39319. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39320. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39321. return extendStatics(d, b);
  39322. };
  39323. return function (d, b) {
  39324. extendStatics(d, b);
  39325. function __() { this.constructor = d; }
  39326. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39327. };
  39328. })();
  39329. var private_channel_PrivateChannel = (function (_super) {
  39330. private_channel_extends(PrivateChannel, _super);
  39331. function PrivateChannel() {
  39332. return _super !== null && _super.apply(this, arguments) || this;
  39333. }
  39334. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39335. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39336. return authorizer.authorize(socketId, callback);
  39337. };
  39338. return PrivateChannel;
  39339. }(channels_channel));
  39340. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39341. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39342. var members_Members = (function () {
  39343. function Members() {
  39344. this.reset();
  39345. }
  39346. Members.prototype.get = function (id) {
  39347. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39348. return {
  39349. id: id,
  39350. info: this.members[id]
  39351. };
  39352. }
  39353. else {
  39354. return null;
  39355. }
  39356. };
  39357. Members.prototype.each = function (callback) {
  39358. var _this = this;
  39359. objectApply(this.members, function (member, id) {
  39360. callback(_this.get(id));
  39361. });
  39362. };
  39363. Members.prototype.setMyID = function (id) {
  39364. this.myID = id;
  39365. };
  39366. Members.prototype.onSubscription = function (subscriptionData) {
  39367. this.members = subscriptionData.presence.hash;
  39368. this.count = subscriptionData.presence.count;
  39369. this.me = this.get(this.myID);
  39370. };
  39371. Members.prototype.addMember = function (memberData) {
  39372. if (this.get(memberData.user_id) === null) {
  39373. this.count++;
  39374. }
  39375. this.members[memberData.user_id] = memberData.user_info;
  39376. return this.get(memberData.user_id);
  39377. };
  39378. Members.prototype.removeMember = function (memberData) {
  39379. var member = this.get(memberData.user_id);
  39380. if (member) {
  39381. delete this.members[memberData.user_id];
  39382. this.count--;
  39383. }
  39384. return member;
  39385. };
  39386. Members.prototype.reset = function () {
  39387. this.members = {};
  39388. this.count = 0;
  39389. this.myID = null;
  39390. this.me = null;
  39391. };
  39392. return Members;
  39393. }());
  39394. /* harmony default export */ var members = (members_Members);
  39395. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39396. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39397. var extendStatics = function (d, b) {
  39398. extendStatics = Object.setPrototypeOf ||
  39399. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39400. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39401. return extendStatics(d, b);
  39402. };
  39403. return function (d, b) {
  39404. extendStatics(d, b);
  39405. function __() { this.constructor = d; }
  39406. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39407. };
  39408. })();
  39409. var presence_channel_PresenceChannel = (function (_super) {
  39410. presence_channel_extends(PresenceChannel, _super);
  39411. function PresenceChannel(name, pusher) {
  39412. var _this = _super.call(this, name, pusher) || this;
  39413. _this.members = new members();
  39414. return _this;
  39415. }
  39416. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39417. var _this = this;
  39418. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39419. if (!error) {
  39420. if (authData.channel_data === undefined) {
  39421. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39422. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39423. ("expected 'channel_data' field. " + suffix));
  39424. callback("Invalid auth response");
  39425. return;
  39426. }
  39427. var channelData = JSON.parse(authData.channel_data);
  39428. _this.members.setMyID(channelData.user_id);
  39429. }
  39430. callback(error, authData);
  39431. });
  39432. };
  39433. PresenceChannel.prototype.handleEvent = function (event) {
  39434. var eventName = event.event;
  39435. if (eventName.indexOf("pusher_internal:") === 0) {
  39436. this.handleInternalEvent(event);
  39437. }
  39438. else {
  39439. var data = event.data;
  39440. var metadata = {};
  39441. if (event.user_id) {
  39442. metadata.user_id = event.user_id;
  39443. }
  39444. this.emit(eventName, data, metadata);
  39445. }
  39446. };
  39447. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39448. var eventName = event.event;
  39449. var data = event.data;
  39450. switch (eventName) {
  39451. case "pusher_internal:subscription_succeeded":
  39452. this.handleSubscriptionSucceededEvent(event);
  39453. break;
  39454. case "pusher_internal:member_added":
  39455. var addedMember = this.members.addMember(data);
  39456. this.emit('pusher:member_added', addedMember);
  39457. break;
  39458. case "pusher_internal:member_removed":
  39459. var removedMember = this.members.removeMember(data);
  39460. if (removedMember) {
  39461. this.emit('pusher:member_removed', removedMember);
  39462. }
  39463. break;
  39464. }
  39465. };
  39466. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39467. this.subscriptionPending = false;
  39468. this.subscribed = true;
  39469. if (this.subscriptionCancelled) {
  39470. this.pusher.unsubscribe(this.name);
  39471. }
  39472. else {
  39473. this.members.onSubscription(event.data);
  39474. this.emit("pusher:subscription_succeeded", this.members);
  39475. }
  39476. };
  39477. PresenceChannel.prototype.disconnect = function () {
  39478. this.members.reset();
  39479. _super.prototype.disconnect.call(this);
  39480. };
  39481. return PresenceChannel;
  39482. }(private_channel));
  39483. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39484. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39485. var nacl_fast = __webpack_require__(0);
  39486. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39487. var nacl_util = __webpack_require__(1);
  39488. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39489. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39490. var extendStatics = function (d, b) {
  39491. extendStatics = Object.setPrototypeOf ||
  39492. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39493. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39494. return extendStatics(d, b);
  39495. };
  39496. return function (d, b) {
  39497. extendStatics(d, b);
  39498. function __() { this.constructor = d; }
  39499. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39500. };
  39501. })();
  39502. var encrypted_channel_EncryptedChannel = (function (_super) {
  39503. encrypted_channel_extends(EncryptedChannel, _super);
  39504. function EncryptedChannel() {
  39505. var _this = _super !== null && _super.apply(this, arguments) || this;
  39506. _this.key = null;
  39507. return _this;
  39508. }
  39509. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39510. var _this = this;
  39511. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39512. if (error) {
  39513. callback(true, authData);
  39514. return;
  39515. }
  39516. var sharedSecret = authData["shared_secret"];
  39517. if (!sharedSecret) {
  39518. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39519. callback(true, errorMsg);
  39520. return;
  39521. }
  39522. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39523. delete authData["shared_secret"];
  39524. callback(false, authData);
  39525. });
  39526. };
  39527. EncryptedChannel.prototype.trigger = function (event, data) {
  39528. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39529. };
  39530. EncryptedChannel.prototype.handleEvent = function (event) {
  39531. var eventName = event.event;
  39532. var data = event.data;
  39533. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39534. _super.prototype.handleEvent.call(this, event);
  39535. return;
  39536. }
  39537. this.handleEncryptedEvent(eventName, data);
  39538. };
  39539. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39540. var _this = this;
  39541. if (!this.key) {
  39542. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39543. return;
  39544. }
  39545. if (!data.ciphertext || !data.nonce) {
  39546. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39547. return;
  39548. }
  39549. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39550. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39551. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39552. return;
  39553. }
  39554. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39555. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39556. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39557. return;
  39558. }
  39559. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39560. if (bytes === null) {
  39561. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39562. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39563. if (error) {
  39564. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39565. return;
  39566. }
  39567. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39568. if (bytes === null) {
  39569. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39570. return;
  39571. }
  39572. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39573. return;
  39574. });
  39575. return;
  39576. }
  39577. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39578. };
  39579. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39580. try {
  39581. this.emit(eventName, JSON.parse(data));
  39582. }
  39583. catch (e) {
  39584. this.emit(eventName, data);
  39585. }
  39586. return this;
  39587. };
  39588. return EncryptedChannel;
  39589. }(private_channel));
  39590. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39591. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39592. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39593. var extendStatics = function (d, b) {
  39594. extendStatics = Object.setPrototypeOf ||
  39595. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39596. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39597. return extendStatics(d, b);
  39598. };
  39599. return function (d, b) {
  39600. extendStatics(d, b);
  39601. function __() { this.constructor = d; }
  39602. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39603. };
  39604. })();
  39605. var connection_manager_ConnectionManager = (function (_super) {
  39606. connection_manager_extends(ConnectionManager, _super);
  39607. function ConnectionManager(key, options) {
  39608. var _this = _super.call(this) || this;
  39609. _this.key = key;
  39610. _this.options = options || {};
  39611. _this.state = "initialized";
  39612. _this.connection = null;
  39613. _this.usingTLS = !!options.useTLS;
  39614. _this.timeline = _this.options.timeline;
  39615. _this.errorCallbacks = _this.buildErrorCallbacks();
  39616. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39617. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39618. var Network = runtime.getNetwork();
  39619. Network.bind("online", function () {
  39620. _this.timeline.info({ netinfo: "online" });
  39621. if (_this.state === "connecting" || _this.state === "unavailable") {
  39622. _this.retryIn(0);
  39623. }
  39624. });
  39625. Network.bind("offline", function () {
  39626. _this.timeline.info({ netinfo: "offline" });
  39627. if (_this.connection) {
  39628. _this.sendActivityCheck();
  39629. }
  39630. });
  39631. _this.updateStrategy();
  39632. return _this;
  39633. }
  39634. ConnectionManager.prototype.connect = function () {
  39635. if (this.connection || this.runner) {
  39636. return;
  39637. }
  39638. if (!this.strategy.isSupported()) {
  39639. this.updateState("failed");
  39640. return;
  39641. }
  39642. this.updateState("connecting");
  39643. this.startConnecting();
  39644. this.setUnavailableTimer();
  39645. };
  39646. ;
  39647. ConnectionManager.prototype.send = function (data) {
  39648. if (this.connection) {
  39649. return this.connection.send(data);
  39650. }
  39651. else {
  39652. return false;
  39653. }
  39654. };
  39655. ;
  39656. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39657. if (this.connection) {
  39658. return this.connection.send_event(name, data, channel);
  39659. }
  39660. else {
  39661. return false;
  39662. }
  39663. };
  39664. ;
  39665. ConnectionManager.prototype.disconnect = function () {
  39666. this.disconnectInternally();
  39667. this.updateState("disconnected");
  39668. };
  39669. ;
  39670. ConnectionManager.prototype.isUsingTLS = function () {
  39671. return this.usingTLS;
  39672. };
  39673. ;
  39674. ConnectionManager.prototype.startConnecting = function () {
  39675. var _this = this;
  39676. var callback = function (error, handshake) {
  39677. if (error) {
  39678. _this.runner = _this.strategy.connect(0, callback);
  39679. }
  39680. else {
  39681. if (handshake.action === "error") {
  39682. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39683. _this.timeline.error({ handshakeError: handshake.error });
  39684. }
  39685. else {
  39686. _this.abortConnecting();
  39687. _this.handshakeCallbacks[handshake.action](handshake);
  39688. }
  39689. }
  39690. };
  39691. this.runner = this.strategy.connect(0, callback);
  39692. };
  39693. ;
  39694. ConnectionManager.prototype.abortConnecting = function () {
  39695. if (this.runner) {
  39696. this.runner.abort();
  39697. this.runner = null;
  39698. }
  39699. };
  39700. ;
  39701. ConnectionManager.prototype.disconnectInternally = function () {
  39702. this.abortConnecting();
  39703. this.clearRetryTimer();
  39704. this.clearUnavailableTimer();
  39705. if (this.connection) {
  39706. var connection = this.abandonConnection();
  39707. connection.close();
  39708. }
  39709. };
  39710. ;
  39711. ConnectionManager.prototype.updateStrategy = function () {
  39712. this.strategy = this.options.getStrategy({
  39713. key: this.key,
  39714. timeline: this.timeline,
  39715. useTLS: this.usingTLS
  39716. });
  39717. };
  39718. ;
  39719. ConnectionManager.prototype.retryIn = function (delay) {
  39720. var _this = this;
  39721. this.timeline.info({ action: "retry", delay: delay });
  39722. if (delay > 0) {
  39723. this.emit("connecting_in", Math.round(delay / 1000));
  39724. }
  39725. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39726. _this.disconnectInternally();
  39727. _this.connect();
  39728. });
  39729. };
  39730. ;
  39731. ConnectionManager.prototype.clearRetryTimer = function () {
  39732. if (this.retryTimer) {
  39733. this.retryTimer.ensureAborted();
  39734. this.retryTimer = null;
  39735. }
  39736. };
  39737. ;
  39738. ConnectionManager.prototype.setUnavailableTimer = function () {
  39739. var _this = this;
  39740. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39741. _this.updateState("unavailable");
  39742. });
  39743. };
  39744. ;
  39745. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39746. if (this.unavailableTimer) {
  39747. this.unavailableTimer.ensureAborted();
  39748. }
  39749. };
  39750. ;
  39751. ConnectionManager.prototype.sendActivityCheck = function () {
  39752. var _this = this;
  39753. this.stopActivityCheck();
  39754. this.connection.ping();
  39755. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39756. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39757. _this.retryIn(0);
  39758. });
  39759. };
  39760. ;
  39761. ConnectionManager.prototype.resetActivityCheck = function () {
  39762. var _this = this;
  39763. this.stopActivityCheck();
  39764. if (this.connection && !this.connection.handlesActivityChecks()) {
  39765. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39766. _this.sendActivityCheck();
  39767. });
  39768. }
  39769. };
  39770. ;
  39771. ConnectionManager.prototype.stopActivityCheck = function () {
  39772. if (this.activityTimer) {
  39773. this.activityTimer.ensureAborted();
  39774. }
  39775. };
  39776. ;
  39777. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39778. var _this = this;
  39779. return extend({}, errorCallbacks, {
  39780. message: function (message) {
  39781. _this.resetActivityCheck();
  39782. _this.emit('message', message);
  39783. },
  39784. ping: function () {
  39785. _this.send_event('pusher:pong', {});
  39786. },
  39787. activity: function () {
  39788. _this.resetActivityCheck();
  39789. },
  39790. error: function (error) {
  39791. _this.emit("error", { type: "WebSocketError", error: error });
  39792. },
  39793. closed: function () {
  39794. _this.abandonConnection();
  39795. if (_this.shouldRetry()) {
  39796. _this.retryIn(1000);
  39797. }
  39798. }
  39799. });
  39800. };
  39801. ;
  39802. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39803. var _this = this;
  39804. return extend({}, errorCallbacks, {
  39805. connected: function (handshake) {
  39806. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39807. _this.clearUnavailableTimer();
  39808. _this.setConnection(handshake.connection);
  39809. _this.socket_id = _this.connection.id;
  39810. _this.updateState("connected", { socket_id: _this.socket_id });
  39811. }
  39812. });
  39813. };
  39814. ;
  39815. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39816. var _this = this;
  39817. var withErrorEmitted = function (callback) {
  39818. return function (result) {
  39819. if (result.error) {
  39820. _this.emit("error", { type: "WebSocketError", error: result.error });
  39821. }
  39822. callback(result);
  39823. };
  39824. };
  39825. return {
  39826. tls_only: withErrorEmitted(function () {
  39827. _this.usingTLS = true;
  39828. _this.updateStrategy();
  39829. _this.retryIn(0);
  39830. }),
  39831. refused: withErrorEmitted(function () {
  39832. _this.disconnect();
  39833. }),
  39834. backoff: withErrorEmitted(function () {
  39835. _this.retryIn(1000);
  39836. }),
  39837. retry: withErrorEmitted(function () {
  39838. _this.retryIn(0);
  39839. })
  39840. };
  39841. };
  39842. ;
  39843. ConnectionManager.prototype.setConnection = function (connection) {
  39844. this.connection = connection;
  39845. for (var event in this.connectionCallbacks) {
  39846. this.connection.bind(event, this.connectionCallbacks[event]);
  39847. }
  39848. this.resetActivityCheck();
  39849. };
  39850. ;
  39851. ConnectionManager.prototype.abandonConnection = function () {
  39852. if (!this.connection) {
  39853. return;
  39854. }
  39855. this.stopActivityCheck();
  39856. for (var event in this.connectionCallbacks) {
  39857. this.connection.unbind(event, this.connectionCallbacks[event]);
  39858. }
  39859. var connection = this.connection;
  39860. this.connection = null;
  39861. return connection;
  39862. };
  39863. ConnectionManager.prototype.updateState = function (newState, data) {
  39864. var previousState = this.state;
  39865. this.state = newState;
  39866. if (previousState !== newState) {
  39867. var newStateDescription = newState;
  39868. if (newStateDescription === "connected") {
  39869. newStateDescription += " with new socket ID " + data.socket_id;
  39870. }
  39871. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39872. this.timeline.info({ state: newState, params: data });
  39873. this.emit('state_change', { previous: previousState, current: newState });
  39874. this.emit(newState, data);
  39875. }
  39876. };
  39877. ConnectionManager.prototype.shouldRetry = function () {
  39878. return this.state === "connecting" || this.state === "connected";
  39879. };
  39880. return ConnectionManager;
  39881. }(dispatcher));
  39882. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39883. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39884. var channels_Channels = (function () {
  39885. function Channels() {
  39886. this.channels = {};
  39887. }
  39888. Channels.prototype.add = function (name, pusher) {
  39889. if (!this.channels[name]) {
  39890. this.channels[name] = createChannel(name, pusher);
  39891. }
  39892. return this.channels[name];
  39893. };
  39894. Channels.prototype.all = function () {
  39895. return values(this.channels);
  39896. };
  39897. Channels.prototype.find = function (name) {
  39898. return this.channels[name];
  39899. };
  39900. Channels.prototype.remove = function (name) {
  39901. var channel = this.channels[name];
  39902. delete this.channels[name];
  39903. return channel;
  39904. };
  39905. Channels.prototype.disconnect = function () {
  39906. objectApply(this.channels, function (channel) {
  39907. channel.disconnect();
  39908. });
  39909. };
  39910. return Channels;
  39911. }());
  39912. /* harmony default export */ var channels = (channels_Channels);
  39913. function createChannel(name, pusher) {
  39914. if (name.indexOf('private-encrypted-') === 0) {
  39915. if (false) { var errorMsg; }
  39916. return factory.createEncryptedChannel(name, pusher);
  39917. }
  39918. else if (name.indexOf('private-') === 0) {
  39919. return factory.createPrivateChannel(name, pusher);
  39920. }
  39921. else if (name.indexOf('presence-') === 0) {
  39922. return factory.createPresenceChannel(name, pusher);
  39923. }
  39924. else {
  39925. return factory.createChannel(name, pusher);
  39926. }
  39927. }
  39928. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39929. var Factory = {
  39930. createChannels: function () {
  39931. return new channels();
  39932. },
  39933. createConnectionManager: function (key, options) {
  39934. return new connection_manager(key, options);
  39935. },
  39936. createChannel: function (name, pusher) {
  39937. return new channels_channel(name, pusher);
  39938. },
  39939. createPrivateChannel: function (name, pusher) {
  39940. return new private_channel(name, pusher);
  39941. },
  39942. createPresenceChannel: function (name, pusher) {
  39943. return new presence_channel(name, pusher);
  39944. },
  39945. createEncryptedChannel: function (name, pusher) {
  39946. return new encrypted_channel(name, pusher);
  39947. },
  39948. createTimelineSender: function (timeline, options) {
  39949. return new timeline_sender(timeline, options);
  39950. },
  39951. createAuthorizer: function (channel, options) {
  39952. if (options.authorizer) {
  39953. return options.authorizer(channel, options);
  39954. }
  39955. return new pusher_authorizer(channel, options);
  39956. },
  39957. createHandshake: function (transport, callback) {
  39958. return new connection_handshake(transport, callback);
  39959. },
  39960. createAssistantToTheTransportManager: function (manager, transport, options) {
  39961. return new assistant_to_the_transport_manager(manager, transport, options);
  39962. }
  39963. };
  39964. /* harmony default export */ var factory = (Factory);
  39965. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  39966. var transport_manager_TransportManager = (function () {
  39967. function TransportManager(options) {
  39968. this.options = options || {};
  39969. this.livesLeft = this.options.lives || Infinity;
  39970. }
  39971. TransportManager.prototype.getAssistant = function (transport) {
  39972. return factory.createAssistantToTheTransportManager(this, transport, {
  39973. minPingDelay: this.options.minPingDelay,
  39974. maxPingDelay: this.options.maxPingDelay
  39975. });
  39976. };
  39977. TransportManager.prototype.isAlive = function () {
  39978. return this.livesLeft > 0;
  39979. };
  39980. TransportManager.prototype.reportDeath = function () {
  39981. this.livesLeft -= 1;
  39982. };
  39983. return TransportManager;
  39984. }());
  39985. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  39986. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  39987. var sequential_strategy_SequentialStrategy = (function () {
  39988. function SequentialStrategy(strategies, options) {
  39989. this.strategies = strategies;
  39990. this.loop = Boolean(options.loop);
  39991. this.failFast = Boolean(options.failFast);
  39992. this.timeout = options.timeout;
  39993. this.timeoutLimit = options.timeoutLimit;
  39994. }
  39995. SequentialStrategy.prototype.isSupported = function () {
  39996. return any(this.strategies, util.method("isSupported"));
  39997. };
  39998. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  39999. var _this = this;
  40000. var strategies = this.strategies;
  40001. var current = 0;
  40002. var timeout = this.timeout;
  40003. var runner = null;
  40004. var tryNextStrategy = function (error, handshake) {
  40005. if (handshake) {
  40006. callback(null, handshake);
  40007. }
  40008. else {
  40009. current = current + 1;
  40010. if (_this.loop) {
  40011. current = current % strategies.length;
  40012. }
  40013. if (current < strategies.length) {
  40014. if (timeout) {
  40015. timeout = timeout * 2;
  40016. if (_this.timeoutLimit) {
  40017. timeout = Math.min(timeout, _this.timeoutLimit);
  40018. }
  40019. }
  40020. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40021. }
  40022. else {
  40023. callback(true);
  40024. }
  40025. }
  40026. };
  40027. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40028. return {
  40029. abort: function () {
  40030. runner.abort();
  40031. },
  40032. forceMinPriority: function (p) {
  40033. minPriority = p;
  40034. if (runner) {
  40035. runner.forceMinPriority(p);
  40036. }
  40037. }
  40038. };
  40039. };
  40040. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40041. var timer = null;
  40042. var runner = null;
  40043. if (options.timeout > 0) {
  40044. timer = new OneOffTimer(options.timeout, function () {
  40045. runner.abort();
  40046. callback(true);
  40047. });
  40048. }
  40049. runner = strategy.connect(minPriority, function (error, handshake) {
  40050. if (error && timer && timer.isRunning() && !options.failFast) {
  40051. return;
  40052. }
  40053. if (timer) {
  40054. timer.ensureAborted();
  40055. }
  40056. callback(error, handshake);
  40057. });
  40058. return {
  40059. abort: function () {
  40060. if (timer) {
  40061. timer.ensureAborted();
  40062. }
  40063. runner.abort();
  40064. },
  40065. forceMinPriority: function (p) {
  40066. runner.forceMinPriority(p);
  40067. }
  40068. };
  40069. };
  40070. return SequentialStrategy;
  40071. }());
  40072. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40073. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40074. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40075. function BestConnectedEverStrategy(strategies) {
  40076. this.strategies = strategies;
  40077. }
  40078. BestConnectedEverStrategy.prototype.isSupported = function () {
  40079. return any(this.strategies, util.method("isSupported"));
  40080. };
  40081. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40082. return connect(this.strategies, minPriority, function (i, runners) {
  40083. return function (error, handshake) {
  40084. runners[i].error = error;
  40085. if (error) {
  40086. if (allRunnersFailed(runners)) {
  40087. callback(true);
  40088. }
  40089. return;
  40090. }
  40091. apply(runners, function (runner) {
  40092. runner.forceMinPriority(handshake.transport.priority);
  40093. });
  40094. callback(null, handshake);
  40095. };
  40096. });
  40097. };
  40098. return BestConnectedEverStrategy;
  40099. }());
  40100. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40101. function connect(strategies, minPriority, callbackBuilder) {
  40102. var runners = map(strategies, function (strategy, i, _, rs) {
  40103. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40104. });
  40105. return {
  40106. abort: function () {
  40107. apply(runners, abortRunner);
  40108. },
  40109. forceMinPriority: function (p) {
  40110. apply(runners, function (runner) {
  40111. runner.forceMinPriority(p);
  40112. });
  40113. }
  40114. };
  40115. }
  40116. function allRunnersFailed(runners) {
  40117. return collections_all(runners, function (runner) {
  40118. return Boolean(runner.error);
  40119. });
  40120. }
  40121. function abortRunner(runner) {
  40122. if (!runner.error && !runner.aborted) {
  40123. runner.abort();
  40124. runner.aborted = true;
  40125. }
  40126. }
  40127. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40128. var cached_strategy_CachedStrategy = (function () {
  40129. function CachedStrategy(strategy, transports, options) {
  40130. this.strategy = strategy;
  40131. this.transports = transports;
  40132. this.ttl = options.ttl || 1800 * 1000;
  40133. this.usingTLS = options.useTLS;
  40134. this.timeline = options.timeline;
  40135. }
  40136. CachedStrategy.prototype.isSupported = function () {
  40137. return this.strategy.isSupported();
  40138. };
  40139. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40140. var usingTLS = this.usingTLS;
  40141. var info = fetchTransportCache(usingTLS);
  40142. var strategies = [this.strategy];
  40143. if (info && info.timestamp + this.ttl >= util.now()) {
  40144. var transport = this.transports[info.transport];
  40145. if (transport) {
  40146. this.timeline.info({
  40147. cached: true,
  40148. transport: info.transport,
  40149. latency: info.latency
  40150. });
  40151. strategies.push(new sequential_strategy([transport], {
  40152. timeout: info.latency * 2 + 1000,
  40153. failFast: true
  40154. }));
  40155. }
  40156. }
  40157. var startTimestamp = util.now();
  40158. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40159. if (error) {
  40160. flushTransportCache(usingTLS);
  40161. if (strategies.length > 0) {
  40162. startTimestamp = util.now();
  40163. runner = strategies.pop().connect(minPriority, cb);
  40164. }
  40165. else {
  40166. callback(error);
  40167. }
  40168. }
  40169. else {
  40170. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40171. callback(null, handshake);
  40172. }
  40173. });
  40174. return {
  40175. abort: function () {
  40176. runner.abort();
  40177. },
  40178. forceMinPriority: function (p) {
  40179. minPriority = p;
  40180. if (runner) {
  40181. runner.forceMinPriority(p);
  40182. }
  40183. }
  40184. };
  40185. };
  40186. return CachedStrategy;
  40187. }());
  40188. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40189. function getTransportCacheKey(usingTLS) {
  40190. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40191. }
  40192. function fetchTransportCache(usingTLS) {
  40193. var storage = runtime.getLocalStorage();
  40194. if (storage) {
  40195. try {
  40196. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40197. if (serializedCache) {
  40198. return JSON.parse(serializedCache);
  40199. }
  40200. }
  40201. catch (e) {
  40202. flushTransportCache(usingTLS);
  40203. }
  40204. }
  40205. return null;
  40206. }
  40207. function storeTransportCache(usingTLS, transport, latency) {
  40208. var storage = runtime.getLocalStorage();
  40209. if (storage) {
  40210. try {
  40211. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40212. timestamp: util.now(),
  40213. transport: transport,
  40214. latency: latency
  40215. });
  40216. }
  40217. catch (e) {
  40218. }
  40219. }
  40220. }
  40221. function flushTransportCache(usingTLS) {
  40222. var storage = runtime.getLocalStorage();
  40223. if (storage) {
  40224. try {
  40225. delete storage[getTransportCacheKey(usingTLS)];
  40226. }
  40227. catch (e) {
  40228. }
  40229. }
  40230. }
  40231. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40232. var delayed_strategy_DelayedStrategy = (function () {
  40233. function DelayedStrategy(strategy, _a) {
  40234. var number = _a.delay;
  40235. this.strategy = strategy;
  40236. this.options = { delay: number };
  40237. }
  40238. DelayedStrategy.prototype.isSupported = function () {
  40239. return this.strategy.isSupported();
  40240. };
  40241. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40242. var strategy = this.strategy;
  40243. var runner;
  40244. var timer = new OneOffTimer(this.options.delay, function () {
  40245. runner = strategy.connect(minPriority, callback);
  40246. });
  40247. return {
  40248. abort: function () {
  40249. timer.ensureAborted();
  40250. if (runner) {
  40251. runner.abort();
  40252. }
  40253. },
  40254. forceMinPriority: function (p) {
  40255. minPriority = p;
  40256. if (runner) {
  40257. runner.forceMinPriority(p);
  40258. }
  40259. }
  40260. };
  40261. };
  40262. return DelayedStrategy;
  40263. }());
  40264. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40265. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40266. var IfStrategy = (function () {
  40267. function IfStrategy(test, trueBranch, falseBranch) {
  40268. this.test = test;
  40269. this.trueBranch = trueBranch;
  40270. this.falseBranch = falseBranch;
  40271. }
  40272. IfStrategy.prototype.isSupported = function () {
  40273. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40274. return branch.isSupported();
  40275. };
  40276. IfStrategy.prototype.connect = function (minPriority, callback) {
  40277. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40278. return branch.connect(minPriority, callback);
  40279. };
  40280. return IfStrategy;
  40281. }());
  40282. /* harmony default export */ var if_strategy = (IfStrategy);
  40283. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40284. var FirstConnectedStrategy = (function () {
  40285. function FirstConnectedStrategy(strategy) {
  40286. this.strategy = strategy;
  40287. }
  40288. FirstConnectedStrategy.prototype.isSupported = function () {
  40289. return this.strategy.isSupported();
  40290. };
  40291. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40292. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40293. if (handshake) {
  40294. runner.abort();
  40295. }
  40296. callback(error, handshake);
  40297. });
  40298. return runner;
  40299. };
  40300. return FirstConnectedStrategy;
  40301. }());
  40302. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40303. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40304. function testSupportsStrategy(strategy) {
  40305. return function () {
  40306. return strategy.isSupported();
  40307. };
  40308. }
  40309. var getDefaultStrategy = function (config, defineTransport) {
  40310. var definedTransports = {};
  40311. function defineTransportStrategy(name, type, priority, options, manager) {
  40312. var transport = defineTransport(config, name, type, priority, options, manager);
  40313. definedTransports[name] = transport;
  40314. return transport;
  40315. }
  40316. var ws_options = {
  40317. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40318. hostTLS: config.wsHost + ":" + config.wssPort,
  40319. httpPath: config.wsPath
  40320. };
  40321. var wss_options = extend({}, ws_options, {
  40322. useTLS: true
  40323. });
  40324. var sockjs_options = {
  40325. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40326. hostTLS: config.httpHost + ":" + config.httpsPort,
  40327. httpPath: config.httpPath
  40328. };
  40329. var timeouts = {
  40330. loop: true,
  40331. timeout: 15000,
  40332. timeoutLimit: 60000
  40333. };
  40334. var ws_manager = new transport_manager({
  40335. lives: 2,
  40336. minPingDelay: 10000,
  40337. maxPingDelay: config.activity_timeout
  40338. });
  40339. var streaming_manager = new transport_manager({
  40340. lives: 2,
  40341. minPingDelay: 10000,
  40342. maxPingDelay: config.activity_timeout
  40343. });
  40344. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40345. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40346. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40347. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40348. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40349. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40350. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40351. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40352. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40353. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40354. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40355. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40356. 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);
  40357. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40358. var wsStrategy;
  40359. if (config.useTLS) {
  40360. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40361. }
  40362. else {
  40363. wsStrategy = new best_connected_ever_strategy([
  40364. ws_loop,
  40365. new delayed_strategy(wss_loop, { delay: 2000 }),
  40366. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40367. ]);
  40368. }
  40369. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40370. ttl: 1800000,
  40371. timeline: config.timeline,
  40372. useTLS: config.useTLS
  40373. });
  40374. };
  40375. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40376. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40377. /* harmony default export */ var transport_connection_initializer = (function () {
  40378. var self = this;
  40379. self.timeline.info(self.buildTimelineMessage({
  40380. transport: self.name + (self.options.useTLS ? "s" : "")
  40381. }));
  40382. if (self.hooks.isInitialized()) {
  40383. self.changeState("initialized");
  40384. }
  40385. else if (self.hooks.file) {
  40386. self.changeState("initializing");
  40387. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40388. if (self.hooks.isInitialized()) {
  40389. self.changeState("initialized");
  40390. callback(true);
  40391. }
  40392. else {
  40393. if (error) {
  40394. self.onError(error);
  40395. }
  40396. self.onClose();
  40397. callback(false);
  40398. }
  40399. });
  40400. }
  40401. else {
  40402. self.onClose();
  40403. }
  40404. });
  40405. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40406. var http_xdomain_request_hooks = {
  40407. getRequest: function (socket) {
  40408. var xdr = new window.XDomainRequest();
  40409. xdr.ontimeout = function () {
  40410. socket.emit("error", new RequestTimedOut());
  40411. socket.close();
  40412. };
  40413. xdr.onerror = function (e) {
  40414. socket.emit("error", e);
  40415. socket.close();
  40416. };
  40417. xdr.onprogress = function () {
  40418. if (xdr.responseText && xdr.responseText.length > 0) {
  40419. socket.onChunk(200, xdr.responseText);
  40420. }
  40421. };
  40422. xdr.onload = function () {
  40423. if (xdr.responseText && xdr.responseText.length > 0) {
  40424. socket.onChunk(200, xdr.responseText);
  40425. }
  40426. socket.emit("finished", 200);
  40427. socket.close();
  40428. };
  40429. return xdr;
  40430. },
  40431. abortRequest: function (xdr) {
  40432. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40433. xdr.abort();
  40434. }
  40435. };
  40436. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40437. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40438. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40439. var extendStatics = function (d, b) {
  40440. extendStatics = Object.setPrototypeOf ||
  40441. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40442. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40443. return extendStatics(d, b);
  40444. };
  40445. return function (d, b) {
  40446. extendStatics(d, b);
  40447. function __() { this.constructor = d; }
  40448. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40449. };
  40450. })();
  40451. var MAX_BUFFER_LENGTH = 256 * 1024;
  40452. var http_request_HTTPRequest = (function (_super) {
  40453. http_request_extends(HTTPRequest, _super);
  40454. function HTTPRequest(hooks, method, url) {
  40455. var _this = _super.call(this) || this;
  40456. _this.hooks = hooks;
  40457. _this.method = method;
  40458. _this.url = url;
  40459. return _this;
  40460. }
  40461. HTTPRequest.prototype.start = function (payload) {
  40462. var _this = this;
  40463. this.position = 0;
  40464. this.xhr = this.hooks.getRequest(this);
  40465. this.unloader = function () {
  40466. _this.close();
  40467. };
  40468. runtime.addUnloadListener(this.unloader);
  40469. this.xhr.open(this.method, this.url, true);
  40470. if (this.xhr.setRequestHeader) {
  40471. this.xhr.setRequestHeader("Content-Type", "application/json");
  40472. }
  40473. this.xhr.send(payload);
  40474. };
  40475. HTTPRequest.prototype.close = function () {
  40476. if (this.unloader) {
  40477. runtime.removeUnloadListener(this.unloader);
  40478. this.unloader = null;
  40479. }
  40480. if (this.xhr) {
  40481. this.hooks.abortRequest(this.xhr);
  40482. this.xhr = null;
  40483. }
  40484. };
  40485. HTTPRequest.prototype.onChunk = function (status, data) {
  40486. while (true) {
  40487. var chunk = this.advanceBuffer(data);
  40488. if (chunk) {
  40489. this.emit("chunk", { status: status, data: chunk });
  40490. }
  40491. else {
  40492. break;
  40493. }
  40494. }
  40495. if (this.isBufferTooLong(data)) {
  40496. this.emit("buffer_too_long");
  40497. }
  40498. };
  40499. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40500. var unreadData = buffer.slice(this.position);
  40501. var endOfLinePosition = unreadData.indexOf("\n");
  40502. if (endOfLinePosition !== -1) {
  40503. this.position += endOfLinePosition + 1;
  40504. return unreadData.slice(0, endOfLinePosition);
  40505. }
  40506. else {
  40507. return null;
  40508. }
  40509. };
  40510. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40511. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40512. };
  40513. return HTTPRequest;
  40514. }(dispatcher));
  40515. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40516. // CONCATENATED MODULE: ./src/core/http/state.ts
  40517. var State;
  40518. (function (State) {
  40519. State[State["CONNECTING"] = 0] = "CONNECTING";
  40520. State[State["OPEN"] = 1] = "OPEN";
  40521. State[State["CLOSED"] = 3] = "CLOSED";
  40522. })(State || (State = {}));
  40523. /* harmony default export */ var state = (State);
  40524. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40525. var autoIncrement = 1;
  40526. var http_socket_HTTPSocket = (function () {
  40527. function HTTPSocket(hooks, url) {
  40528. this.hooks = hooks;
  40529. this.session = randomNumber(1000) + "/" + randomString(8);
  40530. this.location = getLocation(url);
  40531. this.readyState = state.CONNECTING;
  40532. this.openStream();
  40533. }
  40534. HTTPSocket.prototype.send = function (payload) {
  40535. return this.sendRaw(JSON.stringify([payload]));
  40536. };
  40537. HTTPSocket.prototype.ping = function () {
  40538. this.hooks.sendHeartbeat(this);
  40539. };
  40540. HTTPSocket.prototype.close = function (code, reason) {
  40541. this.onClose(code, reason, true);
  40542. };
  40543. HTTPSocket.prototype.sendRaw = function (payload) {
  40544. if (this.readyState === state.OPEN) {
  40545. try {
  40546. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40547. return true;
  40548. }
  40549. catch (e) {
  40550. return false;
  40551. }
  40552. }
  40553. else {
  40554. return false;
  40555. }
  40556. };
  40557. HTTPSocket.prototype.reconnect = function () {
  40558. this.closeStream();
  40559. this.openStream();
  40560. };
  40561. ;
  40562. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40563. this.closeStream();
  40564. this.readyState = state.CLOSED;
  40565. if (this.onclose) {
  40566. this.onclose({
  40567. code: code,
  40568. reason: reason,
  40569. wasClean: wasClean
  40570. });
  40571. }
  40572. };
  40573. HTTPSocket.prototype.onChunk = function (chunk) {
  40574. if (chunk.status !== 200) {
  40575. return;
  40576. }
  40577. if (this.readyState === state.OPEN) {
  40578. this.onActivity();
  40579. }
  40580. var payload;
  40581. var type = chunk.data.slice(0, 1);
  40582. switch (type) {
  40583. case 'o':
  40584. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40585. this.onOpen(payload);
  40586. break;
  40587. case 'a':
  40588. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40589. for (var i = 0; i < payload.length; i++) {
  40590. this.onEvent(payload[i]);
  40591. }
  40592. break;
  40593. case 'm':
  40594. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40595. this.onEvent(payload);
  40596. break;
  40597. case 'h':
  40598. this.hooks.onHeartbeat(this);
  40599. break;
  40600. case 'c':
  40601. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40602. this.onClose(payload[0], payload[1], true);
  40603. break;
  40604. }
  40605. };
  40606. HTTPSocket.prototype.onOpen = function (options) {
  40607. if (this.readyState === state.CONNECTING) {
  40608. if (options && options.hostname) {
  40609. this.location.base = replaceHost(this.location.base, options.hostname);
  40610. }
  40611. this.readyState = state.OPEN;
  40612. if (this.onopen) {
  40613. this.onopen();
  40614. }
  40615. }
  40616. else {
  40617. this.onClose(1006, "Server lost session", true);
  40618. }
  40619. };
  40620. HTTPSocket.prototype.onEvent = function (event) {
  40621. if (this.readyState === state.OPEN && this.onmessage) {
  40622. this.onmessage({ data: event });
  40623. }
  40624. };
  40625. HTTPSocket.prototype.onActivity = function () {
  40626. if (this.onactivity) {
  40627. this.onactivity();
  40628. }
  40629. };
  40630. HTTPSocket.prototype.onError = function (error) {
  40631. if (this.onerror) {
  40632. this.onerror(error);
  40633. }
  40634. };
  40635. HTTPSocket.prototype.openStream = function () {
  40636. var _this = this;
  40637. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40638. this.stream.bind("chunk", function (chunk) {
  40639. _this.onChunk(chunk);
  40640. });
  40641. this.stream.bind("finished", function (status) {
  40642. _this.hooks.onFinished(_this, status);
  40643. });
  40644. this.stream.bind("buffer_too_long", function () {
  40645. _this.reconnect();
  40646. });
  40647. try {
  40648. this.stream.start();
  40649. }
  40650. catch (error) {
  40651. util.defer(function () {
  40652. _this.onError(error);
  40653. _this.onClose(1006, "Could not start streaming", false);
  40654. });
  40655. }
  40656. };
  40657. HTTPSocket.prototype.closeStream = function () {
  40658. if (this.stream) {
  40659. this.stream.unbind_all();
  40660. this.stream.close();
  40661. this.stream = null;
  40662. }
  40663. };
  40664. return HTTPSocket;
  40665. }());
  40666. function getLocation(url) {
  40667. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40668. return {
  40669. base: parts[1],
  40670. queryString: parts[2]
  40671. };
  40672. }
  40673. function getSendURL(url, session) {
  40674. return url.base + "/" + session + "/xhr_send";
  40675. }
  40676. function getUniqueURL(url) {
  40677. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40678. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40679. }
  40680. function replaceHost(url, hostname) {
  40681. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40682. return urlParts[1] + hostname + urlParts[3];
  40683. }
  40684. function randomNumber(max) {
  40685. return Math.floor(Math.random() * max);
  40686. }
  40687. function randomString(length) {
  40688. var result = [];
  40689. for (var i = 0; i < length; i++) {
  40690. result.push(randomNumber(32).toString(32));
  40691. }
  40692. return result.join('');
  40693. }
  40694. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40695. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40696. var http_streaming_socket_hooks = {
  40697. getReceiveURL: function (url, session) {
  40698. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40699. },
  40700. onHeartbeat: function (socket) {
  40701. socket.sendRaw("[]");
  40702. },
  40703. sendHeartbeat: function (socket) {
  40704. socket.sendRaw("[]");
  40705. },
  40706. onFinished: function (socket, status) {
  40707. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40708. }
  40709. };
  40710. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40711. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40712. var http_polling_socket_hooks = {
  40713. getReceiveURL: function (url, session) {
  40714. return url.base + "/" + session + "/xhr" + url.queryString;
  40715. },
  40716. onHeartbeat: function () {
  40717. },
  40718. sendHeartbeat: function (socket) {
  40719. socket.sendRaw("[]");
  40720. },
  40721. onFinished: function (socket, status) {
  40722. if (status === 200) {
  40723. socket.reconnect();
  40724. }
  40725. else {
  40726. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40727. }
  40728. }
  40729. };
  40730. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40731. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40732. var http_xhr_request_hooks = {
  40733. getRequest: function (socket) {
  40734. var Constructor = runtime.getXHRAPI();
  40735. var xhr = new Constructor();
  40736. xhr.onreadystatechange = xhr.onprogress = function () {
  40737. switch (xhr.readyState) {
  40738. case 3:
  40739. if (xhr.responseText && xhr.responseText.length > 0) {
  40740. socket.onChunk(xhr.status, xhr.responseText);
  40741. }
  40742. break;
  40743. case 4:
  40744. if (xhr.responseText && xhr.responseText.length > 0) {
  40745. socket.onChunk(xhr.status, xhr.responseText);
  40746. }
  40747. socket.emit("finished", xhr.status);
  40748. socket.close();
  40749. break;
  40750. }
  40751. };
  40752. return xhr;
  40753. },
  40754. abortRequest: function (xhr) {
  40755. xhr.onreadystatechange = null;
  40756. xhr.abort();
  40757. }
  40758. };
  40759. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40760. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40761. var HTTP = {
  40762. createStreamingSocket: function (url) {
  40763. return this.createSocket(http_streaming_socket, url);
  40764. },
  40765. createPollingSocket: function (url) {
  40766. return this.createSocket(http_polling_socket, url);
  40767. },
  40768. createSocket: function (hooks, url) {
  40769. return new http_socket(hooks, url);
  40770. },
  40771. createXHR: function (method, url) {
  40772. return this.createRequest(http_xhr_request, method, url);
  40773. },
  40774. createRequest: function (hooks, method, url) {
  40775. return new http_request(hooks, method, url);
  40776. }
  40777. };
  40778. /* harmony default export */ var http_http = (HTTP);
  40779. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40780. http_http.createXDR = function (method, url) {
  40781. return this.createRequest(http_xdomain_request, method, url);
  40782. };
  40783. /* harmony default export */ var web_http_http = (http_http);
  40784. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40785. var Runtime = {
  40786. nextAuthCallbackID: 1,
  40787. auth_callbacks: {},
  40788. ScriptReceivers: ScriptReceivers,
  40789. DependenciesReceivers: DependenciesReceivers,
  40790. getDefaultStrategy: default_strategy,
  40791. Transports: transports_transports,
  40792. transportConnectionInitializer: transport_connection_initializer,
  40793. HTTPFactory: web_http_http,
  40794. TimelineTransport: jsonp_timeline,
  40795. getXHRAPI: function () {
  40796. return window.XMLHttpRequest;
  40797. },
  40798. getWebSocketAPI: function () {
  40799. return window.WebSocket || window.MozWebSocket;
  40800. },
  40801. setup: function (PusherClass) {
  40802. var _this = this;
  40803. window.Pusher = PusherClass;
  40804. var initializeOnDocumentBody = function () {
  40805. _this.onDocumentBody(PusherClass.ready);
  40806. };
  40807. if (!window.JSON) {
  40808. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40809. }
  40810. else {
  40811. initializeOnDocumentBody();
  40812. }
  40813. },
  40814. getDocument: function () {
  40815. return document;
  40816. },
  40817. getProtocol: function () {
  40818. return this.getDocument().location.protocol;
  40819. },
  40820. getAuthorizers: function () {
  40821. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40822. },
  40823. onDocumentBody: function (callback) {
  40824. var _this = this;
  40825. if (document.body) {
  40826. callback();
  40827. }
  40828. else {
  40829. setTimeout(function () {
  40830. _this.onDocumentBody(callback);
  40831. }, 0);
  40832. }
  40833. },
  40834. createJSONPRequest: function (url, data) {
  40835. return new jsonp_request(url, data);
  40836. },
  40837. createScriptRequest: function (src) {
  40838. return new script_request(src);
  40839. },
  40840. getLocalStorage: function () {
  40841. try {
  40842. return window.localStorage;
  40843. }
  40844. catch (e) {
  40845. return undefined;
  40846. }
  40847. },
  40848. createXHR: function () {
  40849. if (this.getXHRAPI()) {
  40850. return this.createXMLHttpRequest();
  40851. }
  40852. else {
  40853. return this.createMicrosoftXHR();
  40854. }
  40855. },
  40856. createXMLHttpRequest: function () {
  40857. var Constructor = this.getXHRAPI();
  40858. return new Constructor();
  40859. },
  40860. createMicrosoftXHR: function () {
  40861. return new ActiveXObject("Microsoft.XMLHTTP");
  40862. },
  40863. getNetwork: function () {
  40864. return net_info_Network;
  40865. },
  40866. createWebSocket: function (url) {
  40867. var Constructor = this.getWebSocketAPI();
  40868. return new Constructor(url);
  40869. },
  40870. createSocketRequest: function (method, url) {
  40871. if (this.isXHRSupported()) {
  40872. return this.HTTPFactory.createXHR(method, url);
  40873. }
  40874. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40875. return this.HTTPFactory.createXDR(method, url);
  40876. }
  40877. else {
  40878. throw "Cross-origin HTTP requests are not supported";
  40879. }
  40880. },
  40881. isXHRSupported: function () {
  40882. var Constructor = this.getXHRAPI();
  40883. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40884. },
  40885. isXDRSupported: function (useTLS) {
  40886. var protocol = useTLS ? "https:" : "http:";
  40887. var documentProtocol = this.getProtocol();
  40888. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40889. },
  40890. addUnloadListener: function (listener) {
  40891. if (window.addEventListener !== undefined) {
  40892. window.addEventListener("unload", listener, false);
  40893. }
  40894. else if (window.attachEvent !== undefined) {
  40895. window.attachEvent("onunload", listener);
  40896. }
  40897. },
  40898. removeUnloadListener: function (listener) {
  40899. if (window.addEventListener !== undefined) {
  40900. window.removeEventListener("unload", listener, false);
  40901. }
  40902. else if (window.detachEvent !== undefined) {
  40903. window.detachEvent("onunload", listener);
  40904. }
  40905. }
  40906. };
  40907. /* harmony default export */ var runtime = (Runtime);
  40908. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40909. var TimelineLevel;
  40910. (function (TimelineLevel) {
  40911. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40912. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40913. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40914. })(TimelineLevel || (TimelineLevel = {}));
  40915. /* harmony default export */ var timeline_level = (TimelineLevel);
  40916. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40917. var timeline_Timeline = (function () {
  40918. function Timeline(key, session, options) {
  40919. this.key = key;
  40920. this.session = session;
  40921. this.events = [];
  40922. this.options = options || {};
  40923. this.sent = 0;
  40924. this.uniqueID = 0;
  40925. }
  40926. Timeline.prototype.log = function (level, event) {
  40927. if (level <= this.options.level) {
  40928. this.events.push(extend({}, event, { timestamp: util.now() }));
  40929. if (this.options.limit && this.events.length > this.options.limit) {
  40930. this.events.shift();
  40931. }
  40932. }
  40933. };
  40934. Timeline.prototype.error = function (event) {
  40935. this.log(timeline_level.ERROR, event);
  40936. };
  40937. Timeline.prototype.info = function (event) {
  40938. this.log(timeline_level.INFO, event);
  40939. };
  40940. Timeline.prototype.debug = function (event) {
  40941. this.log(timeline_level.DEBUG, event);
  40942. };
  40943. Timeline.prototype.isEmpty = function () {
  40944. return this.events.length === 0;
  40945. };
  40946. Timeline.prototype.send = function (sendfn, callback) {
  40947. var _this = this;
  40948. var data = extend({
  40949. session: this.session,
  40950. bundle: this.sent + 1,
  40951. key: this.key,
  40952. lib: "js",
  40953. version: this.options.version,
  40954. cluster: this.options.cluster,
  40955. features: this.options.features,
  40956. timeline: this.events
  40957. }, this.options.params);
  40958. this.events = [];
  40959. sendfn(data, function (error, result) {
  40960. if (!error) {
  40961. _this.sent++;
  40962. }
  40963. if (callback) {
  40964. callback(error, result);
  40965. }
  40966. });
  40967. return true;
  40968. };
  40969. Timeline.prototype.generateUniqueID = function () {
  40970. this.uniqueID++;
  40971. return this.uniqueID;
  40972. };
  40973. return Timeline;
  40974. }());
  40975. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  40976. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  40977. var transport_strategy_TransportStrategy = (function () {
  40978. function TransportStrategy(name, priority, transport, options) {
  40979. this.name = name;
  40980. this.priority = priority;
  40981. this.transport = transport;
  40982. this.options = options || {};
  40983. }
  40984. TransportStrategy.prototype.isSupported = function () {
  40985. return this.transport.isSupported({
  40986. useTLS: this.options.useTLS
  40987. });
  40988. };
  40989. TransportStrategy.prototype.connect = function (minPriority, callback) {
  40990. var _this = this;
  40991. if (!this.isSupported()) {
  40992. return failAttempt(new UnsupportedStrategy(), callback);
  40993. }
  40994. else if (this.priority < minPriority) {
  40995. return failAttempt(new TransportPriorityTooLow(), callback);
  40996. }
  40997. var connected = false;
  40998. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  40999. var handshake = null;
  41000. var onInitialized = function () {
  41001. transport.unbind("initialized", onInitialized);
  41002. transport.connect();
  41003. };
  41004. var onOpen = function () {
  41005. handshake = factory.createHandshake(transport, function (result) {
  41006. connected = true;
  41007. unbindListeners();
  41008. callback(null, result);
  41009. });
  41010. };
  41011. var onError = function (error) {
  41012. unbindListeners();
  41013. callback(error);
  41014. };
  41015. var onClosed = function () {
  41016. unbindListeners();
  41017. var serializedTransport;
  41018. serializedTransport = safeJSONStringify(transport);
  41019. callback(new TransportClosed(serializedTransport));
  41020. };
  41021. var unbindListeners = function () {
  41022. transport.unbind("initialized", onInitialized);
  41023. transport.unbind("open", onOpen);
  41024. transport.unbind("error", onError);
  41025. transport.unbind("closed", onClosed);
  41026. };
  41027. transport.bind("initialized", onInitialized);
  41028. transport.bind("open", onOpen);
  41029. transport.bind("error", onError);
  41030. transport.bind("closed", onClosed);
  41031. transport.initialize();
  41032. return {
  41033. abort: function () {
  41034. if (connected) {
  41035. return;
  41036. }
  41037. unbindListeners();
  41038. if (handshake) {
  41039. handshake.close();
  41040. }
  41041. else {
  41042. transport.close();
  41043. }
  41044. },
  41045. forceMinPriority: function (p) {
  41046. if (connected) {
  41047. return;
  41048. }
  41049. if (_this.priority < p) {
  41050. if (handshake) {
  41051. handshake.close();
  41052. }
  41053. else {
  41054. transport.close();
  41055. }
  41056. }
  41057. }
  41058. };
  41059. };
  41060. return TransportStrategy;
  41061. }());
  41062. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41063. function failAttempt(error, callback) {
  41064. util.defer(function () {
  41065. callback(error);
  41066. });
  41067. return {
  41068. abort: function () { },
  41069. forceMinPriority: function () { }
  41070. };
  41071. }
  41072. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41073. var strategy_builder_Transports = runtime.Transports;
  41074. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41075. var transportClass = strategy_builder_Transports[type];
  41076. if (!transportClass) {
  41077. throw new UnsupportedTransport(type);
  41078. }
  41079. var enabled = (!config.enabledTransports ||
  41080. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41081. (!config.disabledTransports ||
  41082. arrayIndexOf(config.disabledTransports, name) === -1);
  41083. var transport;
  41084. if (enabled) {
  41085. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41086. key: config.key,
  41087. useTLS: config.useTLS,
  41088. timeline: config.timeline,
  41089. ignoreNullOrigin: config.ignoreNullOrigin
  41090. }, options));
  41091. }
  41092. else {
  41093. transport = strategy_builder_UnsupportedStrategy;
  41094. }
  41095. return transport;
  41096. };
  41097. var strategy_builder_UnsupportedStrategy = {
  41098. isSupported: function () {
  41099. return false;
  41100. },
  41101. connect: function (_, callback) {
  41102. var deferred = util.defer(function () {
  41103. callback(new UnsupportedStrategy());
  41104. });
  41105. return {
  41106. abort: function () {
  41107. deferred.ensureAborted();
  41108. },
  41109. forceMinPriority: function () { }
  41110. };
  41111. }
  41112. };
  41113. // CONCATENATED MODULE: ./src/core/config.ts
  41114. var getGlobalConfig = function () {
  41115. return {
  41116. wsHost: defaults.host,
  41117. wsPort: defaults.ws_port,
  41118. wssPort: defaults.wss_port,
  41119. wsPath: defaults.ws_path,
  41120. httpHost: defaults.sockjs_host,
  41121. httpPort: defaults.sockjs_http_port,
  41122. httpsPort: defaults.sockjs_https_port,
  41123. httpPath: defaults.sockjs_path,
  41124. statsHost: defaults.stats_host,
  41125. authEndpoint: defaults.channel_auth_endpoint,
  41126. authTransport: defaults.channel_auth_transport,
  41127. activity_timeout: defaults.activity_timeout,
  41128. pong_timeout: defaults.pong_timeout,
  41129. unavailable_timeout: defaults.unavailable_timeout
  41130. };
  41131. };
  41132. var getClusterConfig = function (clusterName) {
  41133. return {
  41134. wsHost: 'ws-' + clusterName + '.pusher.com',
  41135. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41136. };
  41137. };
  41138. // CONCATENATED MODULE: ./src/core/pusher.ts
  41139. var pusher_Pusher = (function () {
  41140. function Pusher(app_key, options) {
  41141. var _this = this;
  41142. checkAppKey(app_key);
  41143. options = options || {};
  41144. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41145. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41146. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41147. }
  41148. this.key = app_key;
  41149. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41150. this.channels = factory.createChannels();
  41151. this.global_emitter = new dispatcher();
  41152. this.sessionID = Math.floor(Math.random() * 1000000000);
  41153. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41154. cluster: this.config.cluster,
  41155. features: Pusher.getClientFeatures(),
  41156. params: this.config.timelineParams || {},
  41157. limit: 50,
  41158. level: timeline_level.INFO,
  41159. version: defaults.VERSION
  41160. });
  41161. if (!this.config.disableStats) {
  41162. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41163. host: this.config.statsHost,
  41164. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41165. });
  41166. }
  41167. var getStrategy = function (options) {
  41168. var config = extend({}, _this.config, options);
  41169. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41170. };
  41171. this.connection = factory.createConnectionManager(this.key, extend({
  41172. getStrategy: getStrategy,
  41173. timeline: this.timeline,
  41174. activityTimeout: this.config.activity_timeout,
  41175. pongTimeout: this.config.pong_timeout,
  41176. unavailableTimeout: this.config.unavailable_timeout
  41177. }, this.config, { useTLS: this.shouldUseTLS() }));
  41178. this.connection.bind('connected', function () {
  41179. _this.subscribeAll();
  41180. if (_this.timelineSender) {
  41181. _this.timelineSender.send(_this.connection.isUsingTLS());
  41182. }
  41183. });
  41184. this.connection.bind('message', function (event) {
  41185. var eventName = event.event;
  41186. var internal = eventName.indexOf('pusher_internal:') === 0;
  41187. if (event.channel) {
  41188. var channel = _this.channel(event.channel);
  41189. if (channel) {
  41190. channel.handleEvent(event);
  41191. }
  41192. }
  41193. if (!internal) {
  41194. _this.global_emitter.emit(event.event, event.data);
  41195. }
  41196. });
  41197. this.connection.bind('connecting', function () {
  41198. _this.channels.disconnect();
  41199. });
  41200. this.connection.bind('disconnected', function () {
  41201. _this.channels.disconnect();
  41202. });
  41203. this.connection.bind('error', function (err) {
  41204. logger.warn(err);
  41205. });
  41206. Pusher.instances.push(this);
  41207. this.timeline.info({ instances: Pusher.instances.length });
  41208. if (Pusher.isReady) {
  41209. this.connect();
  41210. }
  41211. }
  41212. Pusher.ready = function () {
  41213. Pusher.isReady = true;
  41214. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41215. Pusher.instances[i].connect();
  41216. }
  41217. };
  41218. Pusher.getClientFeatures = function () {
  41219. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41220. return t.isSupported({});
  41221. }));
  41222. };
  41223. Pusher.prototype.channel = function (name) {
  41224. return this.channels.find(name);
  41225. };
  41226. Pusher.prototype.allChannels = function () {
  41227. return this.channels.all();
  41228. };
  41229. Pusher.prototype.connect = function () {
  41230. this.connection.connect();
  41231. if (this.timelineSender) {
  41232. if (!this.timelineSenderTimer) {
  41233. var usingTLS = this.connection.isUsingTLS();
  41234. var timelineSender = this.timelineSender;
  41235. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41236. timelineSender.send(usingTLS);
  41237. });
  41238. }
  41239. }
  41240. };
  41241. Pusher.prototype.disconnect = function () {
  41242. this.connection.disconnect();
  41243. if (this.timelineSenderTimer) {
  41244. this.timelineSenderTimer.ensureAborted();
  41245. this.timelineSenderTimer = null;
  41246. }
  41247. };
  41248. Pusher.prototype.bind = function (event_name, callback, context) {
  41249. this.global_emitter.bind(event_name, callback, context);
  41250. return this;
  41251. };
  41252. Pusher.prototype.unbind = function (event_name, callback, context) {
  41253. this.global_emitter.unbind(event_name, callback, context);
  41254. return this;
  41255. };
  41256. Pusher.prototype.bind_global = function (callback) {
  41257. this.global_emitter.bind_global(callback);
  41258. return this;
  41259. };
  41260. Pusher.prototype.unbind_global = function (callback) {
  41261. this.global_emitter.unbind_global(callback);
  41262. return this;
  41263. };
  41264. Pusher.prototype.unbind_all = function (callback) {
  41265. this.global_emitter.unbind_all();
  41266. return this;
  41267. };
  41268. Pusher.prototype.subscribeAll = function () {
  41269. var channelName;
  41270. for (channelName in this.channels.channels) {
  41271. if (this.channels.channels.hasOwnProperty(channelName)) {
  41272. this.subscribe(channelName);
  41273. }
  41274. }
  41275. };
  41276. Pusher.prototype.subscribe = function (channel_name) {
  41277. var channel = this.channels.add(channel_name, this);
  41278. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41279. channel.reinstateSubscription();
  41280. }
  41281. else if (!channel.subscriptionPending &&
  41282. this.connection.state === 'connected') {
  41283. channel.subscribe();
  41284. }
  41285. return channel;
  41286. };
  41287. Pusher.prototype.unsubscribe = function (channel_name) {
  41288. var channel = this.channels.find(channel_name);
  41289. if (channel && channel.subscriptionPending) {
  41290. channel.cancelSubscription();
  41291. }
  41292. else {
  41293. channel = this.channels.remove(channel_name);
  41294. if (channel && this.connection.state === 'connected') {
  41295. channel.unsubscribe();
  41296. }
  41297. }
  41298. };
  41299. Pusher.prototype.send_event = function (event_name, data, channel) {
  41300. return this.connection.send_event(event_name, data, channel);
  41301. };
  41302. Pusher.prototype.shouldUseTLS = function () {
  41303. if (runtime.getProtocol() === 'https:') {
  41304. return true;
  41305. }
  41306. else if (this.config.forceTLS === true) {
  41307. return true;
  41308. }
  41309. else {
  41310. return Boolean(this.config.encrypted);
  41311. }
  41312. };
  41313. Pusher.instances = [];
  41314. Pusher.isReady = false;
  41315. Pusher.logToConsole = false;
  41316. Pusher.Runtime = runtime;
  41317. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41318. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41319. Pusher.auth_callbacks = runtime.auth_callbacks;
  41320. return Pusher;
  41321. }());
  41322. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41323. function checkAppKey(key) {
  41324. if (key === null || key === undefined) {
  41325. throw 'You must pass your app key when you instantiate Pusher.';
  41326. }
  41327. }
  41328. runtime.setup(pusher_Pusher);
  41329. /***/ })
  41330. /******/ ]);
  41331. });
  41332. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41333. /***/ }),
  41334. /***/ "./node_modules/setimmediate/setImmediate.js":
  41335. /*!***************************************************!*\
  41336. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41337. \***************************************************/
  41338. /*! no static exports found */
  41339. /***/ (function(module, exports, __webpack_require__) {
  41340. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41341. "use strict";
  41342. if (global.setImmediate) {
  41343. return;
  41344. }
  41345. var nextHandle = 1; // Spec says greater than zero
  41346. var tasksByHandle = {};
  41347. var currentlyRunningATask = false;
  41348. var doc = global.document;
  41349. var registerImmediate;
  41350. function setImmediate(callback) {
  41351. // Callback can either be a function or a string
  41352. if (typeof callback !== "function") {
  41353. callback = new Function("" + callback);
  41354. }
  41355. // Copy function arguments
  41356. var args = new Array(arguments.length - 1);
  41357. for (var i = 0; i < args.length; i++) {
  41358. args[i] = arguments[i + 1];
  41359. }
  41360. // Store and register the task
  41361. var task = { callback: callback, args: args };
  41362. tasksByHandle[nextHandle] = task;
  41363. registerImmediate(nextHandle);
  41364. return nextHandle++;
  41365. }
  41366. function clearImmediate(handle) {
  41367. delete tasksByHandle[handle];
  41368. }
  41369. function run(task) {
  41370. var callback = task.callback;
  41371. var args = task.args;
  41372. switch (args.length) {
  41373. case 0:
  41374. callback();
  41375. break;
  41376. case 1:
  41377. callback(args[0]);
  41378. break;
  41379. case 2:
  41380. callback(args[0], args[1]);
  41381. break;
  41382. case 3:
  41383. callback(args[0], args[1], args[2]);
  41384. break;
  41385. default:
  41386. callback.apply(undefined, args);
  41387. break;
  41388. }
  41389. }
  41390. function runIfPresent(handle) {
  41391. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41392. // So if we're currently running a task, we'll need to delay this invocation.
  41393. if (currentlyRunningATask) {
  41394. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41395. // "too much recursion" error.
  41396. setTimeout(runIfPresent, 0, handle);
  41397. } else {
  41398. var task = tasksByHandle[handle];
  41399. if (task) {
  41400. currentlyRunningATask = true;
  41401. try {
  41402. run(task);
  41403. } finally {
  41404. clearImmediate(handle);
  41405. currentlyRunningATask = false;
  41406. }
  41407. }
  41408. }
  41409. }
  41410. function installNextTickImplementation() {
  41411. registerImmediate = function(handle) {
  41412. process.nextTick(function () { runIfPresent(handle); });
  41413. };
  41414. }
  41415. function canUsePostMessage() {
  41416. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41417. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41418. if (global.postMessage && !global.importScripts) {
  41419. var postMessageIsAsynchronous = true;
  41420. var oldOnMessage = global.onmessage;
  41421. global.onmessage = function() {
  41422. postMessageIsAsynchronous = false;
  41423. };
  41424. global.postMessage("", "*");
  41425. global.onmessage = oldOnMessage;
  41426. return postMessageIsAsynchronous;
  41427. }
  41428. }
  41429. function installPostMessageImplementation() {
  41430. // Installs an event handler on `global` for the `message` event: see
  41431. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41432. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41433. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41434. var onGlobalMessage = function(event) {
  41435. if (event.source === global &&
  41436. typeof event.data === "string" &&
  41437. event.data.indexOf(messagePrefix) === 0) {
  41438. runIfPresent(+event.data.slice(messagePrefix.length));
  41439. }
  41440. };
  41441. if (global.addEventListener) {
  41442. global.addEventListener("message", onGlobalMessage, false);
  41443. } else {
  41444. global.attachEvent("onmessage", onGlobalMessage);
  41445. }
  41446. registerImmediate = function(handle) {
  41447. global.postMessage(messagePrefix + handle, "*");
  41448. };
  41449. }
  41450. function installMessageChannelImplementation() {
  41451. var channel = new MessageChannel();
  41452. channel.port1.onmessage = function(event) {
  41453. var handle = event.data;
  41454. runIfPresent(handle);
  41455. };
  41456. registerImmediate = function(handle) {
  41457. channel.port2.postMessage(handle);
  41458. };
  41459. }
  41460. function installReadyStateChangeImplementation() {
  41461. var html = doc.documentElement;
  41462. registerImmediate = function(handle) {
  41463. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41464. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41465. var script = doc.createElement("script");
  41466. script.onreadystatechange = function () {
  41467. runIfPresent(handle);
  41468. script.onreadystatechange = null;
  41469. html.removeChild(script);
  41470. script = null;
  41471. };
  41472. html.appendChild(script);
  41473. };
  41474. }
  41475. function installSetTimeoutImplementation() {
  41476. registerImmediate = function(handle) {
  41477. setTimeout(runIfPresent, 0, handle);
  41478. };
  41479. }
  41480. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41481. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41482. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41483. // Don't get fooled by e.g. browserify environments.
  41484. if ({}.toString.call(global.process) === "[object process]") {
  41485. // For Node.js before 0.9
  41486. installNextTickImplementation();
  41487. } else if (canUsePostMessage()) {
  41488. // For non-IE10 modern browsers
  41489. installPostMessageImplementation();
  41490. } else if (global.MessageChannel) {
  41491. // For web workers, where supported
  41492. installMessageChannelImplementation();
  41493. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41494. // For IE 6–8
  41495. installReadyStateChangeImplementation();
  41496. } else {
  41497. // For older browsers
  41498. installSetTimeoutImplementation();
  41499. }
  41500. attachTo.setImmediate = setImmediate;
  41501. attachTo.clearImmediate = clearImmediate;
  41502. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41503. /* 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")))
  41504. /***/ }),
  41505. /***/ "./node_modules/timers-browserify/main.js":
  41506. /*!************************************************!*\
  41507. !*** ./node_modules/timers-browserify/main.js ***!
  41508. \************************************************/
  41509. /*! no static exports found */
  41510. /***/ (function(module, exports, __webpack_require__) {
  41511. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41512. (typeof self !== "undefined" && self) ||
  41513. window;
  41514. var apply = Function.prototype.apply;
  41515. // DOM APIs, for completeness
  41516. exports.setTimeout = function() {
  41517. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41518. };
  41519. exports.setInterval = function() {
  41520. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41521. };
  41522. exports.clearTimeout =
  41523. exports.clearInterval = function(timeout) {
  41524. if (timeout) {
  41525. timeout.close();
  41526. }
  41527. };
  41528. function Timeout(id, clearFn) {
  41529. this._id = id;
  41530. this._clearFn = clearFn;
  41531. }
  41532. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41533. Timeout.prototype.close = function() {
  41534. this._clearFn.call(scope, this._id);
  41535. };
  41536. // Does not start the time, just sets up the members needed.
  41537. exports.enroll = function(item, msecs) {
  41538. clearTimeout(item._idleTimeoutId);
  41539. item._idleTimeout = msecs;
  41540. };
  41541. exports.unenroll = function(item) {
  41542. clearTimeout(item._idleTimeoutId);
  41543. item._idleTimeout = -1;
  41544. };
  41545. exports._unrefActive = exports.active = function(item) {
  41546. clearTimeout(item._idleTimeoutId);
  41547. var msecs = item._idleTimeout;
  41548. if (msecs >= 0) {
  41549. item._idleTimeoutId = setTimeout(function onTimeout() {
  41550. if (item._onTimeout)
  41551. item._onTimeout();
  41552. }, msecs);
  41553. }
  41554. };
  41555. // setimmediate attaches itself to the global object
  41556. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41557. // On some exotic environments, it's not clear which object `setimmediate` was
  41558. // able to install onto. Search each possibility in the same order as the
  41559. // `setimmediate` library.
  41560. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41561. (typeof global !== "undefined" && global.setImmediate) ||
  41562. (this && this.setImmediate);
  41563. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41564. (typeof global !== "undefined" && global.clearImmediate) ||
  41565. (this && this.clearImmediate);
  41566. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41567. /***/ }),
  41568. /***/ "./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&":
  41569. /*!*******************************************************************************************************************************************************************************************************************!*\
  41570. !*** ./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& ***!
  41571. \*******************************************************************************************************************************************************************************************************************/
  41572. /*! exports provided: render, staticRenderFns */
  41573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41574. "use strict";
  41575. __webpack_require__.r(__webpack_exports__);
  41576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41578. var render = function() {
  41579. var _vm = this
  41580. var _h = _vm.$createElement
  41581. var _c = _vm._self._c || _h
  41582. return _vm._m(0)
  41583. }
  41584. var staticRenderFns = [
  41585. function() {
  41586. var _vm = this
  41587. var _h = _vm.$createElement
  41588. var _c = _vm._self._c || _h
  41589. return _c("div", { staticClass: "container" }, [
  41590. _c("div", { staticClass: "row justify-content-center" }, [
  41591. _c("div", { staticClass: "col-md-8" }, [
  41592. _c("div", { staticClass: "card" }, [
  41593. _c("div", { staticClass: "card-header" }, [
  41594. _vm._v("Example Component")
  41595. ]),
  41596. _vm._v(" "),
  41597. _c("div", { staticClass: "card-body" }, [
  41598. _vm._v(
  41599. "\n I'm an example component.\n "
  41600. )
  41601. ])
  41602. ])
  41603. ])
  41604. ])
  41605. ])
  41606. }
  41607. ]
  41608. render._withStripped = true
  41609. /***/ }),
  41610. /***/ "./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&":
  41611. /*!************************************************************************************************************************************************************************************************************!*\
  41612. !*** ./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& ***!
  41613. \************************************************************************************************************************************************************************************************************/
  41614. /*! exports provided: render, staticRenderFns */
  41615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41616. "use strict";
  41617. __webpack_require__.r(__webpack_exports__);
  41618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41620. var render = function() {
  41621. var _vm = this
  41622. var _h = _vm.$createElement
  41623. var _c = _vm._self._c || _h
  41624. return _c("div", [
  41625. _c("p", [
  41626. _vm._v("PCID: "),
  41627. _c("span", { domProps: { textContent: _vm._s(this.data.pcid) } })
  41628. ]),
  41629. _vm._v(" "),
  41630. _c("p", [
  41631. _vm._v("Manufacturer: "),
  41632. _c("span", { domProps: { textContent: _vm._s(this.data.pcmanu) } })
  41633. ])
  41634. ])
  41635. }
  41636. var staticRenderFns = []
  41637. render._withStripped = true
  41638. /***/ }),
  41639. /***/ "./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&":
  41640. /*!*********************************************************************************************************************************************************************************************************!*\
  41641. !*** ./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& ***!
  41642. \*********************************************************************************************************************************************************************************************************/
  41643. /*! exports provided: render, staticRenderFns */
  41644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41645. "use strict";
  41646. __webpack_require__.r(__webpack_exports__);
  41647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41649. var render = function() {
  41650. var _vm = this
  41651. var _h = _vm.$createElement
  41652. var _c = _vm._self._c || _h
  41653. return _c("div", [
  41654. _c("p", [
  41655. _vm._v("Problem Description: "),
  41656. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  41657. ]),
  41658. _vm._v(" "),
  41659. _c("p", [
  41660. _vm._v("Suggested Solution: "),
  41661. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  41662. ]),
  41663. _vm._v(" "),
  41664. _c("p", [
  41665. _vm._v("Work Order ID: "),
  41666. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  41667. ]),
  41668. _vm._v(" "),
  41669. _c("p", [
  41670. _vm._v("Store: "),
  41671. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  41672. ]),
  41673. _vm._v(" "),
  41674. _c("p", [
  41675. _vm._v("Check-in Date: \n "),
  41676. _c(
  41677. "span",
  41678. {
  41679. staticClass: "dashed-underline",
  41680. attrs: {
  41681. "data-toggle": "tooltip",
  41682. "data-placement": "bottom",
  41683. title: this.getHRDate(this.data.dropdate)
  41684. }
  41685. },
  41686. [
  41687. _vm._v(
  41688. "\n " +
  41689. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  41690. " days ago\n "
  41691. )
  41692. ]
  41693. )
  41694. ]),
  41695. _vm._v(" "),
  41696. _c("p", [
  41697. _vm._v("Check-out Date: \n "),
  41698. !this.isZero(this.data.pickupdate)
  41699. ? _c(
  41700. "span",
  41701. {
  41702. staticClass: "dashed-underline",
  41703. attrs: {
  41704. "data-toggle": "tooltip",
  41705. "data-placement": "bottom",
  41706. tittle: this.getHRDate(this.data.pickupdate)
  41707. }
  41708. },
  41709. [
  41710. _vm._v(
  41711. "\n " +
  41712. _vm._s(
  41713. Math.floor(this.daysSinceToday(this.data.pickupdate))
  41714. ) +
  41715. " days ago\n "
  41716. )
  41717. ]
  41718. )
  41719. : _vm._e()
  41720. ]),
  41721. _vm._v(" "),
  41722. _c("p", [
  41723. _vm._v("Accessories: "),
  41724. _c("span", { domProps: { textContent: _vm._s(this.data.custassets) } })
  41725. ])
  41726. ])
  41727. }
  41728. var staticRenderFns = []
  41729. render._withStripped = true
  41730. /***/ }),
  41731. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41732. /*!********************************************************************!*\
  41733. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41734. \********************************************************************/
  41735. /*! exports provided: default */
  41736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41737. "use strict";
  41738. __webpack_require__.r(__webpack_exports__);
  41739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41740. /* globals __VUE_SSR_CONTEXT__ */
  41741. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41742. // This module is a runtime utility for cleaner component module output and will
  41743. // be included in the final webpack user bundle.
  41744. function normalizeComponent (
  41745. scriptExports,
  41746. render,
  41747. staticRenderFns,
  41748. functionalTemplate,
  41749. injectStyles,
  41750. scopeId,
  41751. moduleIdentifier, /* server only */
  41752. shadowMode /* vue-cli only */
  41753. ) {
  41754. // Vue.extend constructor export interop
  41755. var options = typeof scriptExports === 'function'
  41756. ? scriptExports.options
  41757. : scriptExports
  41758. // render functions
  41759. if (render) {
  41760. options.render = render
  41761. options.staticRenderFns = staticRenderFns
  41762. options._compiled = true
  41763. }
  41764. // functional template
  41765. if (functionalTemplate) {
  41766. options.functional = true
  41767. }
  41768. // scopedId
  41769. if (scopeId) {
  41770. options._scopeId = 'data-v-' + scopeId
  41771. }
  41772. var hook
  41773. if (moduleIdentifier) { // server build
  41774. hook = function (context) {
  41775. // 2.3 injection
  41776. context =
  41777. context || // cached call
  41778. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41779. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41780. // 2.2 with runInNewContext: true
  41781. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41782. context = __VUE_SSR_CONTEXT__
  41783. }
  41784. // inject component styles
  41785. if (injectStyles) {
  41786. injectStyles.call(this, context)
  41787. }
  41788. // register component module identifier for async chunk inferrence
  41789. if (context && context._registeredComponents) {
  41790. context._registeredComponents.add(moduleIdentifier)
  41791. }
  41792. }
  41793. // used by ssr in case component is cached and beforeCreate
  41794. // never gets called
  41795. options._ssrRegister = hook
  41796. } else if (injectStyles) {
  41797. hook = shadowMode
  41798. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41799. : injectStyles
  41800. }
  41801. if (hook) {
  41802. if (options.functional) {
  41803. // for template-only hot-reload because in that case the render fn doesn't
  41804. // go through the normalizer
  41805. options._injectStyles = hook
  41806. // register for functioal component in vue file
  41807. var originalRender = options.render
  41808. options.render = function renderWithStyleInjection (h, context) {
  41809. hook.call(context)
  41810. return originalRender(h, context)
  41811. }
  41812. } else {
  41813. // inject component registration as beforeCreate hook
  41814. var existing = options.beforeCreate
  41815. options.beforeCreate = existing
  41816. ? [].concat(existing, hook)
  41817. : [hook]
  41818. }
  41819. }
  41820. return {
  41821. exports: scriptExports,
  41822. options: options
  41823. }
  41824. }
  41825. /***/ }),
  41826. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41827. /*!*************************************************!*\
  41828. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41829. \*************************************************/
  41830. /*! no static exports found */
  41831. /***/ (function(module, exports, __webpack_require__) {
  41832. "use strict";
  41833. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41834. * Vue.js v2.6.11
  41835. * (c) 2014-2019 Evan You
  41836. * Released under the MIT License.
  41837. */
  41838. /* */
  41839. var emptyObject = Object.freeze({});
  41840. // These helpers produce better VM code in JS engines due to their
  41841. // explicitness and function inlining.
  41842. function isUndef (v) {
  41843. return v === undefined || v === null
  41844. }
  41845. function isDef (v) {
  41846. return v !== undefined && v !== null
  41847. }
  41848. function isTrue (v) {
  41849. return v === true
  41850. }
  41851. function isFalse (v) {
  41852. return v === false
  41853. }
  41854. /**
  41855. * Check if value is primitive.
  41856. */
  41857. function isPrimitive (value) {
  41858. return (
  41859. typeof value === 'string' ||
  41860. typeof value === 'number' ||
  41861. // $flow-disable-line
  41862. typeof value === 'symbol' ||
  41863. typeof value === 'boolean'
  41864. )
  41865. }
  41866. /**
  41867. * Quick object check - this is primarily used to tell
  41868. * Objects from primitive values when we know the value
  41869. * is a JSON-compliant type.
  41870. */
  41871. function isObject (obj) {
  41872. return obj !== null && typeof obj === 'object'
  41873. }
  41874. /**
  41875. * Get the raw type string of a value, e.g., [object Object].
  41876. */
  41877. var _toString = Object.prototype.toString;
  41878. function toRawType (value) {
  41879. return _toString.call(value).slice(8, -1)
  41880. }
  41881. /**
  41882. * Strict object type check. Only returns true
  41883. * for plain JavaScript objects.
  41884. */
  41885. function isPlainObject (obj) {
  41886. return _toString.call(obj) === '[object Object]'
  41887. }
  41888. function isRegExp (v) {
  41889. return _toString.call(v) === '[object RegExp]'
  41890. }
  41891. /**
  41892. * Check if val is a valid array index.
  41893. */
  41894. function isValidArrayIndex (val) {
  41895. var n = parseFloat(String(val));
  41896. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41897. }
  41898. function isPromise (val) {
  41899. return (
  41900. isDef(val) &&
  41901. typeof val.then === 'function' &&
  41902. typeof val.catch === 'function'
  41903. )
  41904. }
  41905. /**
  41906. * Convert a value to a string that is actually rendered.
  41907. */
  41908. function toString (val) {
  41909. return val == null
  41910. ? ''
  41911. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  41912. ? JSON.stringify(val, null, 2)
  41913. : String(val)
  41914. }
  41915. /**
  41916. * Convert an input value to a number for persistence.
  41917. * If the conversion fails, return original string.
  41918. */
  41919. function toNumber (val) {
  41920. var n = parseFloat(val);
  41921. return isNaN(n) ? val : n
  41922. }
  41923. /**
  41924. * Make a map and return a function for checking if a key
  41925. * is in that map.
  41926. */
  41927. function makeMap (
  41928. str,
  41929. expectsLowerCase
  41930. ) {
  41931. var map = Object.create(null);
  41932. var list = str.split(',');
  41933. for (var i = 0; i < list.length; i++) {
  41934. map[list[i]] = true;
  41935. }
  41936. return expectsLowerCase
  41937. ? function (val) { return map[val.toLowerCase()]; }
  41938. : function (val) { return map[val]; }
  41939. }
  41940. /**
  41941. * Check if a tag is a built-in tag.
  41942. */
  41943. var isBuiltInTag = makeMap('slot,component', true);
  41944. /**
  41945. * Check if an attribute is a reserved attribute.
  41946. */
  41947. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  41948. /**
  41949. * Remove an item from an array.
  41950. */
  41951. function remove (arr, item) {
  41952. if (arr.length) {
  41953. var index = arr.indexOf(item);
  41954. if (index > -1) {
  41955. return arr.splice(index, 1)
  41956. }
  41957. }
  41958. }
  41959. /**
  41960. * Check whether an object has the property.
  41961. */
  41962. var hasOwnProperty = Object.prototype.hasOwnProperty;
  41963. function hasOwn (obj, key) {
  41964. return hasOwnProperty.call(obj, key)
  41965. }
  41966. /**
  41967. * Create a cached version of a pure function.
  41968. */
  41969. function cached (fn) {
  41970. var cache = Object.create(null);
  41971. return (function cachedFn (str) {
  41972. var hit = cache[str];
  41973. return hit || (cache[str] = fn(str))
  41974. })
  41975. }
  41976. /**
  41977. * Camelize a hyphen-delimited string.
  41978. */
  41979. var camelizeRE = /-(\w)/g;
  41980. var camelize = cached(function (str) {
  41981. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  41982. });
  41983. /**
  41984. * Capitalize a string.
  41985. */
  41986. var capitalize = cached(function (str) {
  41987. return str.charAt(0).toUpperCase() + str.slice(1)
  41988. });
  41989. /**
  41990. * Hyphenate a camelCase string.
  41991. */
  41992. var hyphenateRE = /\B([A-Z])/g;
  41993. var hyphenate = cached(function (str) {
  41994. return str.replace(hyphenateRE, '-$1').toLowerCase()
  41995. });
  41996. /**
  41997. * Simple bind polyfill for environments that do not support it,
  41998. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  41999. * since native bind is now performant enough in most browsers.
  42000. * But removing it would mean breaking code that was able to run in
  42001. * PhantomJS 1.x, so this must be kept for backward compatibility.
  42002. */
  42003. /* istanbul ignore next */
  42004. function polyfillBind (fn, ctx) {
  42005. function boundFn (a) {
  42006. var l = arguments.length;
  42007. return l
  42008. ? l > 1
  42009. ? fn.apply(ctx, arguments)
  42010. : fn.call(ctx, a)
  42011. : fn.call(ctx)
  42012. }
  42013. boundFn._length = fn.length;
  42014. return boundFn
  42015. }
  42016. function nativeBind (fn, ctx) {
  42017. return fn.bind(ctx)
  42018. }
  42019. var bind = Function.prototype.bind
  42020. ? nativeBind
  42021. : polyfillBind;
  42022. /**
  42023. * Convert an Array-like object to a real Array.
  42024. */
  42025. function toArray (list, start) {
  42026. start = start || 0;
  42027. var i = list.length - start;
  42028. var ret = new Array(i);
  42029. while (i--) {
  42030. ret[i] = list[i + start];
  42031. }
  42032. return ret
  42033. }
  42034. /**
  42035. * Mix properties into target object.
  42036. */
  42037. function extend (to, _from) {
  42038. for (var key in _from) {
  42039. to[key] = _from[key];
  42040. }
  42041. return to
  42042. }
  42043. /**
  42044. * Merge an Array of Objects into a single Object.
  42045. */
  42046. function toObject (arr) {
  42047. var res = {};
  42048. for (var i = 0; i < arr.length; i++) {
  42049. if (arr[i]) {
  42050. extend(res, arr[i]);
  42051. }
  42052. }
  42053. return res
  42054. }
  42055. /* eslint-disable no-unused-vars */
  42056. /**
  42057. * Perform no operation.
  42058. * Stubbing args to make Flow happy without leaving useless transpiled code
  42059. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  42060. */
  42061. function noop (a, b, c) {}
  42062. /**
  42063. * Always return false.
  42064. */
  42065. var no = function (a, b, c) { return false; };
  42066. /* eslint-enable no-unused-vars */
  42067. /**
  42068. * Return the same value.
  42069. */
  42070. var identity = function (_) { return _; };
  42071. /**
  42072. * Generate a string containing static keys from compiler modules.
  42073. */
  42074. function genStaticKeys (modules) {
  42075. return modules.reduce(function (keys, m) {
  42076. return keys.concat(m.staticKeys || [])
  42077. }, []).join(',')
  42078. }
  42079. /**
  42080. * Check if two values are loosely equal - that is,
  42081. * if they are plain objects, do they have the same shape?
  42082. */
  42083. function looseEqual (a, b) {
  42084. if (a === b) { return true }
  42085. var isObjectA = isObject(a);
  42086. var isObjectB = isObject(b);
  42087. if (isObjectA && isObjectB) {
  42088. try {
  42089. var isArrayA = Array.isArray(a);
  42090. var isArrayB = Array.isArray(b);
  42091. if (isArrayA && isArrayB) {
  42092. return a.length === b.length && a.every(function (e, i) {
  42093. return looseEqual(e, b[i])
  42094. })
  42095. } else if (a instanceof Date && b instanceof Date) {
  42096. return a.getTime() === b.getTime()
  42097. } else if (!isArrayA && !isArrayB) {
  42098. var keysA = Object.keys(a);
  42099. var keysB = Object.keys(b);
  42100. return keysA.length === keysB.length && keysA.every(function (key) {
  42101. return looseEqual(a[key], b[key])
  42102. })
  42103. } else {
  42104. /* istanbul ignore next */
  42105. return false
  42106. }
  42107. } catch (e) {
  42108. /* istanbul ignore next */
  42109. return false
  42110. }
  42111. } else if (!isObjectA && !isObjectB) {
  42112. return String(a) === String(b)
  42113. } else {
  42114. return false
  42115. }
  42116. }
  42117. /**
  42118. * Return the first index at which a loosely equal value can be
  42119. * found in the array (if value is a plain object, the array must
  42120. * contain an object of the same shape), or -1 if it is not present.
  42121. */
  42122. function looseIndexOf (arr, val) {
  42123. for (var i = 0; i < arr.length; i++) {
  42124. if (looseEqual(arr[i], val)) { return i }
  42125. }
  42126. return -1
  42127. }
  42128. /**
  42129. * Ensure a function is called only once.
  42130. */
  42131. function once (fn) {
  42132. var called = false;
  42133. return function () {
  42134. if (!called) {
  42135. called = true;
  42136. fn.apply(this, arguments);
  42137. }
  42138. }
  42139. }
  42140. var SSR_ATTR = 'data-server-rendered';
  42141. var ASSET_TYPES = [
  42142. 'component',
  42143. 'directive',
  42144. 'filter'
  42145. ];
  42146. var LIFECYCLE_HOOKS = [
  42147. 'beforeCreate',
  42148. 'created',
  42149. 'beforeMount',
  42150. 'mounted',
  42151. 'beforeUpdate',
  42152. 'updated',
  42153. 'beforeDestroy',
  42154. 'destroyed',
  42155. 'activated',
  42156. 'deactivated',
  42157. 'errorCaptured',
  42158. 'serverPrefetch'
  42159. ];
  42160. /* */
  42161. var config = ({
  42162. /**
  42163. * Option merge strategies (used in core/util/options)
  42164. */
  42165. // $flow-disable-line
  42166. optionMergeStrategies: Object.create(null),
  42167. /**
  42168. * Whether to suppress warnings.
  42169. */
  42170. silent: false,
  42171. /**
  42172. * Show production mode tip message on boot?
  42173. */
  42174. productionTip: "development" !== 'production',
  42175. /**
  42176. * Whether to enable devtools
  42177. */
  42178. devtools: "development" !== 'production',
  42179. /**
  42180. * Whether to record perf
  42181. */
  42182. performance: false,
  42183. /**
  42184. * Error handler for watcher errors
  42185. */
  42186. errorHandler: null,
  42187. /**
  42188. * Warn handler for watcher warns
  42189. */
  42190. warnHandler: null,
  42191. /**
  42192. * Ignore certain custom elements
  42193. */
  42194. ignoredElements: [],
  42195. /**
  42196. * Custom user key aliases for v-on
  42197. */
  42198. // $flow-disable-line
  42199. keyCodes: Object.create(null),
  42200. /**
  42201. * Check if a tag is reserved so that it cannot be registered as a
  42202. * component. This is platform-dependent and may be overwritten.
  42203. */
  42204. isReservedTag: no,
  42205. /**
  42206. * Check if an attribute is reserved so that it cannot be used as a component
  42207. * prop. This is platform-dependent and may be overwritten.
  42208. */
  42209. isReservedAttr: no,
  42210. /**
  42211. * Check if a tag is an unknown element.
  42212. * Platform-dependent.
  42213. */
  42214. isUnknownElement: no,
  42215. /**
  42216. * Get the namespace of an element
  42217. */
  42218. getTagNamespace: noop,
  42219. /**
  42220. * Parse the real tag name for the specific platform.
  42221. */
  42222. parsePlatformTagName: identity,
  42223. /**
  42224. * Check if an attribute must be bound using property, e.g. value
  42225. * Platform-dependent.
  42226. */
  42227. mustUseProp: no,
  42228. /**
  42229. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42230. * This will significantly reduce performance if set to false.
  42231. */
  42232. async: true,
  42233. /**
  42234. * Exposed for legacy reasons
  42235. */
  42236. _lifecycleHooks: LIFECYCLE_HOOKS
  42237. });
  42238. /* */
  42239. /**
  42240. * unicode letters used for parsing html tags, component names and property paths.
  42241. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42242. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42243. */
  42244. 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/;
  42245. /**
  42246. * Check if a string starts with $ or _
  42247. */
  42248. function isReserved (str) {
  42249. var c = (str + '').charCodeAt(0);
  42250. return c === 0x24 || c === 0x5F
  42251. }
  42252. /**
  42253. * Define a property.
  42254. */
  42255. function def (obj, key, val, enumerable) {
  42256. Object.defineProperty(obj, key, {
  42257. value: val,
  42258. enumerable: !!enumerable,
  42259. writable: true,
  42260. configurable: true
  42261. });
  42262. }
  42263. /**
  42264. * Parse simple path.
  42265. */
  42266. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42267. function parsePath (path) {
  42268. if (bailRE.test(path)) {
  42269. return
  42270. }
  42271. var segments = path.split('.');
  42272. return function (obj) {
  42273. for (var i = 0; i < segments.length; i++) {
  42274. if (!obj) { return }
  42275. obj = obj[segments[i]];
  42276. }
  42277. return obj
  42278. }
  42279. }
  42280. /* */
  42281. // can we use __proto__?
  42282. var hasProto = '__proto__' in {};
  42283. // Browser environment sniffing
  42284. var inBrowser = typeof window !== 'undefined';
  42285. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42286. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42287. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42288. var isIE = UA && /msie|trident/.test(UA);
  42289. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42290. var isEdge = UA && UA.indexOf('edge/') > 0;
  42291. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42292. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42293. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42294. var isPhantomJS = UA && /phantomjs/.test(UA);
  42295. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42296. // Firefox has a "watch" function on Object.prototype...
  42297. var nativeWatch = ({}).watch;
  42298. var supportsPassive = false;
  42299. if (inBrowser) {
  42300. try {
  42301. var opts = {};
  42302. Object.defineProperty(opts, 'passive', ({
  42303. get: function get () {
  42304. /* istanbul ignore next */
  42305. supportsPassive = true;
  42306. }
  42307. })); // https://github.com/facebook/flow/issues/285
  42308. window.addEventListener('test-passive', null, opts);
  42309. } catch (e) {}
  42310. }
  42311. // this needs to be lazy-evaled because vue may be required before
  42312. // vue-server-renderer can set VUE_ENV
  42313. var _isServer;
  42314. var isServerRendering = function () {
  42315. if (_isServer === undefined) {
  42316. /* istanbul ignore if */
  42317. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42318. // detect presence of vue-server-renderer and avoid
  42319. // Webpack shimming the process
  42320. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42321. } else {
  42322. _isServer = false;
  42323. }
  42324. }
  42325. return _isServer
  42326. };
  42327. // detect devtools
  42328. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42329. /* istanbul ignore next */
  42330. function isNative (Ctor) {
  42331. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42332. }
  42333. var hasSymbol =
  42334. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42335. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42336. var _Set;
  42337. /* istanbul ignore if */ // $flow-disable-line
  42338. if (typeof Set !== 'undefined' && isNative(Set)) {
  42339. // use native Set when available.
  42340. _Set = Set;
  42341. } else {
  42342. // a non-standard Set polyfill that only works with primitive keys.
  42343. _Set = /*@__PURE__*/(function () {
  42344. function Set () {
  42345. this.set = Object.create(null);
  42346. }
  42347. Set.prototype.has = function has (key) {
  42348. return this.set[key] === true
  42349. };
  42350. Set.prototype.add = function add (key) {
  42351. this.set[key] = true;
  42352. };
  42353. Set.prototype.clear = function clear () {
  42354. this.set = Object.create(null);
  42355. };
  42356. return Set;
  42357. }());
  42358. }
  42359. /* */
  42360. var warn = noop;
  42361. var tip = noop;
  42362. var generateComponentTrace = (noop); // work around flow check
  42363. var formatComponentName = (noop);
  42364. {
  42365. var hasConsole = typeof console !== 'undefined';
  42366. var classifyRE = /(?:^|[-_])(\w)/g;
  42367. var classify = function (str) { return str
  42368. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42369. .replace(/[-_]/g, ''); };
  42370. warn = function (msg, vm) {
  42371. var trace = vm ? generateComponentTrace(vm) : '';
  42372. if (config.warnHandler) {
  42373. config.warnHandler.call(null, msg, vm, trace);
  42374. } else if (hasConsole && (!config.silent)) {
  42375. console.error(("[Vue warn]: " + msg + trace));
  42376. }
  42377. };
  42378. tip = function (msg, vm) {
  42379. if (hasConsole && (!config.silent)) {
  42380. console.warn("[Vue tip]: " + msg + (
  42381. vm ? generateComponentTrace(vm) : ''
  42382. ));
  42383. }
  42384. };
  42385. formatComponentName = function (vm, includeFile) {
  42386. if (vm.$root === vm) {
  42387. return '<Root>'
  42388. }
  42389. var options = typeof vm === 'function' && vm.cid != null
  42390. ? vm.options
  42391. : vm._isVue
  42392. ? vm.$options || vm.constructor.options
  42393. : vm;
  42394. var name = options.name || options._componentTag;
  42395. var file = options.__file;
  42396. if (!name && file) {
  42397. var match = file.match(/([^/\\]+)\.vue$/);
  42398. name = match && match[1];
  42399. }
  42400. return (
  42401. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42402. (file && includeFile !== false ? (" at " + file) : '')
  42403. )
  42404. };
  42405. var repeat = function (str, n) {
  42406. var res = '';
  42407. while (n) {
  42408. if (n % 2 === 1) { res += str; }
  42409. if (n > 1) { str += str; }
  42410. n >>= 1;
  42411. }
  42412. return res
  42413. };
  42414. generateComponentTrace = function (vm) {
  42415. if (vm._isVue && vm.$parent) {
  42416. var tree = [];
  42417. var currentRecursiveSequence = 0;
  42418. while (vm) {
  42419. if (tree.length > 0) {
  42420. var last = tree[tree.length - 1];
  42421. if (last.constructor === vm.constructor) {
  42422. currentRecursiveSequence++;
  42423. vm = vm.$parent;
  42424. continue
  42425. } else if (currentRecursiveSequence > 0) {
  42426. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42427. currentRecursiveSequence = 0;
  42428. }
  42429. }
  42430. tree.push(vm);
  42431. vm = vm.$parent;
  42432. }
  42433. return '\n\nfound in\n\n' + tree
  42434. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42435. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42436. : formatComponentName(vm))); })
  42437. .join('\n')
  42438. } else {
  42439. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42440. }
  42441. };
  42442. }
  42443. /* */
  42444. var uid = 0;
  42445. /**
  42446. * A dep is an observable that can have multiple
  42447. * directives subscribing to it.
  42448. */
  42449. var Dep = function Dep () {
  42450. this.id = uid++;
  42451. this.subs = [];
  42452. };
  42453. Dep.prototype.addSub = function addSub (sub) {
  42454. this.subs.push(sub);
  42455. };
  42456. Dep.prototype.removeSub = function removeSub (sub) {
  42457. remove(this.subs, sub);
  42458. };
  42459. Dep.prototype.depend = function depend () {
  42460. if (Dep.target) {
  42461. Dep.target.addDep(this);
  42462. }
  42463. };
  42464. Dep.prototype.notify = function notify () {
  42465. // stabilize the subscriber list first
  42466. var subs = this.subs.slice();
  42467. if (!config.async) {
  42468. // subs aren't sorted in scheduler if not running async
  42469. // we need to sort them now to make sure they fire in correct
  42470. // order
  42471. subs.sort(function (a, b) { return a.id - b.id; });
  42472. }
  42473. for (var i = 0, l = subs.length; i < l; i++) {
  42474. subs[i].update();
  42475. }
  42476. };
  42477. // The current target watcher being evaluated.
  42478. // This is globally unique because only one watcher
  42479. // can be evaluated at a time.
  42480. Dep.target = null;
  42481. var targetStack = [];
  42482. function pushTarget (target) {
  42483. targetStack.push(target);
  42484. Dep.target = target;
  42485. }
  42486. function popTarget () {
  42487. targetStack.pop();
  42488. Dep.target = targetStack[targetStack.length - 1];
  42489. }
  42490. /* */
  42491. var VNode = function VNode (
  42492. tag,
  42493. data,
  42494. children,
  42495. text,
  42496. elm,
  42497. context,
  42498. componentOptions,
  42499. asyncFactory
  42500. ) {
  42501. this.tag = tag;
  42502. this.data = data;
  42503. this.children = children;
  42504. this.text = text;
  42505. this.elm = elm;
  42506. this.ns = undefined;
  42507. this.context = context;
  42508. this.fnContext = undefined;
  42509. this.fnOptions = undefined;
  42510. this.fnScopeId = undefined;
  42511. this.key = data && data.key;
  42512. this.componentOptions = componentOptions;
  42513. this.componentInstance = undefined;
  42514. this.parent = undefined;
  42515. this.raw = false;
  42516. this.isStatic = false;
  42517. this.isRootInsert = true;
  42518. this.isComment = false;
  42519. this.isCloned = false;
  42520. this.isOnce = false;
  42521. this.asyncFactory = asyncFactory;
  42522. this.asyncMeta = undefined;
  42523. this.isAsyncPlaceholder = false;
  42524. };
  42525. var prototypeAccessors = { child: { configurable: true } };
  42526. // DEPRECATED: alias for componentInstance for backwards compat.
  42527. /* istanbul ignore next */
  42528. prototypeAccessors.child.get = function () {
  42529. return this.componentInstance
  42530. };
  42531. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42532. var createEmptyVNode = function (text) {
  42533. if ( text === void 0 ) text = '';
  42534. var node = new VNode();
  42535. node.text = text;
  42536. node.isComment = true;
  42537. return node
  42538. };
  42539. function createTextVNode (val) {
  42540. return new VNode(undefined, undefined, undefined, String(val))
  42541. }
  42542. // optimized shallow clone
  42543. // used for static nodes and slot nodes because they may be reused across
  42544. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42545. // on their elm reference.
  42546. function cloneVNode (vnode) {
  42547. var cloned = new VNode(
  42548. vnode.tag,
  42549. vnode.data,
  42550. // #7975
  42551. // clone children array to avoid mutating original in case of cloning
  42552. // a child.
  42553. vnode.children && vnode.children.slice(),
  42554. vnode.text,
  42555. vnode.elm,
  42556. vnode.context,
  42557. vnode.componentOptions,
  42558. vnode.asyncFactory
  42559. );
  42560. cloned.ns = vnode.ns;
  42561. cloned.isStatic = vnode.isStatic;
  42562. cloned.key = vnode.key;
  42563. cloned.isComment = vnode.isComment;
  42564. cloned.fnContext = vnode.fnContext;
  42565. cloned.fnOptions = vnode.fnOptions;
  42566. cloned.fnScopeId = vnode.fnScopeId;
  42567. cloned.asyncMeta = vnode.asyncMeta;
  42568. cloned.isCloned = true;
  42569. return cloned
  42570. }
  42571. /*
  42572. * not type checking this file because flow doesn't play well with
  42573. * dynamically accessing methods on Array prototype
  42574. */
  42575. var arrayProto = Array.prototype;
  42576. var arrayMethods = Object.create(arrayProto);
  42577. var methodsToPatch = [
  42578. 'push',
  42579. 'pop',
  42580. 'shift',
  42581. 'unshift',
  42582. 'splice',
  42583. 'sort',
  42584. 'reverse'
  42585. ];
  42586. /**
  42587. * Intercept mutating methods and emit events
  42588. */
  42589. methodsToPatch.forEach(function (method) {
  42590. // cache original method
  42591. var original = arrayProto[method];
  42592. def(arrayMethods, method, function mutator () {
  42593. var args = [], len = arguments.length;
  42594. while ( len-- ) args[ len ] = arguments[ len ];
  42595. var result = original.apply(this, args);
  42596. var ob = this.__ob__;
  42597. var inserted;
  42598. switch (method) {
  42599. case 'push':
  42600. case 'unshift':
  42601. inserted = args;
  42602. break
  42603. case 'splice':
  42604. inserted = args.slice(2);
  42605. break
  42606. }
  42607. if (inserted) { ob.observeArray(inserted); }
  42608. // notify change
  42609. ob.dep.notify();
  42610. return result
  42611. });
  42612. });
  42613. /* */
  42614. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42615. /**
  42616. * In some cases we may want to disable observation inside a component's
  42617. * update computation.
  42618. */
  42619. var shouldObserve = true;
  42620. function toggleObserving (value) {
  42621. shouldObserve = value;
  42622. }
  42623. /**
  42624. * Observer class that is attached to each observed
  42625. * object. Once attached, the observer converts the target
  42626. * object's property keys into getter/setters that
  42627. * collect dependencies and dispatch updates.
  42628. */
  42629. var Observer = function Observer (value) {
  42630. this.value = value;
  42631. this.dep = new Dep();
  42632. this.vmCount = 0;
  42633. def(value, '__ob__', this);
  42634. if (Array.isArray(value)) {
  42635. if (hasProto) {
  42636. protoAugment(value, arrayMethods);
  42637. } else {
  42638. copyAugment(value, arrayMethods, arrayKeys);
  42639. }
  42640. this.observeArray(value);
  42641. } else {
  42642. this.walk(value);
  42643. }
  42644. };
  42645. /**
  42646. * Walk through all properties and convert them into
  42647. * getter/setters. This method should only be called when
  42648. * value type is Object.
  42649. */
  42650. Observer.prototype.walk = function walk (obj) {
  42651. var keys = Object.keys(obj);
  42652. for (var i = 0; i < keys.length; i++) {
  42653. defineReactive$$1(obj, keys[i]);
  42654. }
  42655. };
  42656. /**
  42657. * Observe a list of Array items.
  42658. */
  42659. Observer.prototype.observeArray = function observeArray (items) {
  42660. for (var i = 0, l = items.length; i < l; i++) {
  42661. observe(items[i]);
  42662. }
  42663. };
  42664. // helpers
  42665. /**
  42666. * Augment a target Object or Array by intercepting
  42667. * the prototype chain using __proto__
  42668. */
  42669. function protoAugment (target, src) {
  42670. /* eslint-disable no-proto */
  42671. target.__proto__ = src;
  42672. /* eslint-enable no-proto */
  42673. }
  42674. /**
  42675. * Augment a target Object or Array by defining
  42676. * hidden properties.
  42677. */
  42678. /* istanbul ignore next */
  42679. function copyAugment (target, src, keys) {
  42680. for (var i = 0, l = keys.length; i < l; i++) {
  42681. var key = keys[i];
  42682. def(target, key, src[key]);
  42683. }
  42684. }
  42685. /**
  42686. * Attempt to create an observer instance for a value,
  42687. * returns the new observer if successfully observed,
  42688. * or the existing observer if the value already has one.
  42689. */
  42690. function observe (value, asRootData) {
  42691. if (!isObject(value) || value instanceof VNode) {
  42692. return
  42693. }
  42694. var ob;
  42695. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42696. ob = value.__ob__;
  42697. } else if (
  42698. shouldObserve &&
  42699. !isServerRendering() &&
  42700. (Array.isArray(value) || isPlainObject(value)) &&
  42701. Object.isExtensible(value) &&
  42702. !value._isVue
  42703. ) {
  42704. ob = new Observer(value);
  42705. }
  42706. if (asRootData && ob) {
  42707. ob.vmCount++;
  42708. }
  42709. return ob
  42710. }
  42711. /**
  42712. * Define a reactive property on an Object.
  42713. */
  42714. function defineReactive$$1 (
  42715. obj,
  42716. key,
  42717. val,
  42718. customSetter,
  42719. shallow
  42720. ) {
  42721. var dep = new Dep();
  42722. var property = Object.getOwnPropertyDescriptor(obj, key);
  42723. if (property && property.configurable === false) {
  42724. return
  42725. }
  42726. // cater for pre-defined getter/setters
  42727. var getter = property && property.get;
  42728. var setter = property && property.set;
  42729. if ((!getter || setter) && arguments.length === 2) {
  42730. val = obj[key];
  42731. }
  42732. var childOb = !shallow && observe(val);
  42733. Object.defineProperty(obj, key, {
  42734. enumerable: true,
  42735. configurable: true,
  42736. get: function reactiveGetter () {
  42737. var value = getter ? getter.call(obj) : val;
  42738. if (Dep.target) {
  42739. dep.depend();
  42740. if (childOb) {
  42741. childOb.dep.depend();
  42742. if (Array.isArray(value)) {
  42743. dependArray(value);
  42744. }
  42745. }
  42746. }
  42747. return value
  42748. },
  42749. set: function reactiveSetter (newVal) {
  42750. var value = getter ? getter.call(obj) : val;
  42751. /* eslint-disable no-self-compare */
  42752. if (newVal === value || (newVal !== newVal && value !== value)) {
  42753. return
  42754. }
  42755. /* eslint-enable no-self-compare */
  42756. if (customSetter) {
  42757. customSetter();
  42758. }
  42759. // #7981: for accessor properties without setter
  42760. if (getter && !setter) { return }
  42761. if (setter) {
  42762. setter.call(obj, newVal);
  42763. } else {
  42764. val = newVal;
  42765. }
  42766. childOb = !shallow && observe(newVal);
  42767. dep.notify();
  42768. }
  42769. });
  42770. }
  42771. /**
  42772. * Set a property on an object. Adds the new property and
  42773. * triggers change notification if the property doesn't
  42774. * already exist.
  42775. */
  42776. function set (target, key, val) {
  42777. if (isUndef(target) || isPrimitive(target)
  42778. ) {
  42779. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42780. }
  42781. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42782. target.length = Math.max(target.length, key);
  42783. target.splice(key, 1, val);
  42784. return val
  42785. }
  42786. if (key in target && !(key in Object.prototype)) {
  42787. target[key] = val;
  42788. return val
  42789. }
  42790. var ob = (target).__ob__;
  42791. if (target._isVue || (ob && ob.vmCount)) {
  42792. warn(
  42793. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42794. 'at runtime - declare it upfront in the data option.'
  42795. );
  42796. return val
  42797. }
  42798. if (!ob) {
  42799. target[key] = val;
  42800. return val
  42801. }
  42802. defineReactive$$1(ob.value, key, val);
  42803. ob.dep.notify();
  42804. return val
  42805. }
  42806. /**
  42807. * Delete a property and trigger change if necessary.
  42808. */
  42809. function del (target, key) {
  42810. if (isUndef(target) || isPrimitive(target)
  42811. ) {
  42812. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42813. }
  42814. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42815. target.splice(key, 1);
  42816. return
  42817. }
  42818. var ob = (target).__ob__;
  42819. if (target._isVue || (ob && ob.vmCount)) {
  42820. warn(
  42821. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42822. '- just set it to null.'
  42823. );
  42824. return
  42825. }
  42826. if (!hasOwn(target, key)) {
  42827. return
  42828. }
  42829. delete target[key];
  42830. if (!ob) {
  42831. return
  42832. }
  42833. ob.dep.notify();
  42834. }
  42835. /**
  42836. * Collect dependencies on array elements when the array is touched, since
  42837. * we cannot intercept array element access like property getters.
  42838. */
  42839. function dependArray (value) {
  42840. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42841. e = value[i];
  42842. e && e.__ob__ && e.__ob__.dep.depend();
  42843. if (Array.isArray(e)) {
  42844. dependArray(e);
  42845. }
  42846. }
  42847. }
  42848. /* */
  42849. /**
  42850. * Option overwriting strategies are functions that handle
  42851. * how to merge a parent option value and a child option
  42852. * value into the final value.
  42853. */
  42854. var strats = config.optionMergeStrategies;
  42855. /**
  42856. * Options with restrictions
  42857. */
  42858. {
  42859. strats.el = strats.propsData = function (parent, child, vm, key) {
  42860. if (!vm) {
  42861. warn(
  42862. "option \"" + key + "\" can only be used during instance " +
  42863. 'creation with the `new` keyword.'
  42864. );
  42865. }
  42866. return defaultStrat(parent, child)
  42867. };
  42868. }
  42869. /**
  42870. * Helper that recursively merges two data objects together.
  42871. */
  42872. function mergeData (to, from) {
  42873. if (!from) { return to }
  42874. var key, toVal, fromVal;
  42875. var keys = hasSymbol
  42876. ? Reflect.ownKeys(from)
  42877. : Object.keys(from);
  42878. for (var i = 0; i < keys.length; i++) {
  42879. key = keys[i];
  42880. // in case the object is already observed...
  42881. if (key === '__ob__') { continue }
  42882. toVal = to[key];
  42883. fromVal = from[key];
  42884. if (!hasOwn(to, key)) {
  42885. set(to, key, fromVal);
  42886. } else if (
  42887. toVal !== fromVal &&
  42888. isPlainObject(toVal) &&
  42889. isPlainObject(fromVal)
  42890. ) {
  42891. mergeData(toVal, fromVal);
  42892. }
  42893. }
  42894. return to
  42895. }
  42896. /**
  42897. * Data
  42898. */
  42899. function mergeDataOrFn (
  42900. parentVal,
  42901. childVal,
  42902. vm
  42903. ) {
  42904. if (!vm) {
  42905. // in a Vue.extend merge, both should be functions
  42906. if (!childVal) {
  42907. return parentVal
  42908. }
  42909. if (!parentVal) {
  42910. return childVal
  42911. }
  42912. // when parentVal & childVal are both present,
  42913. // we need to return a function that returns the
  42914. // merged result of both functions... no need to
  42915. // check if parentVal is a function here because
  42916. // it has to be a function to pass previous merges.
  42917. return function mergedDataFn () {
  42918. return mergeData(
  42919. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  42920. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  42921. )
  42922. }
  42923. } else {
  42924. return function mergedInstanceDataFn () {
  42925. // instance merge
  42926. var instanceData = typeof childVal === 'function'
  42927. ? childVal.call(vm, vm)
  42928. : childVal;
  42929. var defaultData = typeof parentVal === 'function'
  42930. ? parentVal.call(vm, vm)
  42931. : parentVal;
  42932. if (instanceData) {
  42933. return mergeData(instanceData, defaultData)
  42934. } else {
  42935. return defaultData
  42936. }
  42937. }
  42938. }
  42939. }
  42940. strats.data = function (
  42941. parentVal,
  42942. childVal,
  42943. vm
  42944. ) {
  42945. if (!vm) {
  42946. if (childVal && typeof childVal !== 'function') {
  42947. warn(
  42948. 'The "data" option should be a function ' +
  42949. 'that returns a per-instance value in component ' +
  42950. 'definitions.',
  42951. vm
  42952. );
  42953. return parentVal
  42954. }
  42955. return mergeDataOrFn(parentVal, childVal)
  42956. }
  42957. return mergeDataOrFn(parentVal, childVal, vm)
  42958. };
  42959. /**
  42960. * Hooks and props are merged as arrays.
  42961. */
  42962. function mergeHook (
  42963. parentVal,
  42964. childVal
  42965. ) {
  42966. var res = childVal
  42967. ? parentVal
  42968. ? parentVal.concat(childVal)
  42969. : Array.isArray(childVal)
  42970. ? childVal
  42971. : [childVal]
  42972. : parentVal;
  42973. return res
  42974. ? dedupeHooks(res)
  42975. : res
  42976. }
  42977. function dedupeHooks (hooks) {
  42978. var res = [];
  42979. for (var i = 0; i < hooks.length; i++) {
  42980. if (res.indexOf(hooks[i]) === -1) {
  42981. res.push(hooks[i]);
  42982. }
  42983. }
  42984. return res
  42985. }
  42986. LIFECYCLE_HOOKS.forEach(function (hook) {
  42987. strats[hook] = mergeHook;
  42988. });
  42989. /**
  42990. * Assets
  42991. *
  42992. * When a vm is present (instance creation), we need to do
  42993. * a three-way merge between constructor options, instance
  42994. * options and parent options.
  42995. */
  42996. function mergeAssets (
  42997. parentVal,
  42998. childVal,
  42999. vm,
  43000. key
  43001. ) {
  43002. var res = Object.create(parentVal || null);
  43003. if (childVal) {
  43004. assertObjectType(key, childVal, vm);
  43005. return extend(res, childVal)
  43006. } else {
  43007. return res
  43008. }
  43009. }
  43010. ASSET_TYPES.forEach(function (type) {
  43011. strats[type + 's'] = mergeAssets;
  43012. });
  43013. /**
  43014. * Watchers.
  43015. *
  43016. * Watchers hashes should not overwrite one
  43017. * another, so we merge them as arrays.
  43018. */
  43019. strats.watch = function (
  43020. parentVal,
  43021. childVal,
  43022. vm,
  43023. key
  43024. ) {
  43025. // work around Firefox's Object.prototype.watch...
  43026. if (parentVal === nativeWatch) { parentVal = undefined; }
  43027. if (childVal === nativeWatch) { childVal = undefined; }
  43028. /* istanbul ignore if */
  43029. if (!childVal) { return Object.create(parentVal || null) }
  43030. {
  43031. assertObjectType(key, childVal, vm);
  43032. }
  43033. if (!parentVal) { return childVal }
  43034. var ret = {};
  43035. extend(ret, parentVal);
  43036. for (var key$1 in childVal) {
  43037. var parent = ret[key$1];
  43038. var child = childVal[key$1];
  43039. if (parent && !Array.isArray(parent)) {
  43040. parent = [parent];
  43041. }
  43042. ret[key$1] = parent
  43043. ? parent.concat(child)
  43044. : Array.isArray(child) ? child : [child];
  43045. }
  43046. return ret
  43047. };
  43048. /**
  43049. * Other object hashes.
  43050. */
  43051. strats.props =
  43052. strats.methods =
  43053. strats.inject =
  43054. strats.computed = function (
  43055. parentVal,
  43056. childVal,
  43057. vm,
  43058. key
  43059. ) {
  43060. if (childVal && "development" !== 'production') {
  43061. assertObjectType(key, childVal, vm);
  43062. }
  43063. if (!parentVal) { return childVal }
  43064. var ret = Object.create(null);
  43065. extend(ret, parentVal);
  43066. if (childVal) { extend(ret, childVal); }
  43067. return ret
  43068. };
  43069. strats.provide = mergeDataOrFn;
  43070. /**
  43071. * Default strategy.
  43072. */
  43073. var defaultStrat = function (parentVal, childVal) {
  43074. return childVal === undefined
  43075. ? parentVal
  43076. : childVal
  43077. };
  43078. /**
  43079. * Validate component names
  43080. */
  43081. function checkComponents (options) {
  43082. for (var key in options.components) {
  43083. validateComponentName(key);
  43084. }
  43085. }
  43086. function validateComponentName (name) {
  43087. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  43088. warn(
  43089. 'Invalid component name: "' + name + '". Component names ' +
  43090. 'should conform to valid custom element name in html5 specification.'
  43091. );
  43092. }
  43093. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  43094. warn(
  43095. 'Do not use built-in or reserved HTML elements as component ' +
  43096. 'id: ' + name
  43097. );
  43098. }
  43099. }
  43100. /**
  43101. * Ensure all props option syntax are normalized into the
  43102. * Object-based format.
  43103. */
  43104. function normalizeProps (options, vm) {
  43105. var props = options.props;
  43106. if (!props) { return }
  43107. var res = {};
  43108. var i, val, name;
  43109. if (Array.isArray(props)) {
  43110. i = props.length;
  43111. while (i--) {
  43112. val = props[i];
  43113. if (typeof val === 'string') {
  43114. name = camelize(val);
  43115. res[name] = { type: null };
  43116. } else {
  43117. warn('props must be strings when using array syntax.');
  43118. }
  43119. }
  43120. } else if (isPlainObject(props)) {
  43121. for (var key in props) {
  43122. val = props[key];
  43123. name = camelize(key);
  43124. res[name] = isPlainObject(val)
  43125. ? val
  43126. : { type: val };
  43127. }
  43128. } else {
  43129. warn(
  43130. "Invalid value for option \"props\": expected an Array or an Object, " +
  43131. "but got " + (toRawType(props)) + ".",
  43132. vm
  43133. );
  43134. }
  43135. options.props = res;
  43136. }
  43137. /**
  43138. * Normalize all injections into Object-based format
  43139. */
  43140. function normalizeInject (options, vm) {
  43141. var inject = options.inject;
  43142. if (!inject) { return }
  43143. var normalized = options.inject = {};
  43144. if (Array.isArray(inject)) {
  43145. for (var i = 0; i < inject.length; i++) {
  43146. normalized[inject[i]] = { from: inject[i] };
  43147. }
  43148. } else if (isPlainObject(inject)) {
  43149. for (var key in inject) {
  43150. var val = inject[key];
  43151. normalized[key] = isPlainObject(val)
  43152. ? extend({ from: key }, val)
  43153. : { from: val };
  43154. }
  43155. } else {
  43156. warn(
  43157. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43158. "but got " + (toRawType(inject)) + ".",
  43159. vm
  43160. );
  43161. }
  43162. }
  43163. /**
  43164. * Normalize raw function directives into object format.
  43165. */
  43166. function normalizeDirectives (options) {
  43167. var dirs = options.directives;
  43168. if (dirs) {
  43169. for (var key in dirs) {
  43170. var def$$1 = dirs[key];
  43171. if (typeof def$$1 === 'function') {
  43172. dirs[key] = { bind: def$$1, update: def$$1 };
  43173. }
  43174. }
  43175. }
  43176. }
  43177. function assertObjectType (name, value, vm) {
  43178. if (!isPlainObject(value)) {
  43179. warn(
  43180. "Invalid value for option \"" + name + "\": expected an Object, " +
  43181. "but got " + (toRawType(value)) + ".",
  43182. vm
  43183. );
  43184. }
  43185. }
  43186. /**
  43187. * Merge two option objects into a new one.
  43188. * Core utility used in both instantiation and inheritance.
  43189. */
  43190. function mergeOptions (
  43191. parent,
  43192. child,
  43193. vm
  43194. ) {
  43195. {
  43196. checkComponents(child);
  43197. }
  43198. if (typeof child === 'function') {
  43199. child = child.options;
  43200. }
  43201. normalizeProps(child, vm);
  43202. normalizeInject(child, vm);
  43203. normalizeDirectives(child);
  43204. // Apply extends and mixins on the child options,
  43205. // but only if it is a raw options object that isn't
  43206. // the result of another mergeOptions call.
  43207. // Only merged options has the _base property.
  43208. if (!child._base) {
  43209. if (child.extends) {
  43210. parent = mergeOptions(parent, child.extends, vm);
  43211. }
  43212. if (child.mixins) {
  43213. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43214. parent = mergeOptions(parent, child.mixins[i], vm);
  43215. }
  43216. }
  43217. }
  43218. var options = {};
  43219. var key;
  43220. for (key in parent) {
  43221. mergeField(key);
  43222. }
  43223. for (key in child) {
  43224. if (!hasOwn(parent, key)) {
  43225. mergeField(key);
  43226. }
  43227. }
  43228. function mergeField (key) {
  43229. var strat = strats[key] || defaultStrat;
  43230. options[key] = strat(parent[key], child[key], vm, key);
  43231. }
  43232. return options
  43233. }
  43234. /**
  43235. * Resolve an asset.
  43236. * This function is used because child instances need access
  43237. * to assets defined in its ancestor chain.
  43238. */
  43239. function resolveAsset (
  43240. options,
  43241. type,
  43242. id,
  43243. warnMissing
  43244. ) {
  43245. /* istanbul ignore if */
  43246. if (typeof id !== 'string') {
  43247. return
  43248. }
  43249. var assets = options[type];
  43250. // check local registration variations first
  43251. if (hasOwn(assets, id)) { return assets[id] }
  43252. var camelizedId = camelize(id);
  43253. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43254. var PascalCaseId = capitalize(camelizedId);
  43255. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43256. // fallback to prototype chain
  43257. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43258. if (warnMissing && !res) {
  43259. warn(
  43260. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43261. options
  43262. );
  43263. }
  43264. return res
  43265. }
  43266. /* */
  43267. function validateProp (
  43268. key,
  43269. propOptions,
  43270. propsData,
  43271. vm
  43272. ) {
  43273. var prop = propOptions[key];
  43274. var absent = !hasOwn(propsData, key);
  43275. var value = propsData[key];
  43276. // boolean casting
  43277. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43278. if (booleanIndex > -1) {
  43279. if (absent && !hasOwn(prop, 'default')) {
  43280. value = false;
  43281. } else if (value === '' || value === hyphenate(key)) {
  43282. // only cast empty string / same name to boolean if
  43283. // boolean has higher priority
  43284. var stringIndex = getTypeIndex(String, prop.type);
  43285. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43286. value = true;
  43287. }
  43288. }
  43289. }
  43290. // check default value
  43291. if (value === undefined) {
  43292. value = getPropDefaultValue(vm, prop, key);
  43293. // since the default value is a fresh copy,
  43294. // make sure to observe it.
  43295. var prevShouldObserve = shouldObserve;
  43296. toggleObserving(true);
  43297. observe(value);
  43298. toggleObserving(prevShouldObserve);
  43299. }
  43300. {
  43301. assertProp(prop, key, value, vm, absent);
  43302. }
  43303. return value
  43304. }
  43305. /**
  43306. * Get the default value of a prop.
  43307. */
  43308. function getPropDefaultValue (vm, prop, key) {
  43309. // no default, return undefined
  43310. if (!hasOwn(prop, 'default')) {
  43311. return undefined
  43312. }
  43313. var def = prop.default;
  43314. // warn against non-factory defaults for Object & Array
  43315. if (isObject(def)) {
  43316. warn(
  43317. 'Invalid default value for prop "' + key + '": ' +
  43318. 'Props with type Object/Array must use a factory function ' +
  43319. 'to return the default value.',
  43320. vm
  43321. );
  43322. }
  43323. // the raw prop value was also undefined from previous render,
  43324. // return previous default value to avoid unnecessary watcher trigger
  43325. if (vm && vm.$options.propsData &&
  43326. vm.$options.propsData[key] === undefined &&
  43327. vm._props[key] !== undefined
  43328. ) {
  43329. return vm._props[key]
  43330. }
  43331. // call factory function for non-Function types
  43332. // a value is Function if its prototype is function even across different execution context
  43333. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43334. ? def.call(vm)
  43335. : def
  43336. }
  43337. /**
  43338. * Assert whether a prop is valid.
  43339. */
  43340. function assertProp (
  43341. prop,
  43342. name,
  43343. value,
  43344. vm,
  43345. absent
  43346. ) {
  43347. if (prop.required && absent) {
  43348. warn(
  43349. 'Missing required prop: "' + name + '"',
  43350. vm
  43351. );
  43352. return
  43353. }
  43354. if (value == null && !prop.required) {
  43355. return
  43356. }
  43357. var type = prop.type;
  43358. var valid = !type || type === true;
  43359. var expectedTypes = [];
  43360. if (type) {
  43361. if (!Array.isArray(type)) {
  43362. type = [type];
  43363. }
  43364. for (var i = 0; i < type.length && !valid; i++) {
  43365. var assertedType = assertType(value, type[i]);
  43366. expectedTypes.push(assertedType.expectedType || '');
  43367. valid = assertedType.valid;
  43368. }
  43369. }
  43370. if (!valid) {
  43371. warn(
  43372. getInvalidTypeMessage(name, value, expectedTypes),
  43373. vm
  43374. );
  43375. return
  43376. }
  43377. var validator = prop.validator;
  43378. if (validator) {
  43379. if (!validator(value)) {
  43380. warn(
  43381. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43382. vm
  43383. );
  43384. }
  43385. }
  43386. }
  43387. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43388. function assertType (value, type) {
  43389. var valid;
  43390. var expectedType = getType(type);
  43391. if (simpleCheckRE.test(expectedType)) {
  43392. var t = typeof value;
  43393. valid = t === expectedType.toLowerCase();
  43394. // for primitive wrapper objects
  43395. if (!valid && t === 'object') {
  43396. valid = value instanceof type;
  43397. }
  43398. } else if (expectedType === 'Object') {
  43399. valid = isPlainObject(value);
  43400. } else if (expectedType === 'Array') {
  43401. valid = Array.isArray(value);
  43402. } else {
  43403. valid = value instanceof type;
  43404. }
  43405. return {
  43406. valid: valid,
  43407. expectedType: expectedType
  43408. }
  43409. }
  43410. /**
  43411. * Use function string name to check built-in types,
  43412. * because a simple equality check will fail when running
  43413. * across different vms / iframes.
  43414. */
  43415. function getType (fn) {
  43416. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43417. return match ? match[1] : ''
  43418. }
  43419. function isSameType (a, b) {
  43420. return getType(a) === getType(b)
  43421. }
  43422. function getTypeIndex (type, expectedTypes) {
  43423. if (!Array.isArray(expectedTypes)) {
  43424. return isSameType(expectedTypes, type) ? 0 : -1
  43425. }
  43426. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43427. if (isSameType(expectedTypes[i], type)) {
  43428. return i
  43429. }
  43430. }
  43431. return -1
  43432. }
  43433. function getInvalidTypeMessage (name, value, expectedTypes) {
  43434. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43435. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43436. var expectedType = expectedTypes[0];
  43437. var receivedType = toRawType(value);
  43438. var expectedValue = styleValue(value, expectedType);
  43439. var receivedValue = styleValue(value, receivedType);
  43440. // check if we need to specify expected value
  43441. if (expectedTypes.length === 1 &&
  43442. isExplicable(expectedType) &&
  43443. !isBoolean(expectedType, receivedType)) {
  43444. message += " with value " + expectedValue;
  43445. }
  43446. message += ", got " + receivedType + " ";
  43447. // check if we need to specify received value
  43448. if (isExplicable(receivedType)) {
  43449. message += "with value " + receivedValue + ".";
  43450. }
  43451. return message
  43452. }
  43453. function styleValue (value, type) {
  43454. if (type === 'String') {
  43455. return ("\"" + value + "\"")
  43456. } else if (type === 'Number') {
  43457. return ("" + (Number(value)))
  43458. } else {
  43459. return ("" + value)
  43460. }
  43461. }
  43462. function isExplicable (value) {
  43463. var explicitTypes = ['string', 'number', 'boolean'];
  43464. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43465. }
  43466. function isBoolean () {
  43467. var args = [], len = arguments.length;
  43468. while ( len-- ) args[ len ] = arguments[ len ];
  43469. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43470. }
  43471. /* */
  43472. function handleError (err, vm, info) {
  43473. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43474. // See: https://github.com/vuejs/vuex/issues/1505
  43475. pushTarget();
  43476. try {
  43477. if (vm) {
  43478. var cur = vm;
  43479. while ((cur = cur.$parent)) {
  43480. var hooks = cur.$options.errorCaptured;
  43481. if (hooks) {
  43482. for (var i = 0; i < hooks.length; i++) {
  43483. try {
  43484. var capture = hooks[i].call(cur, err, vm, info) === false;
  43485. if (capture) { return }
  43486. } catch (e) {
  43487. globalHandleError(e, cur, 'errorCaptured hook');
  43488. }
  43489. }
  43490. }
  43491. }
  43492. }
  43493. globalHandleError(err, vm, info);
  43494. } finally {
  43495. popTarget();
  43496. }
  43497. }
  43498. function invokeWithErrorHandling (
  43499. handler,
  43500. context,
  43501. args,
  43502. vm,
  43503. info
  43504. ) {
  43505. var res;
  43506. try {
  43507. res = args ? handler.apply(context, args) : handler.call(context);
  43508. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43509. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43510. // issue #9511
  43511. // avoid catch triggering multiple times when nested calls
  43512. res._handled = true;
  43513. }
  43514. } catch (e) {
  43515. handleError(e, vm, info);
  43516. }
  43517. return res
  43518. }
  43519. function globalHandleError (err, vm, info) {
  43520. if (config.errorHandler) {
  43521. try {
  43522. return config.errorHandler.call(null, err, vm, info)
  43523. } catch (e) {
  43524. // if the user intentionally throws the original error in the handler,
  43525. // do not log it twice
  43526. if (e !== err) {
  43527. logError(e, null, 'config.errorHandler');
  43528. }
  43529. }
  43530. }
  43531. logError(err, vm, info);
  43532. }
  43533. function logError (err, vm, info) {
  43534. {
  43535. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43536. }
  43537. /* istanbul ignore else */
  43538. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43539. console.error(err);
  43540. } else {
  43541. throw err
  43542. }
  43543. }
  43544. /* */
  43545. var isUsingMicroTask = false;
  43546. var callbacks = [];
  43547. var pending = false;
  43548. function flushCallbacks () {
  43549. pending = false;
  43550. var copies = callbacks.slice(0);
  43551. callbacks.length = 0;
  43552. for (var i = 0; i < copies.length; i++) {
  43553. copies[i]();
  43554. }
  43555. }
  43556. // Here we have async deferring wrappers using microtasks.
  43557. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43558. // However, it has subtle problems when state is changed right before repaint
  43559. // (e.g. #6813, out-in transitions).
  43560. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43561. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43562. // So we now use microtasks everywhere, again.
  43563. // A major drawback of this tradeoff is that there are some scenarios
  43564. // where microtasks have too high a priority and fire in between supposedly
  43565. // sequential events (e.g. #4521, #6690, which have workarounds)
  43566. // or even between bubbling of the same event (#6566).
  43567. var timerFunc;
  43568. // The nextTick behavior leverages the microtask queue, which can be accessed
  43569. // via either native Promise.then or MutationObserver.
  43570. // MutationObserver has wider support, however it is seriously bugged in
  43571. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43572. // completely stops working after triggering a few times... so, if native
  43573. // Promise is available, we will use it:
  43574. /* istanbul ignore next, $flow-disable-line */
  43575. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43576. var p = Promise.resolve();
  43577. timerFunc = function () {
  43578. p.then(flushCallbacks);
  43579. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43580. // it can get stuck in a weird state where callbacks are pushed into the
  43581. // microtask queue but the queue isn't being flushed, until the browser
  43582. // needs to do some other work, e.g. handle a timer. Therefore we can
  43583. // "force" the microtask queue to be flushed by adding an empty timer.
  43584. if (isIOS) { setTimeout(noop); }
  43585. };
  43586. isUsingMicroTask = true;
  43587. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43588. isNative(MutationObserver) ||
  43589. // PhantomJS and iOS 7.x
  43590. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43591. )) {
  43592. // Use MutationObserver where native Promise is not available,
  43593. // e.g. PhantomJS, iOS7, Android 4.4
  43594. // (#6466 MutationObserver is unreliable in IE11)
  43595. var counter = 1;
  43596. var observer = new MutationObserver(flushCallbacks);
  43597. var textNode = document.createTextNode(String(counter));
  43598. observer.observe(textNode, {
  43599. characterData: true
  43600. });
  43601. timerFunc = function () {
  43602. counter = (counter + 1) % 2;
  43603. textNode.data = String(counter);
  43604. };
  43605. isUsingMicroTask = true;
  43606. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43607. // Fallback to setImmediate.
  43608. // Technically it leverages the (macro) task queue,
  43609. // but it is still a better choice than setTimeout.
  43610. timerFunc = function () {
  43611. setImmediate(flushCallbacks);
  43612. };
  43613. } else {
  43614. // Fallback to setTimeout.
  43615. timerFunc = function () {
  43616. setTimeout(flushCallbacks, 0);
  43617. };
  43618. }
  43619. function nextTick (cb, ctx) {
  43620. var _resolve;
  43621. callbacks.push(function () {
  43622. if (cb) {
  43623. try {
  43624. cb.call(ctx);
  43625. } catch (e) {
  43626. handleError(e, ctx, 'nextTick');
  43627. }
  43628. } else if (_resolve) {
  43629. _resolve(ctx);
  43630. }
  43631. });
  43632. if (!pending) {
  43633. pending = true;
  43634. timerFunc();
  43635. }
  43636. // $flow-disable-line
  43637. if (!cb && typeof Promise !== 'undefined') {
  43638. return new Promise(function (resolve) {
  43639. _resolve = resolve;
  43640. })
  43641. }
  43642. }
  43643. /* */
  43644. var mark;
  43645. var measure;
  43646. {
  43647. var perf = inBrowser && window.performance;
  43648. /* istanbul ignore if */
  43649. if (
  43650. perf &&
  43651. perf.mark &&
  43652. perf.measure &&
  43653. perf.clearMarks &&
  43654. perf.clearMeasures
  43655. ) {
  43656. mark = function (tag) { return perf.mark(tag); };
  43657. measure = function (name, startTag, endTag) {
  43658. perf.measure(name, startTag, endTag);
  43659. perf.clearMarks(startTag);
  43660. perf.clearMarks(endTag);
  43661. // perf.clearMeasures(name)
  43662. };
  43663. }
  43664. }
  43665. /* not type checking this file because flow doesn't play well with Proxy */
  43666. var initProxy;
  43667. {
  43668. var allowedGlobals = makeMap(
  43669. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43670. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43671. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43672. 'require' // for Webpack/Browserify
  43673. );
  43674. var warnNonPresent = function (target, key) {
  43675. warn(
  43676. "Property or method \"" + key + "\" is not defined on the instance but " +
  43677. 'referenced during render. Make sure that this property is reactive, ' +
  43678. 'either in the data option, or for class-based components, by ' +
  43679. 'initializing the property. ' +
  43680. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43681. target
  43682. );
  43683. };
  43684. var warnReservedPrefix = function (target, key) {
  43685. warn(
  43686. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43687. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43688. 'prevent conflicts with Vue internals. ' +
  43689. 'See: https://vuejs.org/v2/api/#data',
  43690. target
  43691. );
  43692. };
  43693. var hasProxy =
  43694. typeof Proxy !== 'undefined' && isNative(Proxy);
  43695. if (hasProxy) {
  43696. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43697. config.keyCodes = new Proxy(config.keyCodes, {
  43698. set: function set (target, key, value) {
  43699. if (isBuiltInModifier(key)) {
  43700. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43701. return false
  43702. } else {
  43703. target[key] = value;
  43704. return true
  43705. }
  43706. }
  43707. });
  43708. }
  43709. var hasHandler = {
  43710. has: function has (target, key) {
  43711. var has = key in target;
  43712. var isAllowed = allowedGlobals(key) ||
  43713. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43714. if (!has && !isAllowed) {
  43715. if (key in target.$data) { warnReservedPrefix(target, key); }
  43716. else { warnNonPresent(target, key); }
  43717. }
  43718. return has || !isAllowed
  43719. }
  43720. };
  43721. var getHandler = {
  43722. get: function get (target, key) {
  43723. if (typeof key === 'string' && !(key in target)) {
  43724. if (key in target.$data) { warnReservedPrefix(target, key); }
  43725. else { warnNonPresent(target, key); }
  43726. }
  43727. return target[key]
  43728. }
  43729. };
  43730. initProxy = function initProxy (vm) {
  43731. if (hasProxy) {
  43732. // determine which proxy handler to use
  43733. var options = vm.$options;
  43734. var handlers = options.render && options.render._withStripped
  43735. ? getHandler
  43736. : hasHandler;
  43737. vm._renderProxy = new Proxy(vm, handlers);
  43738. } else {
  43739. vm._renderProxy = vm;
  43740. }
  43741. };
  43742. }
  43743. /* */
  43744. var seenObjects = new _Set();
  43745. /**
  43746. * Recursively traverse an object to evoke all converted
  43747. * getters, so that every nested property inside the object
  43748. * is collected as a "deep" dependency.
  43749. */
  43750. function traverse (val) {
  43751. _traverse(val, seenObjects);
  43752. seenObjects.clear();
  43753. }
  43754. function _traverse (val, seen) {
  43755. var i, keys;
  43756. var isA = Array.isArray(val);
  43757. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43758. return
  43759. }
  43760. if (val.__ob__) {
  43761. var depId = val.__ob__.dep.id;
  43762. if (seen.has(depId)) {
  43763. return
  43764. }
  43765. seen.add(depId);
  43766. }
  43767. if (isA) {
  43768. i = val.length;
  43769. while (i--) { _traverse(val[i], seen); }
  43770. } else {
  43771. keys = Object.keys(val);
  43772. i = keys.length;
  43773. while (i--) { _traverse(val[keys[i]], seen); }
  43774. }
  43775. }
  43776. /* */
  43777. var normalizeEvent = cached(function (name) {
  43778. var passive = name.charAt(0) === '&';
  43779. name = passive ? name.slice(1) : name;
  43780. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43781. name = once$$1 ? name.slice(1) : name;
  43782. var capture = name.charAt(0) === '!';
  43783. name = capture ? name.slice(1) : name;
  43784. return {
  43785. name: name,
  43786. once: once$$1,
  43787. capture: capture,
  43788. passive: passive
  43789. }
  43790. });
  43791. function createFnInvoker (fns, vm) {
  43792. function invoker () {
  43793. var arguments$1 = arguments;
  43794. var fns = invoker.fns;
  43795. if (Array.isArray(fns)) {
  43796. var cloned = fns.slice();
  43797. for (var i = 0; i < cloned.length; i++) {
  43798. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43799. }
  43800. } else {
  43801. // return handler return value for single handlers
  43802. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43803. }
  43804. }
  43805. invoker.fns = fns;
  43806. return invoker
  43807. }
  43808. function updateListeners (
  43809. on,
  43810. oldOn,
  43811. add,
  43812. remove$$1,
  43813. createOnceHandler,
  43814. vm
  43815. ) {
  43816. var name, def$$1, cur, old, event;
  43817. for (name in on) {
  43818. def$$1 = cur = on[name];
  43819. old = oldOn[name];
  43820. event = normalizeEvent(name);
  43821. if (isUndef(cur)) {
  43822. warn(
  43823. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43824. vm
  43825. );
  43826. } else if (isUndef(old)) {
  43827. if (isUndef(cur.fns)) {
  43828. cur = on[name] = createFnInvoker(cur, vm);
  43829. }
  43830. if (isTrue(event.once)) {
  43831. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43832. }
  43833. add(event.name, cur, event.capture, event.passive, event.params);
  43834. } else if (cur !== old) {
  43835. old.fns = cur;
  43836. on[name] = old;
  43837. }
  43838. }
  43839. for (name in oldOn) {
  43840. if (isUndef(on[name])) {
  43841. event = normalizeEvent(name);
  43842. remove$$1(event.name, oldOn[name], event.capture);
  43843. }
  43844. }
  43845. }
  43846. /* */
  43847. function mergeVNodeHook (def, hookKey, hook) {
  43848. if (def instanceof VNode) {
  43849. def = def.data.hook || (def.data.hook = {});
  43850. }
  43851. var invoker;
  43852. var oldHook = def[hookKey];
  43853. function wrappedHook () {
  43854. hook.apply(this, arguments);
  43855. // important: remove merged hook to ensure it's called only once
  43856. // and prevent memory leak
  43857. remove(invoker.fns, wrappedHook);
  43858. }
  43859. if (isUndef(oldHook)) {
  43860. // no existing hook
  43861. invoker = createFnInvoker([wrappedHook]);
  43862. } else {
  43863. /* istanbul ignore if */
  43864. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43865. // already a merged invoker
  43866. invoker = oldHook;
  43867. invoker.fns.push(wrappedHook);
  43868. } else {
  43869. // existing plain hook
  43870. invoker = createFnInvoker([oldHook, wrappedHook]);
  43871. }
  43872. }
  43873. invoker.merged = true;
  43874. def[hookKey] = invoker;
  43875. }
  43876. /* */
  43877. function extractPropsFromVNodeData (
  43878. data,
  43879. Ctor,
  43880. tag
  43881. ) {
  43882. // we are only extracting raw values here.
  43883. // validation and default values are handled in the child
  43884. // component itself.
  43885. var propOptions = Ctor.options.props;
  43886. if (isUndef(propOptions)) {
  43887. return
  43888. }
  43889. var res = {};
  43890. var attrs = data.attrs;
  43891. var props = data.props;
  43892. if (isDef(attrs) || isDef(props)) {
  43893. for (var key in propOptions) {
  43894. var altKey = hyphenate(key);
  43895. {
  43896. var keyInLowerCase = key.toLowerCase();
  43897. if (
  43898. key !== keyInLowerCase &&
  43899. attrs && hasOwn(attrs, keyInLowerCase)
  43900. ) {
  43901. tip(
  43902. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43903. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43904. " \"" + key + "\". " +
  43905. "Note that HTML attributes are case-insensitive and camelCased " +
  43906. "props need to use their kebab-case equivalents when using in-DOM " +
  43907. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  43908. );
  43909. }
  43910. }
  43911. checkProp(res, props, key, altKey, true) ||
  43912. checkProp(res, attrs, key, altKey, false);
  43913. }
  43914. }
  43915. return res
  43916. }
  43917. function checkProp (
  43918. res,
  43919. hash,
  43920. key,
  43921. altKey,
  43922. preserve
  43923. ) {
  43924. if (isDef(hash)) {
  43925. if (hasOwn(hash, key)) {
  43926. res[key] = hash[key];
  43927. if (!preserve) {
  43928. delete hash[key];
  43929. }
  43930. return true
  43931. } else if (hasOwn(hash, altKey)) {
  43932. res[key] = hash[altKey];
  43933. if (!preserve) {
  43934. delete hash[altKey];
  43935. }
  43936. return true
  43937. }
  43938. }
  43939. return false
  43940. }
  43941. /* */
  43942. // The template compiler attempts to minimize the need for normalization by
  43943. // statically analyzing the template at compile time.
  43944. //
  43945. // For plain HTML markup, normalization can be completely skipped because the
  43946. // generated render function is guaranteed to return Array<VNode>. There are
  43947. // two cases where extra normalization is needed:
  43948. // 1. When the children contains components - because a functional component
  43949. // may return an Array instead of a single root. In this case, just a simple
  43950. // normalization is needed - if any child is an Array, we flatten the whole
  43951. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  43952. // because functional components already normalize their own children.
  43953. function simpleNormalizeChildren (children) {
  43954. for (var i = 0; i < children.length; i++) {
  43955. if (Array.isArray(children[i])) {
  43956. return Array.prototype.concat.apply([], children)
  43957. }
  43958. }
  43959. return children
  43960. }
  43961. // 2. When the children contains constructs that always generated nested Arrays,
  43962. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  43963. // with hand-written render functions / JSX. In such cases a full normalization
  43964. // is needed to cater to all possible types of children values.
  43965. function normalizeChildren (children) {
  43966. return isPrimitive(children)
  43967. ? [createTextVNode(children)]
  43968. : Array.isArray(children)
  43969. ? normalizeArrayChildren(children)
  43970. : undefined
  43971. }
  43972. function isTextNode (node) {
  43973. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  43974. }
  43975. function normalizeArrayChildren (children, nestedIndex) {
  43976. var res = [];
  43977. var i, c, lastIndex, last;
  43978. for (i = 0; i < children.length; i++) {
  43979. c = children[i];
  43980. if (isUndef(c) || typeof c === 'boolean') { continue }
  43981. lastIndex = res.length - 1;
  43982. last = res[lastIndex];
  43983. // nested
  43984. if (Array.isArray(c)) {
  43985. if (c.length > 0) {
  43986. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  43987. // merge adjacent text nodes
  43988. if (isTextNode(c[0]) && isTextNode(last)) {
  43989. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  43990. c.shift();
  43991. }
  43992. res.push.apply(res, c);
  43993. }
  43994. } else if (isPrimitive(c)) {
  43995. if (isTextNode(last)) {
  43996. // merge adjacent text nodes
  43997. // this is necessary for SSR hydration because text nodes are
  43998. // essentially merged when rendered to HTML strings
  43999. res[lastIndex] = createTextVNode(last.text + c);
  44000. } else if (c !== '') {
  44001. // convert primitive to vnode
  44002. res.push(createTextVNode(c));
  44003. }
  44004. } else {
  44005. if (isTextNode(c) && isTextNode(last)) {
  44006. // merge adjacent text nodes
  44007. res[lastIndex] = createTextVNode(last.text + c.text);
  44008. } else {
  44009. // default key for nested array children (likely generated by v-for)
  44010. if (isTrue(children._isVList) &&
  44011. isDef(c.tag) &&
  44012. isUndef(c.key) &&
  44013. isDef(nestedIndex)) {
  44014. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  44015. }
  44016. res.push(c);
  44017. }
  44018. }
  44019. }
  44020. return res
  44021. }
  44022. /* */
  44023. function initProvide (vm) {
  44024. var provide = vm.$options.provide;
  44025. if (provide) {
  44026. vm._provided = typeof provide === 'function'
  44027. ? provide.call(vm)
  44028. : provide;
  44029. }
  44030. }
  44031. function initInjections (vm) {
  44032. var result = resolveInject(vm.$options.inject, vm);
  44033. if (result) {
  44034. toggleObserving(false);
  44035. Object.keys(result).forEach(function (key) {
  44036. /* istanbul ignore else */
  44037. {
  44038. defineReactive$$1(vm, key, result[key], function () {
  44039. warn(
  44040. "Avoid mutating an injected value directly since the changes will be " +
  44041. "overwritten whenever the provided component re-renders. " +
  44042. "injection being mutated: \"" + key + "\"",
  44043. vm
  44044. );
  44045. });
  44046. }
  44047. });
  44048. toggleObserving(true);
  44049. }
  44050. }
  44051. function resolveInject (inject, vm) {
  44052. if (inject) {
  44053. // inject is :any because flow is not smart enough to figure out cached
  44054. var result = Object.create(null);
  44055. var keys = hasSymbol
  44056. ? Reflect.ownKeys(inject)
  44057. : Object.keys(inject);
  44058. for (var i = 0; i < keys.length; i++) {
  44059. var key = keys[i];
  44060. // #6574 in case the inject object is observed...
  44061. if (key === '__ob__') { continue }
  44062. var provideKey = inject[key].from;
  44063. var source = vm;
  44064. while (source) {
  44065. if (source._provided && hasOwn(source._provided, provideKey)) {
  44066. result[key] = source._provided[provideKey];
  44067. break
  44068. }
  44069. source = source.$parent;
  44070. }
  44071. if (!source) {
  44072. if ('default' in inject[key]) {
  44073. var provideDefault = inject[key].default;
  44074. result[key] = typeof provideDefault === 'function'
  44075. ? provideDefault.call(vm)
  44076. : provideDefault;
  44077. } else {
  44078. warn(("Injection \"" + key + "\" not found"), vm);
  44079. }
  44080. }
  44081. }
  44082. return result
  44083. }
  44084. }
  44085. /* */
  44086. /**
  44087. * Runtime helper for resolving raw children VNodes into a slot object.
  44088. */
  44089. function resolveSlots (
  44090. children,
  44091. context
  44092. ) {
  44093. if (!children || !children.length) {
  44094. return {}
  44095. }
  44096. var slots = {};
  44097. for (var i = 0, l = children.length; i < l; i++) {
  44098. var child = children[i];
  44099. var data = child.data;
  44100. // remove slot attribute if the node is resolved as a Vue slot node
  44101. if (data && data.attrs && data.attrs.slot) {
  44102. delete data.attrs.slot;
  44103. }
  44104. // named slots should only be respected if the vnode was rendered in the
  44105. // same context.
  44106. if ((child.context === context || child.fnContext === context) &&
  44107. data && data.slot != null
  44108. ) {
  44109. var name = data.slot;
  44110. var slot = (slots[name] || (slots[name] = []));
  44111. if (child.tag === 'template') {
  44112. slot.push.apply(slot, child.children || []);
  44113. } else {
  44114. slot.push(child);
  44115. }
  44116. } else {
  44117. (slots.default || (slots.default = [])).push(child);
  44118. }
  44119. }
  44120. // ignore slots that contains only whitespace
  44121. for (var name$1 in slots) {
  44122. if (slots[name$1].every(isWhitespace)) {
  44123. delete slots[name$1];
  44124. }
  44125. }
  44126. return slots
  44127. }
  44128. function isWhitespace (node) {
  44129. return (node.isComment && !node.asyncFactory) || node.text === ' '
  44130. }
  44131. /* */
  44132. function normalizeScopedSlots (
  44133. slots,
  44134. normalSlots,
  44135. prevSlots
  44136. ) {
  44137. var res;
  44138. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44139. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44140. var key = slots && slots.$key;
  44141. if (!slots) {
  44142. res = {};
  44143. } else if (slots._normalized) {
  44144. // fast path 1: child component re-render only, parent did not change
  44145. return slots._normalized
  44146. } else if (
  44147. isStable &&
  44148. prevSlots &&
  44149. prevSlots !== emptyObject &&
  44150. key === prevSlots.$key &&
  44151. !hasNormalSlots &&
  44152. !prevSlots.$hasNormal
  44153. ) {
  44154. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44155. // only need to normalize once
  44156. return prevSlots
  44157. } else {
  44158. res = {};
  44159. for (var key$1 in slots) {
  44160. if (slots[key$1] && key$1[0] !== '$') {
  44161. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44162. }
  44163. }
  44164. }
  44165. // expose normal slots on scopedSlots
  44166. for (var key$2 in normalSlots) {
  44167. if (!(key$2 in res)) {
  44168. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44169. }
  44170. }
  44171. // avoriaz seems to mock a non-extensible $scopedSlots object
  44172. // and when that is passed down this would cause an error
  44173. if (slots && Object.isExtensible(slots)) {
  44174. (slots)._normalized = res;
  44175. }
  44176. def(res, '$stable', isStable);
  44177. def(res, '$key', key);
  44178. def(res, '$hasNormal', hasNormalSlots);
  44179. return res
  44180. }
  44181. function normalizeScopedSlot(normalSlots, key, fn) {
  44182. var normalized = function () {
  44183. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44184. res = res && typeof res === 'object' && !Array.isArray(res)
  44185. ? [res] // single vnode
  44186. : normalizeChildren(res);
  44187. return res && (
  44188. res.length === 0 ||
  44189. (res.length === 1 && res[0].isComment) // #9658
  44190. ) ? undefined
  44191. : res
  44192. };
  44193. // this is a slot using the new v-slot syntax without scope. although it is
  44194. // compiled as a scoped slot, render fn users would expect it to be present
  44195. // on this.$slots because the usage is semantically a normal slot.
  44196. if (fn.proxy) {
  44197. Object.defineProperty(normalSlots, key, {
  44198. get: normalized,
  44199. enumerable: true,
  44200. configurable: true
  44201. });
  44202. }
  44203. return normalized
  44204. }
  44205. function proxyNormalSlot(slots, key) {
  44206. return function () { return slots[key]; }
  44207. }
  44208. /* */
  44209. /**
  44210. * Runtime helper for rendering v-for lists.
  44211. */
  44212. function renderList (
  44213. val,
  44214. render
  44215. ) {
  44216. var ret, i, l, keys, key;
  44217. if (Array.isArray(val) || typeof val === 'string') {
  44218. ret = new Array(val.length);
  44219. for (i = 0, l = val.length; i < l; i++) {
  44220. ret[i] = render(val[i], i);
  44221. }
  44222. } else if (typeof val === 'number') {
  44223. ret = new Array(val);
  44224. for (i = 0; i < val; i++) {
  44225. ret[i] = render(i + 1, i);
  44226. }
  44227. } else if (isObject(val)) {
  44228. if (hasSymbol && val[Symbol.iterator]) {
  44229. ret = [];
  44230. var iterator = val[Symbol.iterator]();
  44231. var result = iterator.next();
  44232. while (!result.done) {
  44233. ret.push(render(result.value, ret.length));
  44234. result = iterator.next();
  44235. }
  44236. } else {
  44237. keys = Object.keys(val);
  44238. ret = new Array(keys.length);
  44239. for (i = 0, l = keys.length; i < l; i++) {
  44240. key = keys[i];
  44241. ret[i] = render(val[key], key, i);
  44242. }
  44243. }
  44244. }
  44245. if (!isDef(ret)) {
  44246. ret = [];
  44247. }
  44248. (ret)._isVList = true;
  44249. return ret
  44250. }
  44251. /* */
  44252. /**
  44253. * Runtime helper for rendering <slot>
  44254. */
  44255. function renderSlot (
  44256. name,
  44257. fallback,
  44258. props,
  44259. bindObject
  44260. ) {
  44261. var scopedSlotFn = this.$scopedSlots[name];
  44262. var nodes;
  44263. if (scopedSlotFn) { // scoped slot
  44264. props = props || {};
  44265. if (bindObject) {
  44266. if (!isObject(bindObject)) {
  44267. warn(
  44268. 'slot v-bind without argument expects an Object',
  44269. this
  44270. );
  44271. }
  44272. props = extend(extend({}, bindObject), props);
  44273. }
  44274. nodes = scopedSlotFn(props) || fallback;
  44275. } else {
  44276. nodes = this.$slots[name] || fallback;
  44277. }
  44278. var target = props && props.slot;
  44279. if (target) {
  44280. return this.$createElement('template', { slot: target }, nodes)
  44281. } else {
  44282. return nodes
  44283. }
  44284. }
  44285. /* */
  44286. /**
  44287. * Runtime helper for resolving filters
  44288. */
  44289. function resolveFilter (id) {
  44290. return resolveAsset(this.$options, 'filters', id, true) || identity
  44291. }
  44292. /* */
  44293. function isKeyNotMatch (expect, actual) {
  44294. if (Array.isArray(expect)) {
  44295. return expect.indexOf(actual) === -1
  44296. } else {
  44297. return expect !== actual
  44298. }
  44299. }
  44300. /**
  44301. * Runtime helper for checking keyCodes from config.
  44302. * exposed as Vue.prototype._k
  44303. * passing in eventKeyName as last argument separately for backwards compat
  44304. */
  44305. function checkKeyCodes (
  44306. eventKeyCode,
  44307. key,
  44308. builtInKeyCode,
  44309. eventKeyName,
  44310. builtInKeyName
  44311. ) {
  44312. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44313. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44314. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44315. } else if (mappedKeyCode) {
  44316. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44317. } else if (eventKeyName) {
  44318. return hyphenate(eventKeyName) !== key
  44319. }
  44320. }
  44321. /* */
  44322. /**
  44323. * Runtime helper for merging v-bind="object" into a VNode's data.
  44324. */
  44325. function bindObjectProps (
  44326. data,
  44327. tag,
  44328. value,
  44329. asProp,
  44330. isSync
  44331. ) {
  44332. if (value) {
  44333. if (!isObject(value)) {
  44334. warn(
  44335. 'v-bind without argument expects an Object or Array value',
  44336. this
  44337. );
  44338. } else {
  44339. if (Array.isArray(value)) {
  44340. value = toObject(value);
  44341. }
  44342. var hash;
  44343. var loop = function ( key ) {
  44344. if (
  44345. key === 'class' ||
  44346. key === 'style' ||
  44347. isReservedAttribute(key)
  44348. ) {
  44349. hash = data;
  44350. } else {
  44351. var type = data.attrs && data.attrs.type;
  44352. hash = asProp || config.mustUseProp(tag, type, key)
  44353. ? data.domProps || (data.domProps = {})
  44354. : data.attrs || (data.attrs = {});
  44355. }
  44356. var camelizedKey = camelize(key);
  44357. var hyphenatedKey = hyphenate(key);
  44358. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44359. hash[key] = value[key];
  44360. if (isSync) {
  44361. var on = data.on || (data.on = {});
  44362. on[("update:" + key)] = function ($event) {
  44363. value[key] = $event;
  44364. };
  44365. }
  44366. }
  44367. };
  44368. for (var key in value) loop( key );
  44369. }
  44370. }
  44371. return data
  44372. }
  44373. /* */
  44374. /**
  44375. * Runtime helper for rendering static trees.
  44376. */
  44377. function renderStatic (
  44378. index,
  44379. isInFor
  44380. ) {
  44381. var cached = this._staticTrees || (this._staticTrees = []);
  44382. var tree = cached[index];
  44383. // if has already-rendered static tree and not inside v-for,
  44384. // we can reuse the same tree.
  44385. if (tree && !isInFor) {
  44386. return tree
  44387. }
  44388. // otherwise, render a fresh tree.
  44389. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44390. this._renderProxy,
  44391. null,
  44392. this // for render fns generated for functional component templates
  44393. );
  44394. markStatic(tree, ("__static__" + index), false);
  44395. return tree
  44396. }
  44397. /**
  44398. * Runtime helper for v-once.
  44399. * Effectively it means marking the node as static with a unique key.
  44400. */
  44401. function markOnce (
  44402. tree,
  44403. index,
  44404. key
  44405. ) {
  44406. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44407. return tree
  44408. }
  44409. function markStatic (
  44410. tree,
  44411. key,
  44412. isOnce
  44413. ) {
  44414. if (Array.isArray(tree)) {
  44415. for (var i = 0; i < tree.length; i++) {
  44416. if (tree[i] && typeof tree[i] !== 'string') {
  44417. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44418. }
  44419. }
  44420. } else {
  44421. markStaticNode(tree, key, isOnce);
  44422. }
  44423. }
  44424. function markStaticNode (node, key, isOnce) {
  44425. node.isStatic = true;
  44426. node.key = key;
  44427. node.isOnce = isOnce;
  44428. }
  44429. /* */
  44430. function bindObjectListeners (data, value) {
  44431. if (value) {
  44432. if (!isPlainObject(value)) {
  44433. warn(
  44434. 'v-on without argument expects an Object value',
  44435. this
  44436. );
  44437. } else {
  44438. var on = data.on = data.on ? extend({}, data.on) : {};
  44439. for (var key in value) {
  44440. var existing = on[key];
  44441. var ours = value[key];
  44442. on[key] = existing ? [].concat(existing, ours) : ours;
  44443. }
  44444. }
  44445. }
  44446. return data
  44447. }
  44448. /* */
  44449. function resolveScopedSlots (
  44450. fns, // see flow/vnode
  44451. res,
  44452. // the following are added in 2.6
  44453. hasDynamicKeys,
  44454. contentHashKey
  44455. ) {
  44456. res = res || { $stable: !hasDynamicKeys };
  44457. for (var i = 0; i < fns.length; i++) {
  44458. var slot = fns[i];
  44459. if (Array.isArray(slot)) {
  44460. resolveScopedSlots(slot, res, hasDynamicKeys);
  44461. } else if (slot) {
  44462. // marker for reverse proxying v-slot without scope on this.$slots
  44463. if (slot.proxy) {
  44464. slot.fn.proxy = true;
  44465. }
  44466. res[slot.key] = slot.fn;
  44467. }
  44468. }
  44469. if (contentHashKey) {
  44470. (res).$key = contentHashKey;
  44471. }
  44472. return res
  44473. }
  44474. /* */
  44475. function bindDynamicKeys (baseObj, values) {
  44476. for (var i = 0; i < values.length; i += 2) {
  44477. var key = values[i];
  44478. if (typeof key === 'string' && key) {
  44479. baseObj[values[i]] = values[i + 1];
  44480. } else if (key !== '' && key !== null) {
  44481. // null is a special value for explicitly removing a binding
  44482. warn(
  44483. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44484. this
  44485. );
  44486. }
  44487. }
  44488. return baseObj
  44489. }
  44490. // helper to dynamically append modifier runtime markers to event names.
  44491. // ensure only append when value is already string, otherwise it will be cast
  44492. // to string and cause the type check to miss.
  44493. function prependModifier (value, symbol) {
  44494. return typeof value === 'string' ? symbol + value : value
  44495. }
  44496. /* */
  44497. function installRenderHelpers (target) {
  44498. target._o = markOnce;
  44499. target._n = toNumber;
  44500. target._s = toString;
  44501. target._l = renderList;
  44502. target._t = renderSlot;
  44503. target._q = looseEqual;
  44504. target._i = looseIndexOf;
  44505. target._m = renderStatic;
  44506. target._f = resolveFilter;
  44507. target._k = checkKeyCodes;
  44508. target._b = bindObjectProps;
  44509. target._v = createTextVNode;
  44510. target._e = createEmptyVNode;
  44511. target._u = resolveScopedSlots;
  44512. target._g = bindObjectListeners;
  44513. target._d = bindDynamicKeys;
  44514. target._p = prependModifier;
  44515. }
  44516. /* */
  44517. function FunctionalRenderContext (
  44518. data,
  44519. props,
  44520. children,
  44521. parent,
  44522. Ctor
  44523. ) {
  44524. var this$1 = this;
  44525. var options = Ctor.options;
  44526. // ensure the createElement function in functional components
  44527. // gets a unique context - this is necessary for correct named slot check
  44528. var contextVm;
  44529. if (hasOwn(parent, '_uid')) {
  44530. contextVm = Object.create(parent);
  44531. // $flow-disable-line
  44532. contextVm._original = parent;
  44533. } else {
  44534. // the context vm passed in is a functional context as well.
  44535. // in this case we want to make sure we are able to get a hold to the
  44536. // real context instance.
  44537. contextVm = parent;
  44538. // $flow-disable-line
  44539. parent = parent._original;
  44540. }
  44541. var isCompiled = isTrue(options._compiled);
  44542. var needNormalization = !isCompiled;
  44543. this.data = data;
  44544. this.props = props;
  44545. this.children = children;
  44546. this.parent = parent;
  44547. this.listeners = data.on || emptyObject;
  44548. this.injections = resolveInject(options.inject, parent);
  44549. this.slots = function () {
  44550. if (!this$1.$slots) {
  44551. normalizeScopedSlots(
  44552. data.scopedSlots,
  44553. this$1.$slots = resolveSlots(children, parent)
  44554. );
  44555. }
  44556. return this$1.$slots
  44557. };
  44558. Object.defineProperty(this, 'scopedSlots', ({
  44559. enumerable: true,
  44560. get: function get () {
  44561. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44562. }
  44563. }));
  44564. // support for compiled functional template
  44565. if (isCompiled) {
  44566. // exposing $options for renderStatic()
  44567. this.$options = options;
  44568. // pre-resolve slots for renderSlot()
  44569. this.$slots = this.slots();
  44570. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44571. }
  44572. if (options._scopeId) {
  44573. this._c = function (a, b, c, d) {
  44574. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44575. if (vnode && !Array.isArray(vnode)) {
  44576. vnode.fnScopeId = options._scopeId;
  44577. vnode.fnContext = parent;
  44578. }
  44579. return vnode
  44580. };
  44581. } else {
  44582. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44583. }
  44584. }
  44585. installRenderHelpers(FunctionalRenderContext.prototype);
  44586. function createFunctionalComponent (
  44587. Ctor,
  44588. propsData,
  44589. data,
  44590. contextVm,
  44591. children
  44592. ) {
  44593. var options = Ctor.options;
  44594. var props = {};
  44595. var propOptions = options.props;
  44596. if (isDef(propOptions)) {
  44597. for (var key in propOptions) {
  44598. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44599. }
  44600. } else {
  44601. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44602. if (isDef(data.props)) { mergeProps(props, data.props); }
  44603. }
  44604. var renderContext = new FunctionalRenderContext(
  44605. data,
  44606. props,
  44607. children,
  44608. contextVm,
  44609. Ctor
  44610. );
  44611. var vnode = options.render.call(null, renderContext._c, renderContext);
  44612. if (vnode instanceof VNode) {
  44613. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44614. } else if (Array.isArray(vnode)) {
  44615. var vnodes = normalizeChildren(vnode) || [];
  44616. var res = new Array(vnodes.length);
  44617. for (var i = 0; i < vnodes.length; i++) {
  44618. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44619. }
  44620. return res
  44621. }
  44622. }
  44623. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44624. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44625. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44626. // that should not be matched to match.
  44627. var clone = cloneVNode(vnode);
  44628. clone.fnContext = contextVm;
  44629. clone.fnOptions = options;
  44630. {
  44631. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44632. }
  44633. if (data.slot) {
  44634. (clone.data || (clone.data = {})).slot = data.slot;
  44635. }
  44636. return clone
  44637. }
  44638. function mergeProps (to, from) {
  44639. for (var key in from) {
  44640. to[camelize(key)] = from[key];
  44641. }
  44642. }
  44643. /* */
  44644. /* */
  44645. /* */
  44646. /* */
  44647. // inline hooks to be invoked on component VNodes during patch
  44648. var componentVNodeHooks = {
  44649. init: function init (vnode, hydrating) {
  44650. if (
  44651. vnode.componentInstance &&
  44652. !vnode.componentInstance._isDestroyed &&
  44653. vnode.data.keepAlive
  44654. ) {
  44655. // kept-alive components, treat as a patch
  44656. var mountedNode = vnode; // work around flow
  44657. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44658. } else {
  44659. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44660. vnode,
  44661. activeInstance
  44662. );
  44663. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44664. }
  44665. },
  44666. prepatch: function prepatch (oldVnode, vnode) {
  44667. var options = vnode.componentOptions;
  44668. var child = vnode.componentInstance = oldVnode.componentInstance;
  44669. updateChildComponent(
  44670. child,
  44671. options.propsData, // updated props
  44672. options.listeners, // updated listeners
  44673. vnode, // new parent vnode
  44674. options.children // new children
  44675. );
  44676. },
  44677. insert: function insert (vnode) {
  44678. var context = vnode.context;
  44679. var componentInstance = vnode.componentInstance;
  44680. if (!componentInstance._isMounted) {
  44681. componentInstance._isMounted = true;
  44682. callHook(componentInstance, 'mounted');
  44683. }
  44684. if (vnode.data.keepAlive) {
  44685. if (context._isMounted) {
  44686. // vue-router#1212
  44687. // During updates, a kept-alive component's child components may
  44688. // change, so directly walking the tree here may call activated hooks
  44689. // on incorrect children. Instead we push them into a queue which will
  44690. // be processed after the whole patch process ended.
  44691. queueActivatedComponent(componentInstance);
  44692. } else {
  44693. activateChildComponent(componentInstance, true /* direct */);
  44694. }
  44695. }
  44696. },
  44697. destroy: function destroy (vnode) {
  44698. var componentInstance = vnode.componentInstance;
  44699. if (!componentInstance._isDestroyed) {
  44700. if (!vnode.data.keepAlive) {
  44701. componentInstance.$destroy();
  44702. } else {
  44703. deactivateChildComponent(componentInstance, true /* direct */);
  44704. }
  44705. }
  44706. }
  44707. };
  44708. var hooksToMerge = Object.keys(componentVNodeHooks);
  44709. function createComponent (
  44710. Ctor,
  44711. data,
  44712. context,
  44713. children,
  44714. tag
  44715. ) {
  44716. if (isUndef(Ctor)) {
  44717. return
  44718. }
  44719. var baseCtor = context.$options._base;
  44720. // plain options object: turn it into a constructor
  44721. if (isObject(Ctor)) {
  44722. Ctor = baseCtor.extend(Ctor);
  44723. }
  44724. // if at this stage it's not a constructor or an async component factory,
  44725. // reject.
  44726. if (typeof Ctor !== 'function') {
  44727. {
  44728. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44729. }
  44730. return
  44731. }
  44732. // async component
  44733. var asyncFactory;
  44734. if (isUndef(Ctor.cid)) {
  44735. asyncFactory = Ctor;
  44736. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44737. if (Ctor === undefined) {
  44738. // return a placeholder node for async component, which is rendered
  44739. // as a comment node but preserves all the raw information for the node.
  44740. // the information will be used for async server-rendering and hydration.
  44741. return createAsyncPlaceholder(
  44742. asyncFactory,
  44743. data,
  44744. context,
  44745. children,
  44746. tag
  44747. )
  44748. }
  44749. }
  44750. data = data || {};
  44751. // resolve constructor options in case global mixins are applied after
  44752. // component constructor creation
  44753. resolveConstructorOptions(Ctor);
  44754. // transform component v-model data into props & events
  44755. if (isDef(data.model)) {
  44756. transformModel(Ctor.options, data);
  44757. }
  44758. // extract props
  44759. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44760. // functional component
  44761. if (isTrue(Ctor.options.functional)) {
  44762. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44763. }
  44764. // extract listeners, since these needs to be treated as
  44765. // child component listeners instead of DOM listeners
  44766. var listeners = data.on;
  44767. // replace with listeners with .native modifier
  44768. // so it gets processed during parent component patch.
  44769. data.on = data.nativeOn;
  44770. if (isTrue(Ctor.options.abstract)) {
  44771. // abstract components do not keep anything
  44772. // other than props & listeners & slot
  44773. // work around flow
  44774. var slot = data.slot;
  44775. data = {};
  44776. if (slot) {
  44777. data.slot = slot;
  44778. }
  44779. }
  44780. // install component management hooks onto the placeholder node
  44781. installComponentHooks(data);
  44782. // return a placeholder vnode
  44783. var name = Ctor.options.name || tag;
  44784. var vnode = new VNode(
  44785. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44786. data, undefined, undefined, undefined, context,
  44787. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44788. asyncFactory
  44789. );
  44790. return vnode
  44791. }
  44792. function createComponentInstanceForVnode (
  44793. vnode, // we know it's MountedComponentVNode but flow doesn't
  44794. parent // activeInstance in lifecycle state
  44795. ) {
  44796. var options = {
  44797. _isComponent: true,
  44798. _parentVnode: vnode,
  44799. parent: parent
  44800. };
  44801. // check inline-template render functions
  44802. var inlineTemplate = vnode.data.inlineTemplate;
  44803. if (isDef(inlineTemplate)) {
  44804. options.render = inlineTemplate.render;
  44805. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44806. }
  44807. return new vnode.componentOptions.Ctor(options)
  44808. }
  44809. function installComponentHooks (data) {
  44810. var hooks = data.hook || (data.hook = {});
  44811. for (var i = 0; i < hooksToMerge.length; i++) {
  44812. var key = hooksToMerge[i];
  44813. var existing = hooks[key];
  44814. var toMerge = componentVNodeHooks[key];
  44815. if (existing !== toMerge && !(existing && existing._merged)) {
  44816. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44817. }
  44818. }
  44819. }
  44820. function mergeHook$1 (f1, f2) {
  44821. var merged = function (a, b) {
  44822. // flow complains about extra args which is why we use any
  44823. f1(a, b);
  44824. f2(a, b);
  44825. };
  44826. merged._merged = true;
  44827. return merged
  44828. }
  44829. // transform component v-model info (value and callback) into
  44830. // prop and event handler respectively.
  44831. function transformModel (options, data) {
  44832. var prop = (options.model && options.model.prop) || 'value';
  44833. var event = (options.model && options.model.event) || 'input'
  44834. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44835. var on = data.on || (data.on = {});
  44836. var existing = on[event];
  44837. var callback = data.model.callback;
  44838. if (isDef(existing)) {
  44839. if (
  44840. Array.isArray(existing)
  44841. ? existing.indexOf(callback) === -1
  44842. : existing !== callback
  44843. ) {
  44844. on[event] = [callback].concat(existing);
  44845. }
  44846. } else {
  44847. on[event] = callback;
  44848. }
  44849. }
  44850. /* */
  44851. var SIMPLE_NORMALIZE = 1;
  44852. var ALWAYS_NORMALIZE = 2;
  44853. // wrapper function for providing a more flexible interface
  44854. // without getting yelled at by flow
  44855. function createElement (
  44856. context,
  44857. tag,
  44858. data,
  44859. children,
  44860. normalizationType,
  44861. alwaysNormalize
  44862. ) {
  44863. if (Array.isArray(data) || isPrimitive(data)) {
  44864. normalizationType = children;
  44865. children = data;
  44866. data = undefined;
  44867. }
  44868. if (isTrue(alwaysNormalize)) {
  44869. normalizationType = ALWAYS_NORMALIZE;
  44870. }
  44871. return _createElement(context, tag, data, children, normalizationType)
  44872. }
  44873. function _createElement (
  44874. context,
  44875. tag,
  44876. data,
  44877. children,
  44878. normalizationType
  44879. ) {
  44880. if (isDef(data) && isDef((data).__ob__)) {
  44881. warn(
  44882. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44883. 'Always create fresh vnode data objects in each render!',
  44884. context
  44885. );
  44886. return createEmptyVNode()
  44887. }
  44888. // object syntax in v-bind
  44889. if (isDef(data) && isDef(data.is)) {
  44890. tag = data.is;
  44891. }
  44892. if (!tag) {
  44893. // in case of component :is set to falsy value
  44894. return createEmptyVNode()
  44895. }
  44896. // warn against non-primitive key
  44897. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44898. ) {
  44899. {
  44900. warn(
  44901. 'Avoid using non-primitive value as key, ' +
  44902. 'use string/number value instead.',
  44903. context
  44904. );
  44905. }
  44906. }
  44907. // support single function children as default scoped slot
  44908. if (Array.isArray(children) &&
  44909. typeof children[0] === 'function'
  44910. ) {
  44911. data = data || {};
  44912. data.scopedSlots = { default: children[0] };
  44913. children.length = 0;
  44914. }
  44915. if (normalizationType === ALWAYS_NORMALIZE) {
  44916. children = normalizeChildren(children);
  44917. } else if (normalizationType === SIMPLE_NORMALIZE) {
  44918. children = simpleNormalizeChildren(children);
  44919. }
  44920. var vnode, ns;
  44921. if (typeof tag === 'string') {
  44922. var Ctor;
  44923. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  44924. if (config.isReservedTag(tag)) {
  44925. // platform built-in elements
  44926. if (isDef(data) && isDef(data.nativeOn)) {
  44927. warn(
  44928. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  44929. context
  44930. );
  44931. }
  44932. vnode = new VNode(
  44933. config.parsePlatformTagName(tag), data, children,
  44934. undefined, undefined, context
  44935. );
  44936. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  44937. // component
  44938. vnode = createComponent(Ctor, data, context, children, tag);
  44939. } else {
  44940. // unknown or unlisted namespaced elements
  44941. // check at runtime because it may get assigned a namespace when its
  44942. // parent normalizes children
  44943. vnode = new VNode(
  44944. tag, data, children,
  44945. undefined, undefined, context
  44946. );
  44947. }
  44948. } else {
  44949. // direct component options / constructor
  44950. vnode = createComponent(tag, data, context, children);
  44951. }
  44952. if (Array.isArray(vnode)) {
  44953. return vnode
  44954. } else if (isDef(vnode)) {
  44955. if (isDef(ns)) { applyNS(vnode, ns); }
  44956. if (isDef(data)) { registerDeepBindings(data); }
  44957. return vnode
  44958. } else {
  44959. return createEmptyVNode()
  44960. }
  44961. }
  44962. function applyNS (vnode, ns, force) {
  44963. vnode.ns = ns;
  44964. if (vnode.tag === 'foreignObject') {
  44965. // use default namespace inside foreignObject
  44966. ns = undefined;
  44967. force = true;
  44968. }
  44969. if (isDef(vnode.children)) {
  44970. for (var i = 0, l = vnode.children.length; i < l; i++) {
  44971. var child = vnode.children[i];
  44972. if (isDef(child.tag) && (
  44973. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  44974. applyNS(child, ns, force);
  44975. }
  44976. }
  44977. }
  44978. }
  44979. // ref #5318
  44980. // necessary to ensure parent re-render when deep bindings like :style and
  44981. // :class are used on slot nodes
  44982. function registerDeepBindings (data) {
  44983. if (isObject(data.style)) {
  44984. traverse(data.style);
  44985. }
  44986. if (isObject(data.class)) {
  44987. traverse(data.class);
  44988. }
  44989. }
  44990. /* */
  44991. function initRender (vm) {
  44992. vm._vnode = null; // the root of the child tree
  44993. vm._staticTrees = null; // v-once cached trees
  44994. var options = vm.$options;
  44995. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  44996. var renderContext = parentVnode && parentVnode.context;
  44997. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  44998. vm.$scopedSlots = emptyObject;
  44999. // bind the createElement fn to this instance
  45000. // so that we get proper render context inside it.
  45001. // args order: tag, data, children, normalizationType, alwaysNormalize
  45002. // internal version is used by render functions compiled from templates
  45003. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  45004. // normalization is always applied for the public version, used in
  45005. // user-written render functions.
  45006. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  45007. // $attrs & $listeners are exposed for easier HOC creation.
  45008. // they need to be reactive so that HOCs using them are always updated
  45009. var parentData = parentVnode && parentVnode.data;
  45010. /* istanbul ignore else */
  45011. {
  45012. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  45013. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  45014. }, true);
  45015. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  45016. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  45017. }, true);
  45018. }
  45019. }
  45020. var currentRenderingInstance = null;
  45021. function renderMixin (Vue) {
  45022. // install runtime convenience helpers
  45023. installRenderHelpers(Vue.prototype);
  45024. Vue.prototype.$nextTick = function (fn) {
  45025. return nextTick(fn, this)
  45026. };
  45027. Vue.prototype._render = function () {
  45028. var vm = this;
  45029. var ref = vm.$options;
  45030. var render = ref.render;
  45031. var _parentVnode = ref._parentVnode;
  45032. if (_parentVnode) {
  45033. vm.$scopedSlots = normalizeScopedSlots(
  45034. _parentVnode.data.scopedSlots,
  45035. vm.$slots,
  45036. vm.$scopedSlots
  45037. );
  45038. }
  45039. // set parent vnode. this allows render functions to have access
  45040. // to the data on the placeholder node.
  45041. vm.$vnode = _parentVnode;
  45042. // render self
  45043. var vnode;
  45044. try {
  45045. // There's no need to maintain a stack because all render fns are called
  45046. // separately from one another. Nested component's render fns are called
  45047. // when parent component is patched.
  45048. currentRenderingInstance = vm;
  45049. vnode = render.call(vm._renderProxy, vm.$createElement);
  45050. } catch (e) {
  45051. handleError(e, vm, "render");
  45052. // return error render result,
  45053. // or previous vnode to prevent render error causing blank component
  45054. /* istanbul ignore else */
  45055. if (vm.$options.renderError) {
  45056. try {
  45057. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  45058. } catch (e) {
  45059. handleError(e, vm, "renderError");
  45060. vnode = vm._vnode;
  45061. }
  45062. } else {
  45063. vnode = vm._vnode;
  45064. }
  45065. } finally {
  45066. currentRenderingInstance = null;
  45067. }
  45068. // if the returned array contains only a single node, allow it
  45069. if (Array.isArray(vnode) && vnode.length === 1) {
  45070. vnode = vnode[0];
  45071. }
  45072. // return empty vnode in case the render function errored out
  45073. if (!(vnode instanceof VNode)) {
  45074. if (Array.isArray(vnode)) {
  45075. warn(
  45076. 'Multiple root nodes returned from render function. Render function ' +
  45077. 'should return a single root node.',
  45078. vm
  45079. );
  45080. }
  45081. vnode = createEmptyVNode();
  45082. }
  45083. // set parent
  45084. vnode.parent = _parentVnode;
  45085. return vnode
  45086. };
  45087. }
  45088. /* */
  45089. function ensureCtor (comp, base) {
  45090. if (
  45091. comp.__esModule ||
  45092. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  45093. ) {
  45094. comp = comp.default;
  45095. }
  45096. return isObject(comp)
  45097. ? base.extend(comp)
  45098. : comp
  45099. }
  45100. function createAsyncPlaceholder (
  45101. factory,
  45102. data,
  45103. context,
  45104. children,
  45105. tag
  45106. ) {
  45107. var node = createEmptyVNode();
  45108. node.asyncFactory = factory;
  45109. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  45110. return node
  45111. }
  45112. function resolveAsyncComponent (
  45113. factory,
  45114. baseCtor
  45115. ) {
  45116. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  45117. return factory.errorComp
  45118. }
  45119. if (isDef(factory.resolved)) {
  45120. return factory.resolved
  45121. }
  45122. var owner = currentRenderingInstance;
  45123. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  45124. // already pending
  45125. factory.owners.push(owner);
  45126. }
  45127. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  45128. return factory.loadingComp
  45129. }
  45130. if (owner && !isDef(factory.owners)) {
  45131. var owners = factory.owners = [owner];
  45132. var sync = true;
  45133. var timerLoading = null;
  45134. var timerTimeout = null
  45135. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  45136. var forceRender = function (renderCompleted) {
  45137. for (var i = 0, l = owners.length; i < l; i++) {
  45138. (owners[i]).$forceUpdate();
  45139. }
  45140. if (renderCompleted) {
  45141. owners.length = 0;
  45142. if (timerLoading !== null) {
  45143. clearTimeout(timerLoading);
  45144. timerLoading = null;
  45145. }
  45146. if (timerTimeout !== null) {
  45147. clearTimeout(timerTimeout);
  45148. timerTimeout = null;
  45149. }
  45150. }
  45151. };
  45152. var resolve = once(function (res) {
  45153. // cache resolved
  45154. factory.resolved = ensureCtor(res, baseCtor);
  45155. // invoke callbacks only if this is not a synchronous resolve
  45156. // (async resolves are shimmed as synchronous during SSR)
  45157. if (!sync) {
  45158. forceRender(true);
  45159. } else {
  45160. owners.length = 0;
  45161. }
  45162. });
  45163. var reject = once(function (reason) {
  45164. warn(
  45165. "Failed to resolve async component: " + (String(factory)) +
  45166. (reason ? ("\nReason: " + reason) : '')
  45167. );
  45168. if (isDef(factory.errorComp)) {
  45169. factory.error = true;
  45170. forceRender(true);
  45171. }
  45172. });
  45173. var res = factory(resolve, reject);
  45174. if (isObject(res)) {
  45175. if (isPromise(res)) {
  45176. // () => Promise
  45177. if (isUndef(factory.resolved)) {
  45178. res.then(resolve, reject);
  45179. }
  45180. } else if (isPromise(res.component)) {
  45181. res.component.then(resolve, reject);
  45182. if (isDef(res.error)) {
  45183. factory.errorComp = ensureCtor(res.error, baseCtor);
  45184. }
  45185. if (isDef(res.loading)) {
  45186. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45187. if (res.delay === 0) {
  45188. factory.loading = true;
  45189. } else {
  45190. timerLoading = setTimeout(function () {
  45191. timerLoading = null;
  45192. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45193. factory.loading = true;
  45194. forceRender(false);
  45195. }
  45196. }, res.delay || 200);
  45197. }
  45198. }
  45199. if (isDef(res.timeout)) {
  45200. timerTimeout = setTimeout(function () {
  45201. timerTimeout = null;
  45202. if (isUndef(factory.resolved)) {
  45203. reject(
  45204. "timeout (" + (res.timeout) + "ms)"
  45205. );
  45206. }
  45207. }, res.timeout);
  45208. }
  45209. }
  45210. }
  45211. sync = false;
  45212. // return in case resolved synchronously
  45213. return factory.loading
  45214. ? factory.loadingComp
  45215. : factory.resolved
  45216. }
  45217. }
  45218. /* */
  45219. function isAsyncPlaceholder (node) {
  45220. return node.isComment && node.asyncFactory
  45221. }
  45222. /* */
  45223. function getFirstComponentChild (children) {
  45224. if (Array.isArray(children)) {
  45225. for (var i = 0; i < children.length; i++) {
  45226. var c = children[i];
  45227. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45228. return c
  45229. }
  45230. }
  45231. }
  45232. }
  45233. /* */
  45234. /* */
  45235. function initEvents (vm) {
  45236. vm._events = Object.create(null);
  45237. vm._hasHookEvent = false;
  45238. // init parent attached events
  45239. var listeners = vm.$options._parentListeners;
  45240. if (listeners) {
  45241. updateComponentListeners(vm, listeners);
  45242. }
  45243. }
  45244. var target;
  45245. function add (event, fn) {
  45246. target.$on(event, fn);
  45247. }
  45248. function remove$1 (event, fn) {
  45249. target.$off(event, fn);
  45250. }
  45251. function createOnceHandler (event, fn) {
  45252. var _target = target;
  45253. return function onceHandler () {
  45254. var res = fn.apply(null, arguments);
  45255. if (res !== null) {
  45256. _target.$off(event, onceHandler);
  45257. }
  45258. }
  45259. }
  45260. function updateComponentListeners (
  45261. vm,
  45262. listeners,
  45263. oldListeners
  45264. ) {
  45265. target = vm;
  45266. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45267. target = undefined;
  45268. }
  45269. function eventsMixin (Vue) {
  45270. var hookRE = /^hook:/;
  45271. Vue.prototype.$on = function (event, fn) {
  45272. var vm = this;
  45273. if (Array.isArray(event)) {
  45274. for (var i = 0, l = event.length; i < l; i++) {
  45275. vm.$on(event[i], fn);
  45276. }
  45277. } else {
  45278. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45279. // optimize hook:event cost by using a boolean flag marked at registration
  45280. // instead of a hash lookup
  45281. if (hookRE.test(event)) {
  45282. vm._hasHookEvent = true;
  45283. }
  45284. }
  45285. return vm
  45286. };
  45287. Vue.prototype.$once = function (event, fn) {
  45288. var vm = this;
  45289. function on () {
  45290. vm.$off(event, on);
  45291. fn.apply(vm, arguments);
  45292. }
  45293. on.fn = fn;
  45294. vm.$on(event, on);
  45295. return vm
  45296. };
  45297. Vue.prototype.$off = function (event, fn) {
  45298. var vm = this;
  45299. // all
  45300. if (!arguments.length) {
  45301. vm._events = Object.create(null);
  45302. return vm
  45303. }
  45304. // array of events
  45305. if (Array.isArray(event)) {
  45306. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45307. vm.$off(event[i$1], fn);
  45308. }
  45309. return vm
  45310. }
  45311. // specific event
  45312. var cbs = vm._events[event];
  45313. if (!cbs) {
  45314. return vm
  45315. }
  45316. if (!fn) {
  45317. vm._events[event] = null;
  45318. return vm
  45319. }
  45320. // specific handler
  45321. var cb;
  45322. var i = cbs.length;
  45323. while (i--) {
  45324. cb = cbs[i];
  45325. if (cb === fn || cb.fn === fn) {
  45326. cbs.splice(i, 1);
  45327. break
  45328. }
  45329. }
  45330. return vm
  45331. };
  45332. Vue.prototype.$emit = function (event) {
  45333. var vm = this;
  45334. {
  45335. var lowerCaseEvent = event.toLowerCase();
  45336. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45337. tip(
  45338. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45339. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45340. "Note that HTML attributes are case-insensitive and you cannot use " +
  45341. "v-on to listen to camelCase events when using in-DOM templates. " +
  45342. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45343. );
  45344. }
  45345. }
  45346. var cbs = vm._events[event];
  45347. if (cbs) {
  45348. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45349. var args = toArray(arguments, 1);
  45350. var info = "event handler for \"" + event + "\"";
  45351. for (var i = 0, l = cbs.length; i < l; i++) {
  45352. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45353. }
  45354. }
  45355. return vm
  45356. };
  45357. }
  45358. /* */
  45359. var activeInstance = null;
  45360. var isUpdatingChildComponent = false;
  45361. function setActiveInstance(vm) {
  45362. var prevActiveInstance = activeInstance;
  45363. activeInstance = vm;
  45364. return function () {
  45365. activeInstance = prevActiveInstance;
  45366. }
  45367. }
  45368. function initLifecycle (vm) {
  45369. var options = vm.$options;
  45370. // locate first non-abstract parent
  45371. var parent = options.parent;
  45372. if (parent && !options.abstract) {
  45373. while (parent.$options.abstract && parent.$parent) {
  45374. parent = parent.$parent;
  45375. }
  45376. parent.$children.push(vm);
  45377. }
  45378. vm.$parent = parent;
  45379. vm.$root = parent ? parent.$root : vm;
  45380. vm.$children = [];
  45381. vm.$refs = {};
  45382. vm._watcher = null;
  45383. vm._inactive = null;
  45384. vm._directInactive = false;
  45385. vm._isMounted = false;
  45386. vm._isDestroyed = false;
  45387. vm._isBeingDestroyed = false;
  45388. }
  45389. function lifecycleMixin (Vue) {
  45390. Vue.prototype._update = function (vnode, hydrating) {
  45391. var vm = this;
  45392. var prevEl = vm.$el;
  45393. var prevVnode = vm._vnode;
  45394. var restoreActiveInstance = setActiveInstance(vm);
  45395. vm._vnode = vnode;
  45396. // Vue.prototype.__patch__ is injected in entry points
  45397. // based on the rendering backend used.
  45398. if (!prevVnode) {
  45399. // initial render
  45400. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45401. } else {
  45402. // updates
  45403. vm.$el = vm.__patch__(prevVnode, vnode);
  45404. }
  45405. restoreActiveInstance();
  45406. // update __vue__ reference
  45407. if (prevEl) {
  45408. prevEl.__vue__ = null;
  45409. }
  45410. if (vm.$el) {
  45411. vm.$el.__vue__ = vm;
  45412. }
  45413. // if parent is an HOC, update its $el as well
  45414. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45415. vm.$parent.$el = vm.$el;
  45416. }
  45417. // updated hook is called by the scheduler to ensure that children are
  45418. // updated in a parent's updated hook.
  45419. };
  45420. Vue.prototype.$forceUpdate = function () {
  45421. var vm = this;
  45422. if (vm._watcher) {
  45423. vm._watcher.update();
  45424. }
  45425. };
  45426. Vue.prototype.$destroy = function () {
  45427. var vm = this;
  45428. if (vm._isBeingDestroyed) {
  45429. return
  45430. }
  45431. callHook(vm, 'beforeDestroy');
  45432. vm._isBeingDestroyed = true;
  45433. // remove self from parent
  45434. var parent = vm.$parent;
  45435. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45436. remove(parent.$children, vm);
  45437. }
  45438. // teardown watchers
  45439. if (vm._watcher) {
  45440. vm._watcher.teardown();
  45441. }
  45442. var i = vm._watchers.length;
  45443. while (i--) {
  45444. vm._watchers[i].teardown();
  45445. }
  45446. // remove reference from data ob
  45447. // frozen object may not have observer.
  45448. if (vm._data.__ob__) {
  45449. vm._data.__ob__.vmCount--;
  45450. }
  45451. // call the last hook...
  45452. vm._isDestroyed = true;
  45453. // invoke destroy hooks on current rendered tree
  45454. vm.__patch__(vm._vnode, null);
  45455. // fire destroyed hook
  45456. callHook(vm, 'destroyed');
  45457. // turn off all instance listeners.
  45458. vm.$off();
  45459. // remove __vue__ reference
  45460. if (vm.$el) {
  45461. vm.$el.__vue__ = null;
  45462. }
  45463. // release circular reference (#6759)
  45464. if (vm.$vnode) {
  45465. vm.$vnode.parent = null;
  45466. }
  45467. };
  45468. }
  45469. function mountComponent (
  45470. vm,
  45471. el,
  45472. hydrating
  45473. ) {
  45474. vm.$el = el;
  45475. if (!vm.$options.render) {
  45476. vm.$options.render = createEmptyVNode;
  45477. {
  45478. /* istanbul ignore if */
  45479. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45480. vm.$options.el || el) {
  45481. warn(
  45482. 'You are using the runtime-only build of Vue where the template ' +
  45483. 'compiler is not available. Either pre-compile the templates into ' +
  45484. 'render functions, or use the compiler-included build.',
  45485. vm
  45486. );
  45487. } else {
  45488. warn(
  45489. 'Failed to mount component: template or render function not defined.',
  45490. vm
  45491. );
  45492. }
  45493. }
  45494. }
  45495. callHook(vm, 'beforeMount');
  45496. var updateComponent;
  45497. /* istanbul ignore if */
  45498. if (config.performance && mark) {
  45499. updateComponent = function () {
  45500. var name = vm._name;
  45501. var id = vm._uid;
  45502. var startTag = "vue-perf-start:" + id;
  45503. var endTag = "vue-perf-end:" + id;
  45504. mark(startTag);
  45505. var vnode = vm._render();
  45506. mark(endTag);
  45507. measure(("vue " + name + " render"), startTag, endTag);
  45508. mark(startTag);
  45509. vm._update(vnode, hydrating);
  45510. mark(endTag);
  45511. measure(("vue " + name + " patch"), startTag, endTag);
  45512. };
  45513. } else {
  45514. updateComponent = function () {
  45515. vm._update(vm._render(), hydrating);
  45516. };
  45517. }
  45518. // we set this to vm._watcher inside the watcher's constructor
  45519. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45520. // component's mounted hook), which relies on vm._watcher being already defined
  45521. new Watcher(vm, updateComponent, noop, {
  45522. before: function before () {
  45523. if (vm._isMounted && !vm._isDestroyed) {
  45524. callHook(vm, 'beforeUpdate');
  45525. }
  45526. }
  45527. }, true /* isRenderWatcher */);
  45528. hydrating = false;
  45529. // manually mounted instance, call mounted on self
  45530. // mounted is called for render-created child components in its inserted hook
  45531. if (vm.$vnode == null) {
  45532. vm._isMounted = true;
  45533. callHook(vm, 'mounted');
  45534. }
  45535. return vm
  45536. }
  45537. function updateChildComponent (
  45538. vm,
  45539. propsData,
  45540. listeners,
  45541. parentVnode,
  45542. renderChildren
  45543. ) {
  45544. {
  45545. isUpdatingChildComponent = true;
  45546. }
  45547. // determine whether component has slot children
  45548. // we need to do this before overwriting $options._renderChildren.
  45549. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45550. // dynamic slot names). Static scoped slots compiled from template has the
  45551. // "$stable" marker.
  45552. var newScopedSlots = parentVnode.data.scopedSlots;
  45553. var oldScopedSlots = vm.$scopedSlots;
  45554. var hasDynamicScopedSlot = !!(
  45555. (newScopedSlots && !newScopedSlots.$stable) ||
  45556. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45557. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45558. );
  45559. // Any static slot children from the parent may have changed during parent's
  45560. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45561. // update is necessary to ensure correctness.
  45562. var needsForceUpdate = !!(
  45563. renderChildren || // has new static slots
  45564. vm.$options._renderChildren || // has old static slots
  45565. hasDynamicScopedSlot
  45566. );
  45567. vm.$options._parentVnode = parentVnode;
  45568. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45569. if (vm._vnode) { // update child tree's parent
  45570. vm._vnode.parent = parentVnode;
  45571. }
  45572. vm.$options._renderChildren = renderChildren;
  45573. // update $attrs and $listeners hash
  45574. // these are also reactive so they may trigger child update if the child
  45575. // used them during render
  45576. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45577. vm.$listeners = listeners || emptyObject;
  45578. // update props
  45579. if (propsData && vm.$options.props) {
  45580. toggleObserving(false);
  45581. var props = vm._props;
  45582. var propKeys = vm.$options._propKeys || [];
  45583. for (var i = 0; i < propKeys.length; i++) {
  45584. var key = propKeys[i];
  45585. var propOptions = vm.$options.props; // wtf flow?
  45586. props[key] = validateProp(key, propOptions, propsData, vm);
  45587. }
  45588. toggleObserving(true);
  45589. // keep a copy of raw propsData
  45590. vm.$options.propsData = propsData;
  45591. }
  45592. // update listeners
  45593. listeners = listeners || emptyObject;
  45594. var oldListeners = vm.$options._parentListeners;
  45595. vm.$options._parentListeners = listeners;
  45596. updateComponentListeners(vm, listeners, oldListeners);
  45597. // resolve slots + force update if has children
  45598. if (needsForceUpdate) {
  45599. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45600. vm.$forceUpdate();
  45601. }
  45602. {
  45603. isUpdatingChildComponent = false;
  45604. }
  45605. }
  45606. function isInInactiveTree (vm) {
  45607. while (vm && (vm = vm.$parent)) {
  45608. if (vm._inactive) { return true }
  45609. }
  45610. return false
  45611. }
  45612. function activateChildComponent (vm, direct) {
  45613. if (direct) {
  45614. vm._directInactive = false;
  45615. if (isInInactiveTree(vm)) {
  45616. return
  45617. }
  45618. } else if (vm._directInactive) {
  45619. return
  45620. }
  45621. if (vm._inactive || vm._inactive === null) {
  45622. vm._inactive = false;
  45623. for (var i = 0; i < vm.$children.length; i++) {
  45624. activateChildComponent(vm.$children[i]);
  45625. }
  45626. callHook(vm, 'activated');
  45627. }
  45628. }
  45629. function deactivateChildComponent (vm, direct) {
  45630. if (direct) {
  45631. vm._directInactive = true;
  45632. if (isInInactiveTree(vm)) {
  45633. return
  45634. }
  45635. }
  45636. if (!vm._inactive) {
  45637. vm._inactive = true;
  45638. for (var i = 0; i < vm.$children.length; i++) {
  45639. deactivateChildComponent(vm.$children[i]);
  45640. }
  45641. callHook(vm, 'deactivated');
  45642. }
  45643. }
  45644. function callHook (vm, hook) {
  45645. // #7573 disable dep collection when invoking lifecycle hooks
  45646. pushTarget();
  45647. var handlers = vm.$options[hook];
  45648. var info = hook + " hook";
  45649. if (handlers) {
  45650. for (var i = 0, j = handlers.length; i < j; i++) {
  45651. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45652. }
  45653. }
  45654. if (vm._hasHookEvent) {
  45655. vm.$emit('hook:' + hook);
  45656. }
  45657. popTarget();
  45658. }
  45659. /* */
  45660. var MAX_UPDATE_COUNT = 100;
  45661. var queue = [];
  45662. var activatedChildren = [];
  45663. var has = {};
  45664. var circular = {};
  45665. var waiting = false;
  45666. var flushing = false;
  45667. var index = 0;
  45668. /**
  45669. * Reset the scheduler's state.
  45670. */
  45671. function resetSchedulerState () {
  45672. index = queue.length = activatedChildren.length = 0;
  45673. has = {};
  45674. {
  45675. circular = {};
  45676. }
  45677. waiting = flushing = false;
  45678. }
  45679. // Async edge case #6566 requires saving the timestamp when event listeners are
  45680. // attached. However, calling performance.now() has a perf overhead especially
  45681. // if the page has thousands of event listeners. Instead, we take a timestamp
  45682. // every time the scheduler flushes and use that for all event listeners
  45683. // attached during that flush.
  45684. var currentFlushTimestamp = 0;
  45685. // Async edge case fix requires storing an event listener's attach timestamp.
  45686. var getNow = Date.now;
  45687. // Determine what event timestamp the browser is using. Annoyingly, the
  45688. // timestamp can either be hi-res (relative to page load) or low-res
  45689. // (relative to UNIX epoch), so in order to compare time we have to use the
  45690. // same timestamp type when saving the flush timestamp.
  45691. // All IE versions use low-res event timestamps, and have problematic clock
  45692. // implementations (#9632)
  45693. if (inBrowser && !isIE) {
  45694. var performance = window.performance;
  45695. if (
  45696. performance &&
  45697. typeof performance.now === 'function' &&
  45698. getNow() > document.createEvent('Event').timeStamp
  45699. ) {
  45700. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45701. // smaller than it, it means the event is using a hi-res timestamp,
  45702. // and we need to use the hi-res version for event listener timestamps as
  45703. // well.
  45704. getNow = function () { return performance.now(); };
  45705. }
  45706. }
  45707. /**
  45708. * Flush both queues and run the watchers.
  45709. */
  45710. function flushSchedulerQueue () {
  45711. currentFlushTimestamp = getNow();
  45712. flushing = true;
  45713. var watcher, id;
  45714. // Sort queue before flush.
  45715. // This ensures that:
  45716. // 1. Components are updated from parent to child. (because parent is always
  45717. // created before the child)
  45718. // 2. A component's user watchers are run before its render watcher (because
  45719. // user watchers are created before the render watcher)
  45720. // 3. If a component is destroyed during a parent component's watcher run,
  45721. // its watchers can be skipped.
  45722. queue.sort(function (a, b) { return a.id - b.id; });
  45723. // do not cache length because more watchers might be pushed
  45724. // as we run existing watchers
  45725. for (index = 0; index < queue.length; index++) {
  45726. watcher = queue[index];
  45727. if (watcher.before) {
  45728. watcher.before();
  45729. }
  45730. id = watcher.id;
  45731. has[id] = null;
  45732. watcher.run();
  45733. // in dev build, check and stop circular updates.
  45734. if (has[id] != null) {
  45735. circular[id] = (circular[id] || 0) + 1;
  45736. if (circular[id] > MAX_UPDATE_COUNT) {
  45737. warn(
  45738. 'You may have an infinite update loop ' + (
  45739. watcher.user
  45740. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45741. : "in a component render function."
  45742. ),
  45743. watcher.vm
  45744. );
  45745. break
  45746. }
  45747. }
  45748. }
  45749. // keep copies of post queues before resetting state
  45750. var activatedQueue = activatedChildren.slice();
  45751. var updatedQueue = queue.slice();
  45752. resetSchedulerState();
  45753. // call component updated and activated hooks
  45754. callActivatedHooks(activatedQueue);
  45755. callUpdatedHooks(updatedQueue);
  45756. // devtool hook
  45757. /* istanbul ignore if */
  45758. if (devtools && config.devtools) {
  45759. devtools.emit('flush');
  45760. }
  45761. }
  45762. function callUpdatedHooks (queue) {
  45763. var i = queue.length;
  45764. while (i--) {
  45765. var watcher = queue[i];
  45766. var vm = watcher.vm;
  45767. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45768. callHook(vm, 'updated');
  45769. }
  45770. }
  45771. }
  45772. /**
  45773. * Queue a kept-alive component that was activated during patch.
  45774. * The queue will be processed after the entire tree has been patched.
  45775. */
  45776. function queueActivatedComponent (vm) {
  45777. // setting _inactive to false here so that a render function can
  45778. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45779. vm._inactive = false;
  45780. activatedChildren.push(vm);
  45781. }
  45782. function callActivatedHooks (queue) {
  45783. for (var i = 0; i < queue.length; i++) {
  45784. queue[i]._inactive = true;
  45785. activateChildComponent(queue[i], true /* true */);
  45786. }
  45787. }
  45788. /**
  45789. * Push a watcher into the watcher queue.
  45790. * Jobs with duplicate IDs will be skipped unless it's
  45791. * pushed when the queue is being flushed.
  45792. */
  45793. function queueWatcher (watcher) {
  45794. var id = watcher.id;
  45795. if (has[id] == null) {
  45796. has[id] = true;
  45797. if (!flushing) {
  45798. queue.push(watcher);
  45799. } else {
  45800. // if already flushing, splice the watcher based on its id
  45801. // if already past its id, it will be run next immediately.
  45802. var i = queue.length - 1;
  45803. while (i > index && queue[i].id > watcher.id) {
  45804. i--;
  45805. }
  45806. queue.splice(i + 1, 0, watcher);
  45807. }
  45808. // queue the flush
  45809. if (!waiting) {
  45810. waiting = true;
  45811. if (!config.async) {
  45812. flushSchedulerQueue();
  45813. return
  45814. }
  45815. nextTick(flushSchedulerQueue);
  45816. }
  45817. }
  45818. }
  45819. /* */
  45820. var uid$2 = 0;
  45821. /**
  45822. * A watcher parses an expression, collects dependencies,
  45823. * and fires callback when the expression value changes.
  45824. * This is used for both the $watch() api and directives.
  45825. */
  45826. var Watcher = function Watcher (
  45827. vm,
  45828. expOrFn,
  45829. cb,
  45830. options,
  45831. isRenderWatcher
  45832. ) {
  45833. this.vm = vm;
  45834. if (isRenderWatcher) {
  45835. vm._watcher = this;
  45836. }
  45837. vm._watchers.push(this);
  45838. // options
  45839. if (options) {
  45840. this.deep = !!options.deep;
  45841. this.user = !!options.user;
  45842. this.lazy = !!options.lazy;
  45843. this.sync = !!options.sync;
  45844. this.before = options.before;
  45845. } else {
  45846. this.deep = this.user = this.lazy = this.sync = false;
  45847. }
  45848. this.cb = cb;
  45849. this.id = ++uid$2; // uid for batching
  45850. this.active = true;
  45851. this.dirty = this.lazy; // for lazy watchers
  45852. this.deps = [];
  45853. this.newDeps = [];
  45854. this.depIds = new _Set();
  45855. this.newDepIds = new _Set();
  45856. this.expression = expOrFn.toString();
  45857. // parse expression for getter
  45858. if (typeof expOrFn === 'function') {
  45859. this.getter = expOrFn;
  45860. } else {
  45861. this.getter = parsePath(expOrFn);
  45862. if (!this.getter) {
  45863. this.getter = noop;
  45864. warn(
  45865. "Failed watching path: \"" + expOrFn + "\" " +
  45866. 'Watcher only accepts simple dot-delimited paths. ' +
  45867. 'For full control, use a function instead.',
  45868. vm
  45869. );
  45870. }
  45871. }
  45872. this.value = this.lazy
  45873. ? undefined
  45874. : this.get();
  45875. };
  45876. /**
  45877. * Evaluate the getter, and re-collect dependencies.
  45878. */
  45879. Watcher.prototype.get = function get () {
  45880. pushTarget(this);
  45881. var value;
  45882. var vm = this.vm;
  45883. try {
  45884. value = this.getter.call(vm, vm);
  45885. } catch (e) {
  45886. if (this.user) {
  45887. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45888. } else {
  45889. throw e
  45890. }
  45891. } finally {
  45892. // "touch" every property so they are all tracked as
  45893. // dependencies for deep watching
  45894. if (this.deep) {
  45895. traverse(value);
  45896. }
  45897. popTarget();
  45898. this.cleanupDeps();
  45899. }
  45900. return value
  45901. };
  45902. /**
  45903. * Add a dependency to this directive.
  45904. */
  45905. Watcher.prototype.addDep = function addDep (dep) {
  45906. var id = dep.id;
  45907. if (!this.newDepIds.has(id)) {
  45908. this.newDepIds.add(id);
  45909. this.newDeps.push(dep);
  45910. if (!this.depIds.has(id)) {
  45911. dep.addSub(this);
  45912. }
  45913. }
  45914. };
  45915. /**
  45916. * Clean up for dependency collection.
  45917. */
  45918. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  45919. var i = this.deps.length;
  45920. while (i--) {
  45921. var dep = this.deps[i];
  45922. if (!this.newDepIds.has(dep.id)) {
  45923. dep.removeSub(this);
  45924. }
  45925. }
  45926. var tmp = this.depIds;
  45927. this.depIds = this.newDepIds;
  45928. this.newDepIds = tmp;
  45929. this.newDepIds.clear();
  45930. tmp = this.deps;
  45931. this.deps = this.newDeps;
  45932. this.newDeps = tmp;
  45933. this.newDeps.length = 0;
  45934. };
  45935. /**
  45936. * Subscriber interface.
  45937. * Will be called when a dependency changes.
  45938. */
  45939. Watcher.prototype.update = function update () {
  45940. /* istanbul ignore else */
  45941. if (this.lazy) {
  45942. this.dirty = true;
  45943. } else if (this.sync) {
  45944. this.run();
  45945. } else {
  45946. queueWatcher(this);
  45947. }
  45948. };
  45949. /**
  45950. * Scheduler job interface.
  45951. * Will be called by the scheduler.
  45952. */
  45953. Watcher.prototype.run = function run () {
  45954. if (this.active) {
  45955. var value = this.get();
  45956. if (
  45957. value !== this.value ||
  45958. // Deep watchers and watchers on Object/Arrays should fire even
  45959. // when the value is the same, because the value may
  45960. // have mutated.
  45961. isObject(value) ||
  45962. this.deep
  45963. ) {
  45964. // set new value
  45965. var oldValue = this.value;
  45966. this.value = value;
  45967. if (this.user) {
  45968. try {
  45969. this.cb.call(this.vm, value, oldValue);
  45970. } catch (e) {
  45971. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  45972. }
  45973. } else {
  45974. this.cb.call(this.vm, value, oldValue);
  45975. }
  45976. }
  45977. }
  45978. };
  45979. /**
  45980. * Evaluate the value of the watcher.
  45981. * This only gets called for lazy watchers.
  45982. */
  45983. Watcher.prototype.evaluate = function evaluate () {
  45984. this.value = this.get();
  45985. this.dirty = false;
  45986. };
  45987. /**
  45988. * Depend on all deps collected by this watcher.
  45989. */
  45990. Watcher.prototype.depend = function depend () {
  45991. var i = this.deps.length;
  45992. while (i--) {
  45993. this.deps[i].depend();
  45994. }
  45995. };
  45996. /**
  45997. * Remove self from all dependencies' subscriber list.
  45998. */
  45999. Watcher.prototype.teardown = function teardown () {
  46000. if (this.active) {
  46001. // remove self from vm's watcher list
  46002. // this is a somewhat expensive operation so we skip it
  46003. // if the vm is being destroyed.
  46004. if (!this.vm._isBeingDestroyed) {
  46005. remove(this.vm._watchers, this);
  46006. }
  46007. var i = this.deps.length;
  46008. while (i--) {
  46009. this.deps[i].removeSub(this);
  46010. }
  46011. this.active = false;
  46012. }
  46013. };
  46014. /* */
  46015. var sharedPropertyDefinition = {
  46016. enumerable: true,
  46017. configurable: true,
  46018. get: noop,
  46019. set: noop
  46020. };
  46021. function proxy (target, sourceKey, key) {
  46022. sharedPropertyDefinition.get = function proxyGetter () {
  46023. return this[sourceKey][key]
  46024. };
  46025. sharedPropertyDefinition.set = function proxySetter (val) {
  46026. this[sourceKey][key] = val;
  46027. };
  46028. Object.defineProperty(target, key, sharedPropertyDefinition);
  46029. }
  46030. function initState (vm) {
  46031. vm._watchers = [];
  46032. var opts = vm.$options;
  46033. if (opts.props) { initProps(vm, opts.props); }
  46034. if (opts.methods) { initMethods(vm, opts.methods); }
  46035. if (opts.data) {
  46036. initData(vm);
  46037. } else {
  46038. observe(vm._data = {}, true /* asRootData */);
  46039. }
  46040. if (opts.computed) { initComputed(vm, opts.computed); }
  46041. if (opts.watch && opts.watch !== nativeWatch) {
  46042. initWatch(vm, opts.watch);
  46043. }
  46044. }
  46045. function initProps (vm, propsOptions) {
  46046. var propsData = vm.$options.propsData || {};
  46047. var props = vm._props = {};
  46048. // cache prop keys so that future props updates can iterate using Array
  46049. // instead of dynamic object key enumeration.
  46050. var keys = vm.$options._propKeys = [];
  46051. var isRoot = !vm.$parent;
  46052. // root instance props should be converted
  46053. if (!isRoot) {
  46054. toggleObserving(false);
  46055. }
  46056. var loop = function ( key ) {
  46057. keys.push(key);
  46058. var value = validateProp(key, propsOptions, propsData, vm);
  46059. /* istanbul ignore else */
  46060. {
  46061. var hyphenatedKey = hyphenate(key);
  46062. if (isReservedAttribute(hyphenatedKey) ||
  46063. config.isReservedAttr(hyphenatedKey)) {
  46064. warn(
  46065. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  46066. vm
  46067. );
  46068. }
  46069. defineReactive$$1(props, key, value, function () {
  46070. if (!isRoot && !isUpdatingChildComponent) {
  46071. warn(
  46072. "Avoid mutating a prop directly since the value will be " +
  46073. "overwritten whenever the parent component re-renders. " +
  46074. "Instead, use a data or computed property based on the prop's " +
  46075. "value. Prop being mutated: \"" + key + "\"",
  46076. vm
  46077. );
  46078. }
  46079. });
  46080. }
  46081. // static props are already proxied on the component's prototype
  46082. // during Vue.extend(). We only need to proxy props defined at
  46083. // instantiation here.
  46084. if (!(key in vm)) {
  46085. proxy(vm, "_props", key);
  46086. }
  46087. };
  46088. for (var key in propsOptions) loop( key );
  46089. toggleObserving(true);
  46090. }
  46091. function initData (vm) {
  46092. var data = vm.$options.data;
  46093. data = vm._data = typeof data === 'function'
  46094. ? getData(data, vm)
  46095. : data || {};
  46096. if (!isPlainObject(data)) {
  46097. data = {};
  46098. warn(
  46099. 'data functions should return an object:\n' +
  46100. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  46101. vm
  46102. );
  46103. }
  46104. // proxy data on instance
  46105. var keys = Object.keys(data);
  46106. var props = vm.$options.props;
  46107. var methods = vm.$options.methods;
  46108. var i = keys.length;
  46109. while (i--) {
  46110. var key = keys[i];
  46111. {
  46112. if (methods && hasOwn(methods, key)) {
  46113. warn(
  46114. ("Method \"" + key + "\" has already been defined as a data property."),
  46115. vm
  46116. );
  46117. }
  46118. }
  46119. if (props && hasOwn(props, key)) {
  46120. warn(
  46121. "The data property \"" + key + "\" is already declared as a prop. " +
  46122. "Use prop default value instead.",
  46123. vm
  46124. );
  46125. } else if (!isReserved(key)) {
  46126. proxy(vm, "_data", key);
  46127. }
  46128. }
  46129. // observe data
  46130. observe(data, true /* asRootData */);
  46131. }
  46132. function getData (data, vm) {
  46133. // #7573 disable dep collection when invoking data getters
  46134. pushTarget();
  46135. try {
  46136. return data.call(vm, vm)
  46137. } catch (e) {
  46138. handleError(e, vm, "data()");
  46139. return {}
  46140. } finally {
  46141. popTarget();
  46142. }
  46143. }
  46144. var computedWatcherOptions = { lazy: true };
  46145. function initComputed (vm, computed) {
  46146. // $flow-disable-line
  46147. var watchers = vm._computedWatchers = Object.create(null);
  46148. // computed properties are just getters during SSR
  46149. var isSSR = isServerRendering();
  46150. for (var key in computed) {
  46151. var userDef = computed[key];
  46152. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46153. if (getter == null) {
  46154. warn(
  46155. ("Getter is missing for computed property \"" + key + "\"."),
  46156. vm
  46157. );
  46158. }
  46159. if (!isSSR) {
  46160. // create internal watcher for the computed property.
  46161. watchers[key] = new Watcher(
  46162. vm,
  46163. getter || noop,
  46164. noop,
  46165. computedWatcherOptions
  46166. );
  46167. }
  46168. // component-defined computed properties are already defined on the
  46169. // component prototype. We only need to define computed properties defined
  46170. // at instantiation here.
  46171. if (!(key in vm)) {
  46172. defineComputed(vm, key, userDef);
  46173. } else {
  46174. if (key in vm.$data) {
  46175. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46176. } else if (vm.$options.props && key in vm.$options.props) {
  46177. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46178. }
  46179. }
  46180. }
  46181. }
  46182. function defineComputed (
  46183. target,
  46184. key,
  46185. userDef
  46186. ) {
  46187. var shouldCache = !isServerRendering();
  46188. if (typeof userDef === 'function') {
  46189. sharedPropertyDefinition.get = shouldCache
  46190. ? createComputedGetter(key)
  46191. : createGetterInvoker(userDef);
  46192. sharedPropertyDefinition.set = noop;
  46193. } else {
  46194. sharedPropertyDefinition.get = userDef.get
  46195. ? shouldCache && userDef.cache !== false
  46196. ? createComputedGetter(key)
  46197. : createGetterInvoker(userDef.get)
  46198. : noop;
  46199. sharedPropertyDefinition.set = userDef.set || noop;
  46200. }
  46201. if (sharedPropertyDefinition.set === noop) {
  46202. sharedPropertyDefinition.set = function () {
  46203. warn(
  46204. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46205. this
  46206. );
  46207. };
  46208. }
  46209. Object.defineProperty(target, key, sharedPropertyDefinition);
  46210. }
  46211. function createComputedGetter (key) {
  46212. return function computedGetter () {
  46213. var watcher = this._computedWatchers && this._computedWatchers[key];
  46214. if (watcher) {
  46215. if (watcher.dirty) {
  46216. watcher.evaluate();
  46217. }
  46218. if (Dep.target) {
  46219. watcher.depend();
  46220. }
  46221. return watcher.value
  46222. }
  46223. }
  46224. }
  46225. function createGetterInvoker(fn) {
  46226. return function computedGetter () {
  46227. return fn.call(this, this)
  46228. }
  46229. }
  46230. function initMethods (vm, methods) {
  46231. var props = vm.$options.props;
  46232. for (var key in methods) {
  46233. {
  46234. if (typeof methods[key] !== 'function') {
  46235. warn(
  46236. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46237. "Did you reference the function correctly?",
  46238. vm
  46239. );
  46240. }
  46241. if (props && hasOwn(props, key)) {
  46242. warn(
  46243. ("Method \"" + key + "\" has already been defined as a prop."),
  46244. vm
  46245. );
  46246. }
  46247. if ((key in vm) && isReserved(key)) {
  46248. warn(
  46249. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46250. "Avoid defining component methods that start with _ or $."
  46251. );
  46252. }
  46253. }
  46254. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46255. }
  46256. }
  46257. function initWatch (vm, watch) {
  46258. for (var key in watch) {
  46259. var handler = watch[key];
  46260. if (Array.isArray(handler)) {
  46261. for (var i = 0; i < handler.length; i++) {
  46262. createWatcher(vm, key, handler[i]);
  46263. }
  46264. } else {
  46265. createWatcher(vm, key, handler);
  46266. }
  46267. }
  46268. }
  46269. function createWatcher (
  46270. vm,
  46271. expOrFn,
  46272. handler,
  46273. options
  46274. ) {
  46275. if (isPlainObject(handler)) {
  46276. options = handler;
  46277. handler = handler.handler;
  46278. }
  46279. if (typeof handler === 'string') {
  46280. handler = vm[handler];
  46281. }
  46282. return vm.$watch(expOrFn, handler, options)
  46283. }
  46284. function stateMixin (Vue) {
  46285. // flow somehow has problems with directly declared definition object
  46286. // when using Object.defineProperty, so we have to procedurally build up
  46287. // the object here.
  46288. var dataDef = {};
  46289. dataDef.get = function () { return this._data };
  46290. var propsDef = {};
  46291. propsDef.get = function () { return this._props };
  46292. {
  46293. dataDef.set = function () {
  46294. warn(
  46295. 'Avoid replacing instance root $data. ' +
  46296. 'Use nested data properties instead.',
  46297. this
  46298. );
  46299. };
  46300. propsDef.set = function () {
  46301. warn("$props is readonly.", this);
  46302. };
  46303. }
  46304. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46305. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46306. Vue.prototype.$set = set;
  46307. Vue.prototype.$delete = del;
  46308. Vue.prototype.$watch = function (
  46309. expOrFn,
  46310. cb,
  46311. options
  46312. ) {
  46313. var vm = this;
  46314. if (isPlainObject(cb)) {
  46315. return createWatcher(vm, expOrFn, cb, options)
  46316. }
  46317. options = options || {};
  46318. options.user = true;
  46319. var watcher = new Watcher(vm, expOrFn, cb, options);
  46320. if (options.immediate) {
  46321. try {
  46322. cb.call(vm, watcher.value);
  46323. } catch (error) {
  46324. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46325. }
  46326. }
  46327. return function unwatchFn () {
  46328. watcher.teardown();
  46329. }
  46330. };
  46331. }
  46332. /* */
  46333. var uid$3 = 0;
  46334. function initMixin (Vue) {
  46335. Vue.prototype._init = function (options) {
  46336. var vm = this;
  46337. // a uid
  46338. vm._uid = uid$3++;
  46339. var startTag, endTag;
  46340. /* istanbul ignore if */
  46341. if (config.performance && mark) {
  46342. startTag = "vue-perf-start:" + (vm._uid);
  46343. endTag = "vue-perf-end:" + (vm._uid);
  46344. mark(startTag);
  46345. }
  46346. // a flag to avoid this being observed
  46347. vm._isVue = true;
  46348. // merge options
  46349. if (options && options._isComponent) {
  46350. // optimize internal component instantiation
  46351. // since dynamic options merging is pretty slow, and none of the
  46352. // internal component options needs special treatment.
  46353. initInternalComponent(vm, options);
  46354. } else {
  46355. vm.$options = mergeOptions(
  46356. resolveConstructorOptions(vm.constructor),
  46357. options || {},
  46358. vm
  46359. );
  46360. }
  46361. /* istanbul ignore else */
  46362. {
  46363. initProxy(vm);
  46364. }
  46365. // expose real self
  46366. vm._self = vm;
  46367. initLifecycle(vm);
  46368. initEvents(vm);
  46369. initRender(vm);
  46370. callHook(vm, 'beforeCreate');
  46371. initInjections(vm); // resolve injections before data/props
  46372. initState(vm);
  46373. initProvide(vm); // resolve provide after data/props
  46374. callHook(vm, 'created');
  46375. /* istanbul ignore if */
  46376. if (config.performance && mark) {
  46377. vm._name = formatComponentName(vm, false);
  46378. mark(endTag);
  46379. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46380. }
  46381. if (vm.$options.el) {
  46382. vm.$mount(vm.$options.el);
  46383. }
  46384. };
  46385. }
  46386. function initInternalComponent (vm, options) {
  46387. var opts = vm.$options = Object.create(vm.constructor.options);
  46388. // doing this because it's faster than dynamic enumeration.
  46389. var parentVnode = options._parentVnode;
  46390. opts.parent = options.parent;
  46391. opts._parentVnode = parentVnode;
  46392. var vnodeComponentOptions = parentVnode.componentOptions;
  46393. opts.propsData = vnodeComponentOptions.propsData;
  46394. opts._parentListeners = vnodeComponentOptions.listeners;
  46395. opts._renderChildren = vnodeComponentOptions.children;
  46396. opts._componentTag = vnodeComponentOptions.tag;
  46397. if (options.render) {
  46398. opts.render = options.render;
  46399. opts.staticRenderFns = options.staticRenderFns;
  46400. }
  46401. }
  46402. function resolveConstructorOptions (Ctor) {
  46403. var options = Ctor.options;
  46404. if (Ctor.super) {
  46405. var superOptions = resolveConstructorOptions(Ctor.super);
  46406. var cachedSuperOptions = Ctor.superOptions;
  46407. if (superOptions !== cachedSuperOptions) {
  46408. // super option changed,
  46409. // need to resolve new options.
  46410. Ctor.superOptions = superOptions;
  46411. // check if there are any late-modified/attached options (#4976)
  46412. var modifiedOptions = resolveModifiedOptions(Ctor);
  46413. // update base extend options
  46414. if (modifiedOptions) {
  46415. extend(Ctor.extendOptions, modifiedOptions);
  46416. }
  46417. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46418. if (options.name) {
  46419. options.components[options.name] = Ctor;
  46420. }
  46421. }
  46422. }
  46423. return options
  46424. }
  46425. function resolveModifiedOptions (Ctor) {
  46426. var modified;
  46427. var latest = Ctor.options;
  46428. var sealed = Ctor.sealedOptions;
  46429. for (var key in latest) {
  46430. if (latest[key] !== sealed[key]) {
  46431. if (!modified) { modified = {}; }
  46432. modified[key] = latest[key];
  46433. }
  46434. }
  46435. return modified
  46436. }
  46437. function Vue (options) {
  46438. if (!(this instanceof Vue)
  46439. ) {
  46440. warn('Vue is a constructor and should be called with the `new` keyword');
  46441. }
  46442. this._init(options);
  46443. }
  46444. initMixin(Vue);
  46445. stateMixin(Vue);
  46446. eventsMixin(Vue);
  46447. lifecycleMixin(Vue);
  46448. renderMixin(Vue);
  46449. /* */
  46450. function initUse (Vue) {
  46451. Vue.use = function (plugin) {
  46452. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46453. if (installedPlugins.indexOf(plugin) > -1) {
  46454. return this
  46455. }
  46456. // additional parameters
  46457. var args = toArray(arguments, 1);
  46458. args.unshift(this);
  46459. if (typeof plugin.install === 'function') {
  46460. plugin.install.apply(plugin, args);
  46461. } else if (typeof plugin === 'function') {
  46462. plugin.apply(null, args);
  46463. }
  46464. installedPlugins.push(plugin);
  46465. return this
  46466. };
  46467. }
  46468. /* */
  46469. function initMixin$1 (Vue) {
  46470. Vue.mixin = function (mixin) {
  46471. this.options = mergeOptions(this.options, mixin);
  46472. return this
  46473. };
  46474. }
  46475. /* */
  46476. function initExtend (Vue) {
  46477. /**
  46478. * Each instance constructor, including Vue, has a unique
  46479. * cid. This enables us to create wrapped "child
  46480. * constructors" for prototypal inheritance and cache them.
  46481. */
  46482. Vue.cid = 0;
  46483. var cid = 1;
  46484. /**
  46485. * Class inheritance
  46486. */
  46487. Vue.extend = function (extendOptions) {
  46488. extendOptions = extendOptions || {};
  46489. var Super = this;
  46490. var SuperId = Super.cid;
  46491. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46492. if (cachedCtors[SuperId]) {
  46493. return cachedCtors[SuperId]
  46494. }
  46495. var name = extendOptions.name || Super.options.name;
  46496. if (name) {
  46497. validateComponentName(name);
  46498. }
  46499. var Sub = function VueComponent (options) {
  46500. this._init(options);
  46501. };
  46502. Sub.prototype = Object.create(Super.prototype);
  46503. Sub.prototype.constructor = Sub;
  46504. Sub.cid = cid++;
  46505. Sub.options = mergeOptions(
  46506. Super.options,
  46507. extendOptions
  46508. );
  46509. Sub['super'] = Super;
  46510. // For props and computed properties, we define the proxy getters on
  46511. // the Vue instances at extension time, on the extended prototype. This
  46512. // avoids Object.defineProperty calls for each instance created.
  46513. if (Sub.options.props) {
  46514. initProps$1(Sub);
  46515. }
  46516. if (Sub.options.computed) {
  46517. initComputed$1(Sub);
  46518. }
  46519. // allow further extension/mixin/plugin usage
  46520. Sub.extend = Super.extend;
  46521. Sub.mixin = Super.mixin;
  46522. Sub.use = Super.use;
  46523. // create asset registers, so extended classes
  46524. // can have their private assets too.
  46525. ASSET_TYPES.forEach(function (type) {
  46526. Sub[type] = Super[type];
  46527. });
  46528. // enable recursive self-lookup
  46529. if (name) {
  46530. Sub.options.components[name] = Sub;
  46531. }
  46532. // keep a reference to the super options at extension time.
  46533. // later at instantiation we can check if Super's options have
  46534. // been updated.
  46535. Sub.superOptions = Super.options;
  46536. Sub.extendOptions = extendOptions;
  46537. Sub.sealedOptions = extend({}, Sub.options);
  46538. // cache constructor
  46539. cachedCtors[SuperId] = Sub;
  46540. return Sub
  46541. };
  46542. }
  46543. function initProps$1 (Comp) {
  46544. var props = Comp.options.props;
  46545. for (var key in props) {
  46546. proxy(Comp.prototype, "_props", key);
  46547. }
  46548. }
  46549. function initComputed$1 (Comp) {
  46550. var computed = Comp.options.computed;
  46551. for (var key in computed) {
  46552. defineComputed(Comp.prototype, key, computed[key]);
  46553. }
  46554. }
  46555. /* */
  46556. function initAssetRegisters (Vue) {
  46557. /**
  46558. * Create asset registration methods.
  46559. */
  46560. ASSET_TYPES.forEach(function (type) {
  46561. Vue[type] = function (
  46562. id,
  46563. definition
  46564. ) {
  46565. if (!definition) {
  46566. return this.options[type + 's'][id]
  46567. } else {
  46568. /* istanbul ignore if */
  46569. if (type === 'component') {
  46570. validateComponentName(id);
  46571. }
  46572. if (type === 'component' && isPlainObject(definition)) {
  46573. definition.name = definition.name || id;
  46574. definition = this.options._base.extend(definition);
  46575. }
  46576. if (type === 'directive' && typeof definition === 'function') {
  46577. definition = { bind: definition, update: definition };
  46578. }
  46579. this.options[type + 's'][id] = definition;
  46580. return definition
  46581. }
  46582. };
  46583. });
  46584. }
  46585. /* */
  46586. function getComponentName (opts) {
  46587. return opts && (opts.Ctor.options.name || opts.tag)
  46588. }
  46589. function matches (pattern, name) {
  46590. if (Array.isArray(pattern)) {
  46591. return pattern.indexOf(name) > -1
  46592. } else if (typeof pattern === 'string') {
  46593. return pattern.split(',').indexOf(name) > -1
  46594. } else if (isRegExp(pattern)) {
  46595. return pattern.test(name)
  46596. }
  46597. /* istanbul ignore next */
  46598. return false
  46599. }
  46600. function pruneCache (keepAliveInstance, filter) {
  46601. var cache = keepAliveInstance.cache;
  46602. var keys = keepAliveInstance.keys;
  46603. var _vnode = keepAliveInstance._vnode;
  46604. for (var key in cache) {
  46605. var cachedNode = cache[key];
  46606. if (cachedNode) {
  46607. var name = getComponentName(cachedNode.componentOptions);
  46608. if (name && !filter(name)) {
  46609. pruneCacheEntry(cache, key, keys, _vnode);
  46610. }
  46611. }
  46612. }
  46613. }
  46614. function pruneCacheEntry (
  46615. cache,
  46616. key,
  46617. keys,
  46618. current
  46619. ) {
  46620. var cached$$1 = cache[key];
  46621. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46622. cached$$1.componentInstance.$destroy();
  46623. }
  46624. cache[key] = null;
  46625. remove(keys, key);
  46626. }
  46627. var patternTypes = [String, RegExp, Array];
  46628. var KeepAlive = {
  46629. name: 'keep-alive',
  46630. abstract: true,
  46631. props: {
  46632. include: patternTypes,
  46633. exclude: patternTypes,
  46634. max: [String, Number]
  46635. },
  46636. created: function created () {
  46637. this.cache = Object.create(null);
  46638. this.keys = [];
  46639. },
  46640. destroyed: function destroyed () {
  46641. for (var key in this.cache) {
  46642. pruneCacheEntry(this.cache, key, this.keys);
  46643. }
  46644. },
  46645. mounted: function mounted () {
  46646. var this$1 = this;
  46647. this.$watch('include', function (val) {
  46648. pruneCache(this$1, function (name) { return matches(val, name); });
  46649. });
  46650. this.$watch('exclude', function (val) {
  46651. pruneCache(this$1, function (name) { return !matches(val, name); });
  46652. });
  46653. },
  46654. render: function render () {
  46655. var slot = this.$slots.default;
  46656. var vnode = getFirstComponentChild(slot);
  46657. var componentOptions = vnode && vnode.componentOptions;
  46658. if (componentOptions) {
  46659. // check pattern
  46660. var name = getComponentName(componentOptions);
  46661. var ref = this;
  46662. var include = ref.include;
  46663. var exclude = ref.exclude;
  46664. if (
  46665. // not included
  46666. (include && (!name || !matches(include, name))) ||
  46667. // excluded
  46668. (exclude && name && matches(exclude, name))
  46669. ) {
  46670. return vnode
  46671. }
  46672. var ref$1 = this;
  46673. var cache = ref$1.cache;
  46674. var keys = ref$1.keys;
  46675. var key = vnode.key == null
  46676. // same constructor may get registered as different local components
  46677. // so cid alone is not enough (#3269)
  46678. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46679. : vnode.key;
  46680. if (cache[key]) {
  46681. vnode.componentInstance = cache[key].componentInstance;
  46682. // make current key freshest
  46683. remove(keys, key);
  46684. keys.push(key);
  46685. } else {
  46686. cache[key] = vnode;
  46687. keys.push(key);
  46688. // prune oldest entry
  46689. if (this.max && keys.length > parseInt(this.max)) {
  46690. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46691. }
  46692. }
  46693. vnode.data.keepAlive = true;
  46694. }
  46695. return vnode || (slot && slot[0])
  46696. }
  46697. };
  46698. var builtInComponents = {
  46699. KeepAlive: KeepAlive
  46700. };
  46701. /* */
  46702. function initGlobalAPI (Vue) {
  46703. // config
  46704. var configDef = {};
  46705. configDef.get = function () { return config; };
  46706. {
  46707. configDef.set = function () {
  46708. warn(
  46709. 'Do not replace the Vue.config object, set individual fields instead.'
  46710. );
  46711. };
  46712. }
  46713. Object.defineProperty(Vue, 'config', configDef);
  46714. // exposed util methods.
  46715. // NOTE: these are not considered part of the public API - avoid relying on
  46716. // them unless you are aware of the risk.
  46717. Vue.util = {
  46718. warn: warn,
  46719. extend: extend,
  46720. mergeOptions: mergeOptions,
  46721. defineReactive: defineReactive$$1
  46722. };
  46723. Vue.set = set;
  46724. Vue.delete = del;
  46725. Vue.nextTick = nextTick;
  46726. // 2.6 explicit observable API
  46727. Vue.observable = function (obj) {
  46728. observe(obj);
  46729. return obj
  46730. };
  46731. Vue.options = Object.create(null);
  46732. ASSET_TYPES.forEach(function (type) {
  46733. Vue.options[type + 's'] = Object.create(null);
  46734. });
  46735. // this is used to identify the "base" constructor to extend all plain-object
  46736. // components with in Weex's multi-instance scenarios.
  46737. Vue.options._base = Vue;
  46738. extend(Vue.options.components, builtInComponents);
  46739. initUse(Vue);
  46740. initMixin$1(Vue);
  46741. initExtend(Vue);
  46742. initAssetRegisters(Vue);
  46743. }
  46744. initGlobalAPI(Vue);
  46745. Object.defineProperty(Vue.prototype, '$isServer', {
  46746. get: isServerRendering
  46747. });
  46748. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46749. get: function get () {
  46750. /* istanbul ignore next */
  46751. return this.$vnode && this.$vnode.ssrContext
  46752. }
  46753. });
  46754. // expose FunctionalRenderContext for ssr runtime helper installation
  46755. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46756. value: FunctionalRenderContext
  46757. });
  46758. Vue.version = '2.6.11';
  46759. /* */
  46760. // these are reserved for web because they are directly compiled away
  46761. // during template compilation
  46762. var isReservedAttr = makeMap('style,class');
  46763. // attributes that should be using props for binding
  46764. var acceptValue = makeMap('input,textarea,option,select,progress');
  46765. var mustUseProp = function (tag, type, attr) {
  46766. return (
  46767. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46768. (attr === 'selected' && tag === 'option') ||
  46769. (attr === 'checked' && tag === 'input') ||
  46770. (attr === 'muted' && tag === 'video')
  46771. )
  46772. };
  46773. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46774. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46775. var convertEnumeratedValue = function (key, value) {
  46776. return isFalsyAttrValue(value) || value === 'false'
  46777. ? 'false'
  46778. // allow arbitrary string value for contenteditable
  46779. : key === 'contenteditable' && isValidContentEditableValue(value)
  46780. ? value
  46781. : 'true'
  46782. };
  46783. var isBooleanAttr = makeMap(
  46784. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46785. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46786. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46787. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46788. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46789. 'truespeed,typemustmatch,visible'
  46790. );
  46791. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46792. var isXlink = function (name) {
  46793. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46794. };
  46795. var getXlinkProp = function (name) {
  46796. return isXlink(name) ? name.slice(6, name.length) : ''
  46797. };
  46798. var isFalsyAttrValue = function (val) {
  46799. return val == null || val === false
  46800. };
  46801. /* */
  46802. function genClassForVnode (vnode) {
  46803. var data = vnode.data;
  46804. var parentNode = vnode;
  46805. var childNode = vnode;
  46806. while (isDef(childNode.componentInstance)) {
  46807. childNode = childNode.componentInstance._vnode;
  46808. if (childNode && childNode.data) {
  46809. data = mergeClassData(childNode.data, data);
  46810. }
  46811. }
  46812. while (isDef(parentNode = parentNode.parent)) {
  46813. if (parentNode && parentNode.data) {
  46814. data = mergeClassData(data, parentNode.data);
  46815. }
  46816. }
  46817. return renderClass(data.staticClass, data.class)
  46818. }
  46819. function mergeClassData (child, parent) {
  46820. return {
  46821. staticClass: concat(child.staticClass, parent.staticClass),
  46822. class: isDef(child.class)
  46823. ? [child.class, parent.class]
  46824. : parent.class
  46825. }
  46826. }
  46827. function renderClass (
  46828. staticClass,
  46829. dynamicClass
  46830. ) {
  46831. if (isDef(staticClass) || isDef(dynamicClass)) {
  46832. return concat(staticClass, stringifyClass(dynamicClass))
  46833. }
  46834. /* istanbul ignore next */
  46835. return ''
  46836. }
  46837. function concat (a, b) {
  46838. return a ? b ? (a + ' ' + b) : a : (b || '')
  46839. }
  46840. function stringifyClass (value) {
  46841. if (Array.isArray(value)) {
  46842. return stringifyArray(value)
  46843. }
  46844. if (isObject(value)) {
  46845. return stringifyObject(value)
  46846. }
  46847. if (typeof value === 'string') {
  46848. return value
  46849. }
  46850. /* istanbul ignore next */
  46851. return ''
  46852. }
  46853. function stringifyArray (value) {
  46854. var res = '';
  46855. var stringified;
  46856. for (var i = 0, l = value.length; i < l; i++) {
  46857. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46858. if (res) { res += ' '; }
  46859. res += stringified;
  46860. }
  46861. }
  46862. return res
  46863. }
  46864. function stringifyObject (value) {
  46865. var res = '';
  46866. for (var key in value) {
  46867. if (value[key]) {
  46868. if (res) { res += ' '; }
  46869. res += key;
  46870. }
  46871. }
  46872. return res
  46873. }
  46874. /* */
  46875. var namespaceMap = {
  46876. svg: 'http://www.w3.org/2000/svg',
  46877. math: 'http://www.w3.org/1998/Math/MathML'
  46878. };
  46879. var isHTMLTag = makeMap(
  46880. 'html,body,base,head,link,meta,style,title,' +
  46881. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46882. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46883. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46884. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46885. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46886. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46887. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46888. 'output,progress,select,textarea,' +
  46889. 'details,dialog,menu,menuitem,summary,' +
  46890. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46891. );
  46892. // this map is intentionally selective, only covering SVG elements that may
  46893. // contain child elements.
  46894. var isSVG = makeMap(
  46895. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46896. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46897. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46898. true
  46899. );
  46900. var isPreTag = function (tag) { return tag === 'pre'; };
  46901. var isReservedTag = function (tag) {
  46902. return isHTMLTag(tag) || isSVG(tag)
  46903. };
  46904. function getTagNamespace (tag) {
  46905. if (isSVG(tag)) {
  46906. return 'svg'
  46907. }
  46908. // basic support for MathML
  46909. // note it doesn't support other MathML elements being component roots
  46910. if (tag === 'math') {
  46911. return 'math'
  46912. }
  46913. }
  46914. var unknownElementCache = Object.create(null);
  46915. function isUnknownElement (tag) {
  46916. /* istanbul ignore if */
  46917. if (!inBrowser) {
  46918. return true
  46919. }
  46920. if (isReservedTag(tag)) {
  46921. return false
  46922. }
  46923. tag = tag.toLowerCase();
  46924. /* istanbul ignore if */
  46925. if (unknownElementCache[tag] != null) {
  46926. return unknownElementCache[tag]
  46927. }
  46928. var el = document.createElement(tag);
  46929. if (tag.indexOf('-') > -1) {
  46930. // http://stackoverflow.com/a/28210364/1070244
  46931. return (unknownElementCache[tag] = (
  46932. el.constructor === window.HTMLUnknownElement ||
  46933. el.constructor === window.HTMLElement
  46934. ))
  46935. } else {
  46936. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  46937. }
  46938. }
  46939. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  46940. /* */
  46941. /**
  46942. * Query an element selector if it's not an element already.
  46943. */
  46944. function query (el) {
  46945. if (typeof el === 'string') {
  46946. var selected = document.querySelector(el);
  46947. if (!selected) {
  46948. warn(
  46949. 'Cannot find element: ' + el
  46950. );
  46951. return document.createElement('div')
  46952. }
  46953. return selected
  46954. } else {
  46955. return el
  46956. }
  46957. }
  46958. /* */
  46959. function createElement$1 (tagName, vnode) {
  46960. var elm = document.createElement(tagName);
  46961. if (tagName !== 'select') {
  46962. return elm
  46963. }
  46964. // false or null will remove the attribute but undefined will not
  46965. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  46966. elm.setAttribute('multiple', 'multiple');
  46967. }
  46968. return elm
  46969. }
  46970. function createElementNS (namespace, tagName) {
  46971. return document.createElementNS(namespaceMap[namespace], tagName)
  46972. }
  46973. function createTextNode (text) {
  46974. return document.createTextNode(text)
  46975. }
  46976. function createComment (text) {
  46977. return document.createComment(text)
  46978. }
  46979. function insertBefore (parentNode, newNode, referenceNode) {
  46980. parentNode.insertBefore(newNode, referenceNode);
  46981. }
  46982. function removeChild (node, child) {
  46983. node.removeChild(child);
  46984. }
  46985. function appendChild (node, child) {
  46986. node.appendChild(child);
  46987. }
  46988. function parentNode (node) {
  46989. return node.parentNode
  46990. }
  46991. function nextSibling (node) {
  46992. return node.nextSibling
  46993. }
  46994. function tagName (node) {
  46995. return node.tagName
  46996. }
  46997. function setTextContent (node, text) {
  46998. node.textContent = text;
  46999. }
  47000. function setStyleScope (node, scopeId) {
  47001. node.setAttribute(scopeId, '');
  47002. }
  47003. var nodeOps = /*#__PURE__*/Object.freeze({
  47004. createElement: createElement$1,
  47005. createElementNS: createElementNS,
  47006. createTextNode: createTextNode,
  47007. createComment: createComment,
  47008. insertBefore: insertBefore,
  47009. removeChild: removeChild,
  47010. appendChild: appendChild,
  47011. parentNode: parentNode,
  47012. nextSibling: nextSibling,
  47013. tagName: tagName,
  47014. setTextContent: setTextContent,
  47015. setStyleScope: setStyleScope
  47016. });
  47017. /* */
  47018. var ref = {
  47019. create: function create (_, vnode) {
  47020. registerRef(vnode);
  47021. },
  47022. update: function update (oldVnode, vnode) {
  47023. if (oldVnode.data.ref !== vnode.data.ref) {
  47024. registerRef(oldVnode, true);
  47025. registerRef(vnode);
  47026. }
  47027. },
  47028. destroy: function destroy (vnode) {
  47029. registerRef(vnode, true);
  47030. }
  47031. };
  47032. function registerRef (vnode, isRemoval) {
  47033. var key = vnode.data.ref;
  47034. if (!isDef(key)) { return }
  47035. var vm = vnode.context;
  47036. var ref = vnode.componentInstance || vnode.elm;
  47037. var refs = vm.$refs;
  47038. if (isRemoval) {
  47039. if (Array.isArray(refs[key])) {
  47040. remove(refs[key], ref);
  47041. } else if (refs[key] === ref) {
  47042. refs[key] = undefined;
  47043. }
  47044. } else {
  47045. if (vnode.data.refInFor) {
  47046. if (!Array.isArray(refs[key])) {
  47047. refs[key] = [ref];
  47048. } else if (refs[key].indexOf(ref) < 0) {
  47049. // $flow-disable-line
  47050. refs[key].push(ref);
  47051. }
  47052. } else {
  47053. refs[key] = ref;
  47054. }
  47055. }
  47056. }
  47057. /**
  47058. * Virtual DOM patching algorithm based on Snabbdom by
  47059. * Simon Friis Vindum (@paldepind)
  47060. * Licensed under the MIT License
  47061. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  47062. *
  47063. * modified by Evan You (@yyx990803)
  47064. *
  47065. * Not type-checking this because this file is perf-critical and the cost
  47066. * of making flow understand it is not worth it.
  47067. */
  47068. var emptyNode = new VNode('', {}, []);
  47069. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  47070. function sameVnode (a, b) {
  47071. return (
  47072. a.key === b.key && (
  47073. (
  47074. a.tag === b.tag &&
  47075. a.isComment === b.isComment &&
  47076. isDef(a.data) === isDef(b.data) &&
  47077. sameInputType(a, b)
  47078. ) || (
  47079. isTrue(a.isAsyncPlaceholder) &&
  47080. a.asyncFactory === b.asyncFactory &&
  47081. isUndef(b.asyncFactory.error)
  47082. )
  47083. )
  47084. )
  47085. }
  47086. function sameInputType (a, b) {
  47087. if (a.tag !== 'input') { return true }
  47088. var i;
  47089. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  47090. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  47091. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  47092. }
  47093. function createKeyToOldIdx (children, beginIdx, endIdx) {
  47094. var i, key;
  47095. var map = {};
  47096. for (i = beginIdx; i <= endIdx; ++i) {
  47097. key = children[i].key;
  47098. if (isDef(key)) { map[key] = i; }
  47099. }
  47100. return map
  47101. }
  47102. function createPatchFunction (backend) {
  47103. var i, j;
  47104. var cbs = {};
  47105. var modules = backend.modules;
  47106. var nodeOps = backend.nodeOps;
  47107. for (i = 0; i < hooks.length; ++i) {
  47108. cbs[hooks[i]] = [];
  47109. for (j = 0; j < modules.length; ++j) {
  47110. if (isDef(modules[j][hooks[i]])) {
  47111. cbs[hooks[i]].push(modules[j][hooks[i]]);
  47112. }
  47113. }
  47114. }
  47115. function emptyNodeAt (elm) {
  47116. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  47117. }
  47118. function createRmCb (childElm, listeners) {
  47119. function remove$$1 () {
  47120. if (--remove$$1.listeners === 0) {
  47121. removeNode(childElm);
  47122. }
  47123. }
  47124. remove$$1.listeners = listeners;
  47125. return remove$$1
  47126. }
  47127. function removeNode (el) {
  47128. var parent = nodeOps.parentNode(el);
  47129. // element may have already been removed due to v-html / v-text
  47130. if (isDef(parent)) {
  47131. nodeOps.removeChild(parent, el);
  47132. }
  47133. }
  47134. function isUnknownElement$$1 (vnode, inVPre) {
  47135. return (
  47136. !inVPre &&
  47137. !vnode.ns &&
  47138. !(
  47139. config.ignoredElements.length &&
  47140. config.ignoredElements.some(function (ignore) {
  47141. return isRegExp(ignore)
  47142. ? ignore.test(vnode.tag)
  47143. : ignore === vnode.tag
  47144. })
  47145. ) &&
  47146. config.isUnknownElement(vnode.tag)
  47147. )
  47148. }
  47149. var creatingElmInVPre = 0;
  47150. function createElm (
  47151. vnode,
  47152. insertedVnodeQueue,
  47153. parentElm,
  47154. refElm,
  47155. nested,
  47156. ownerArray,
  47157. index
  47158. ) {
  47159. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47160. // This vnode was used in a previous render!
  47161. // now it's used as a new node, overwriting its elm would cause
  47162. // potential patch errors down the road when it's used as an insertion
  47163. // reference node. Instead, we clone the node on-demand before creating
  47164. // associated DOM element for it.
  47165. vnode = ownerArray[index] = cloneVNode(vnode);
  47166. }
  47167. vnode.isRootInsert = !nested; // for transition enter check
  47168. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47169. return
  47170. }
  47171. var data = vnode.data;
  47172. var children = vnode.children;
  47173. var tag = vnode.tag;
  47174. if (isDef(tag)) {
  47175. {
  47176. if (data && data.pre) {
  47177. creatingElmInVPre++;
  47178. }
  47179. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47180. warn(
  47181. 'Unknown custom element: <' + tag + '> - did you ' +
  47182. 'register the component correctly? For recursive components, ' +
  47183. 'make sure to provide the "name" option.',
  47184. vnode.context
  47185. );
  47186. }
  47187. }
  47188. vnode.elm = vnode.ns
  47189. ? nodeOps.createElementNS(vnode.ns, tag)
  47190. : nodeOps.createElement(tag, vnode);
  47191. setScope(vnode);
  47192. /* istanbul ignore if */
  47193. {
  47194. createChildren(vnode, children, insertedVnodeQueue);
  47195. if (isDef(data)) {
  47196. invokeCreateHooks(vnode, insertedVnodeQueue);
  47197. }
  47198. insert(parentElm, vnode.elm, refElm);
  47199. }
  47200. if (data && data.pre) {
  47201. creatingElmInVPre--;
  47202. }
  47203. } else if (isTrue(vnode.isComment)) {
  47204. vnode.elm = nodeOps.createComment(vnode.text);
  47205. insert(parentElm, vnode.elm, refElm);
  47206. } else {
  47207. vnode.elm = nodeOps.createTextNode(vnode.text);
  47208. insert(parentElm, vnode.elm, refElm);
  47209. }
  47210. }
  47211. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47212. var i = vnode.data;
  47213. if (isDef(i)) {
  47214. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47215. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47216. i(vnode, false /* hydrating */);
  47217. }
  47218. // after calling the init hook, if the vnode is a child component
  47219. // it should've created a child instance and mounted it. the child
  47220. // component also has set the placeholder vnode's elm.
  47221. // in that case we can just return the element and be done.
  47222. if (isDef(vnode.componentInstance)) {
  47223. initComponent(vnode, insertedVnodeQueue);
  47224. insert(parentElm, vnode.elm, refElm);
  47225. if (isTrue(isReactivated)) {
  47226. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47227. }
  47228. return true
  47229. }
  47230. }
  47231. }
  47232. function initComponent (vnode, insertedVnodeQueue) {
  47233. if (isDef(vnode.data.pendingInsert)) {
  47234. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47235. vnode.data.pendingInsert = null;
  47236. }
  47237. vnode.elm = vnode.componentInstance.$el;
  47238. if (isPatchable(vnode)) {
  47239. invokeCreateHooks(vnode, insertedVnodeQueue);
  47240. setScope(vnode);
  47241. } else {
  47242. // empty component root.
  47243. // skip all element-related modules except for ref (#3455)
  47244. registerRef(vnode);
  47245. // make sure to invoke the insert hook
  47246. insertedVnodeQueue.push(vnode);
  47247. }
  47248. }
  47249. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47250. var i;
  47251. // hack for #4339: a reactivated component with inner transition
  47252. // does not trigger because the inner node's created hooks are not called
  47253. // again. It's not ideal to involve module-specific logic in here but
  47254. // there doesn't seem to be a better way to do it.
  47255. var innerNode = vnode;
  47256. while (innerNode.componentInstance) {
  47257. innerNode = innerNode.componentInstance._vnode;
  47258. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47259. for (i = 0; i < cbs.activate.length; ++i) {
  47260. cbs.activate[i](emptyNode, innerNode);
  47261. }
  47262. insertedVnodeQueue.push(innerNode);
  47263. break
  47264. }
  47265. }
  47266. // unlike a newly created component,
  47267. // a reactivated keep-alive component doesn't insert itself
  47268. insert(parentElm, vnode.elm, refElm);
  47269. }
  47270. function insert (parent, elm, ref$$1) {
  47271. if (isDef(parent)) {
  47272. if (isDef(ref$$1)) {
  47273. if (nodeOps.parentNode(ref$$1) === parent) {
  47274. nodeOps.insertBefore(parent, elm, ref$$1);
  47275. }
  47276. } else {
  47277. nodeOps.appendChild(parent, elm);
  47278. }
  47279. }
  47280. }
  47281. function createChildren (vnode, children, insertedVnodeQueue) {
  47282. if (Array.isArray(children)) {
  47283. {
  47284. checkDuplicateKeys(children);
  47285. }
  47286. for (var i = 0; i < children.length; ++i) {
  47287. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47288. }
  47289. } else if (isPrimitive(vnode.text)) {
  47290. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47291. }
  47292. }
  47293. function isPatchable (vnode) {
  47294. while (vnode.componentInstance) {
  47295. vnode = vnode.componentInstance._vnode;
  47296. }
  47297. return isDef(vnode.tag)
  47298. }
  47299. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47300. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47301. cbs.create[i$1](emptyNode, vnode);
  47302. }
  47303. i = vnode.data.hook; // Reuse variable
  47304. if (isDef(i)) {
  47305. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47306. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47307. }
  47308. }
  47309. // set scope id attribute for scoped CSS.
  47310. // this is implemented as a special case to avoid the overhead
  47311. // of going through the normal attribute patching process.
  47312. function setScope (vnode) {
  47313. var i;
  47314. if (isDef(i = vnode.fnScopeId)) {
  47315. nodeOps.setStyleScope(vnode.elm, i);
  47316. } else {
  47317. var ancestor = vnode;
  47318. while (ancestor) {
  47319. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47320. nodeOps.setStyleScope(vnode.elm, i);
  47321. }
  47322. ancestor = ancestor.parent;
  47323. }
  47324. }
  47325. // for slot content they should also get the scopeId from the host instance.
  47326. if (isDef(i = activeInstance) &&
  47327. i !== vnode.context &&
  47328. i !== vnode.fnContext &&
  47329. isDef(i = i.$options._scopeId)
  47330. ) {
  47331. nodeOps.setStyleScope(vnode.elm, i);
  47332. }
  47333. }
  47334. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47335. for (; startIdx <= endIdx; ++startIdx) {
  47336. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47337. }
  47338. }
  47339. function invokeDestroyHook (vnode) {
  47340. var i, j;
  47341. var data = vnode.data;
  47342. if (isDef(data)) {
  47343. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47344. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47345. }
  47346. if (isDef(i = vnode.children)) {
  47347. for (j = 0; j < vnode.children.length; ++j) {
  47348. invokeDestroyHook(vnode.children[j]);
  47349. }
  47350. }
  47351. }
  47352. function removeVnodes (vnodes, startIdx, endIdx) {
  47353. for (; startIdx <= endIdx; ++startIdx) {
  47354. var ch = vnodes[startIdx];
  47355. if (isDef(ch)) {
  47356. if (isDef(ch.tag)) {
  47357. removeAndInvokeRemoveHook(ch);
  47358. invokeDestroyHook(ch);
  47359. } else { // Text node
  47360. removeNode(ch.elm);
  47361. }
  47362. }
  47363. }
  47364. }
  47365. function removeAndInvokeRemoveHook (vnode, rm) {
  47366. if (isDef(rm) || isDef(vnode.data)) {
  47367. var i;
  47368. var listeners = cbs.remove.length + 1;
  47369. if (isDef(rm)) {
  47370. // we have a recursively passed down rm callback
  47371. // increase the listeners count
  47372. rm.listeners += listeners;
  47373. } else {
  47374. // directly removing
  47375. rm = createRmCb(vnode.elm, listeners);
  47376. }
  47377. // recursively invoke hooks on child component root node
  47378. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47379. removeAndInvokeRemoveHook(i, rm);
  47380. }
  47381. for (i = 0; i < cbs.remove.length; ++i) {
  47382. cbs.remove[i](vnode, rm);
  47383. }
  47384. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47385. i(vnode, rm);
  47386. } else {
  47387. rm();
  47388. }
  47389. } else {
  47390. removeNode(vnode.elm);
  47391. }
  47392. }
  47393. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47394. var oldStartIdx = 0;
  47395. var newStartIdx = 0;
  47396. var oldEndIdx = oldCh.length - 1;
  47397. var oldStartVnode = oldCh[0];
  47398. var oldEndVnode = oldCh[oldEndIdx];
  47399. var newEndIdx = newCh.length - 1;
  47400. var newStartVnode = newCh[0];
  47401. var newEndVnode = newCh[newEndIdx];
  47402. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47403. // removeOnly is a special flag used only by <transition-group>
  47404. // to ensure removed elements stay in correct relative positions
  47405. // during leaving transitions
  47406. var canMove = !removeOnly;
  47407. {
  47408. checkDuplicateKeys(newCh);
  47409. }
  47410. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47411. if (isUndef(oldStartVnode)) {
  47412. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47413. } else if (isUndef(oldEndVnode)) {
  47414. oldEndVnode = oldCh[--oldEndIdx];
  47415. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47416. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47417. oldStartVnode = oldCh[++oldStartIdx];
  47418. newStartVnode = newCh[++newStartIdx];
  47419. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47420. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47421. oldEndVnode = oldCh[--oldEndIdx];
  47422. newEndVnode = newCh[--newEndIdx];
  47423. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47424. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47425. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47426. oldStartVnode = oldCh[++oldStartIdx];
  47427. newEndVnode = newCh[--newEndIdx];
  47428. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47429. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47430. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47431. oldEndVnode = oldCh[--oldEndIdx];
  47432. newStartVnode = newCh[++newStartIdx];
  47433. } else {
  47434. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47435. idxInOld = isDef(newStartVnode.key)
  47436. ? oldKeyToIdx[newStartVnode.key]
  47437. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47438. if (isUndef(idxInOld)) { // New element
  47439. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47440. } else {
  47441. vnodeToMove = oldCh[idxInOld];
  47442. if (sameVnode(vnodeToMove, newStartVnode)) {
  47443. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47444. oldCh[idxInOld] = undefined;
  47445. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47446. } else {
  47447. // same key but different element. treat as new element
  47448. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47449. }
  47450. }
  47451. newStartVnode = newCh[++newStartIdx];
  47452. }
  47453. }
  47454. if (oldStartIdx > oldEndIdx) {
  47455. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47456. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47457. } else if (newStartIdx > newEndIdx) {
  47458. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47459. }
  47460. }
  47461. function checkDuplicateKeys (children) {
  47462. var seenKeys = {};
  47463. for (var i = 0; i < children.length; i++) {
  47464. var vnode = children[i];
  47465. var key = vnode.key;
  47466. if (isDef(key)) {
  47467. if (seenKeys[key]) {
  47468. warn(
  47469. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47470. vnode.context
  47471. );
  47472. } else {
  47473. seenKeys[key] = true;
  47474. }
  47475. }
  47476. }
  47477. }
  47478. function findIdxInOld (node, oldCh, start, end) {
  47479. for (var i = start; i < end; i++) {
  47480. var c = oldCh[i];
  47481. if (isDef(c) && sameVnode(node, c)) { return i }
  47482. }
  47483. }
  47484. function patchVnode (
  47485. oldVnode,
  47486. vnode,
  47487. insertedVnodeQueue,
  47488. ownerArray,
  47489. index,
  47490. removeOnly
  47491. ) {
  47492. if (oldVnode === vnode) {
  47493. return
  47494. }
  47495. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47496. // clone reused vnode
  47497. vnode = ownerArray[index] = cloneVNode(vnode);
  47498. }
  47499. var elm = vnode.elm = oldVnode.elm;
  47500. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47501. if (isDef(vnode.asyncFactory.resolved)) {
  47502. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47503. } else {
  47504. vnode.isAsyncPlaceholder = true;
  47505. }
  47506. return
  47507. }
  47508. // reuse element for static trees.
  47509. // note we only do this if the vnode is cloned -
  47510. // if the new node is not cloned it means the render functions have been
  47511. // reset by the hot-reload-api and we need to do a proper re-render.
  47512. if (isTrue(vnode.isStatic) &&
  47513. isTrue(oldVnode.isStatic) &&
  47514. vnode.key === oldVnode.key &&
  47515. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47516. ) {
  47517. vnode.componentInstance = oldVnode.componentInstance;
  47518. return
  47519. }
  47520. var i;
  47521. var data = vnode.data;
  47522. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47523. i(oldVnode, vnode);
  47524. }
  47525. var oldCh = oldVnode.children;
  47526. var ch = vnode.children;
  47527. if (isDef(data) && isPatchable(vnode)) {
  47528. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47529. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47530. }
  47531. if (isUndef(vnode.text)) {
  47532. if (isDef(oldCh) && isDef(ch)) {
  47533. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47534. } else if (isDef(ch)) {
  47535. {
  47536. checkDuplicateKeys(ch);
  47537. }
  47538. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47539. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47540. } else if (isDef(oldCh)) {
  47541. removeVnodes(oldCh, 0, oldCh.length - 1);
  47542. } else if (isDef(oldVnode.text)) {
  47543. nodeOps.setTextContent(elm, '');
  47544. }
  47545. } else if (oldVnode.text !== vnode.text) {
  47546. nodeOps.setTextContent(elm, vnode.text);
  47547. }
  47548. if (isDef(data)) {
  47549. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47550. }
  47551. }
  47552. function invokeInsertHook (vnode, queue, initial) {
  47553. // delay insert hooks for component root nodes, invoke them after the
  47554. // element is really inserted
  47555. if (isTrue(initial) && isDef(vnode.parent)) {
  47556. vnode.parent.data.pendingInsert = queue;
  47557. } else {
  47558. for (var i = 0; i < queue.length; ++i) {
  47559. queue[i].data.hook.insert(queue[i]);
  47560. }
  47561. }
  47562. }
  47563. var hydrationBailed = false;
  47564. // list of modules that can skip create hook during hydration because they
  47565. // are already rendered on the client or has no need for initialization
  47566. // Note: style is excluded because it relies on initial clone for future
  47567. // deep updates (#7063).
  47568. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47569. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47570. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47571. var i;
  47572. var tag = vnode.tag;
  47573. var data = vnode.data;
  47574. var children = vnode.children;
  47575. inVPre = inVPre || (data && data.pre);
  47576. vnode.elm = elm;
  47577. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47578. vnode.isAsyncPlaceholder = true;
  47579. return true
  47580. }
  47581. // assert node match
  47582. {
  47583. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47584. return false
  47585. }
  47586. }
  47587. if (isDef(data)) {
  47588. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47589. if (isDef(i = vnode.componentInstance)) {
  47590. // child component. it should have hydrated its own tree.
  47591. initComponent(vnode, insertedVnodeQueue);
  47592. return true
  47593. }
  47594. }
  47595. if (isDef(tag)) {
  47596. if (isDef(children)) {
  47597. // empty element, allow client to pick up and populate children
  47598. if (!elm.hasChildNodes()) {
  47599. createChildren(vnode, children, insertedVnodeQueue);
  47600. } else {
  47601. // v-html and domProps: innerHTML
  47602. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47603. if (i !== elm.innerHTML) {
  47604. /* istanbul ignore if */
  47605. if (typeof console !== 'undefined' &&
  47606. !hydrationBailed
  47607. ) {
  47608. hydrationBailed = true;
  47609. console.warn('Parent: ', elm);
  47610. console.warn('server innerHTML: ', i);
  47611. console.warn('client innerHTML: ', elm.innerHTML);
  47612. }
  47613. return false
  47614. }
  47615. } else {
  47616. // iterate and compare children lists
  47617. var childrenMatch = true;
  47618. var childNode = elm.firstChild;
  47619. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47620. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47621. childrenMatch = false;
  47622. break
  47623. }
  47624. childNode = childNode.nextSibling;
  47625. }
  47626. // if childNode is not null, it means the actual childNodes list is
  47627. // longer than the virtual children list.
  47628. if (!childrenMatch || childNode) {
  47629. /* istanbul ignore if */
  47630. if (typeof console !== 'undefined' &&
  47631. !hydrationBailed
  47632. ) {
  47633. hydrationBailed = true;
  47634. console.warn('Parent: ', elm);
  47635. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47636. }
  47637. return false
  47638. }
  47639. }
  47640. }
  47641. }
  47642. if (isDef(data)) {
  47643. var fullInvoke = false;
  47644. for (var key in data) {
  47645. if (!isRenderedModule(key)) {
  47646. fullInvoke = true;
  47647. invokeCreateHooks(vnode, insertedVnodeQueue);
  47648. break
  47649. }
  47650. }
  47651. if (!fullInvoke && data['class']) {
  47652. // ensure collecting deps for deep class bindings for future updates
  47653. traverse(data['class']);
  47654. }
  47655. }
  47656. } else if (elm.data !== vnode.text) {
  47657. elm.data = vnode.text;
  47658. }
  47659. return true
  47660. }
  47661. function assertNodeMatch (node, vnode, inVPre) {
  47662. if (isDef(vnode.tag)) {
  47663. return vnode.tag.indexOf('vue-component') === 0 || (
  47664. !isUnknownElement$$1(vnode, inVPre) &&
  47665. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47666. )
  47667. } else {
  47668. return node.nodeType === (vnode.isComment ? 8 : 3)
  47669. }
  47670. }
  47671. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47672. if (isUndef(vnode)) {
  47673. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47674. return
  47675. }
  47676. var isInitialPatch = false;
  47677. var insertedVnodeQueue = [];
  47678. if (isUndef(oldVnode)) {
  47679. // empty mount (likely as component), create new root element
  47680. isInitialPatch = true;
  47681. createElm(vnode, insertedVnodeQueue);
  47682. } else {
  47683. var isRealElement = isDef(oldVnode.nodeType);
  47684. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47685. // patch existing root node
  47686. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47687. } else {
  47688. if (isRealElement) {
  47689. // mounting to a real element
  47690. // check if this is server-rendered content and if we can perform
  47691. // a successful hydration.
  47692. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47693. oldVnode.removeAttribute(SSR_ATTR);
  47694. hydrating = true;
  47695. }
  47696. if (isTrue(hydrating)) {
  47697. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47698. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47699. return oldVnode
  47700. } else {
  47701. warn(
  47702. 'The client-side rendered virtual DOM tree is not matching ' +
  47703. 'server-rendered content. This is likely caused by incorrect ' +
  47704. 'HTML markup, for example nesting block-level elements inside ' +
  47705. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47706. 'full client-side render.'
  47707. );
  47708. }
  47709. }
  47710. // either not server-rendered, or hydration failed.
  47711. // create an empty node and replace it
  47712. oldVnode = emptyNodeAt(oldVnode);
  47713. }
  47714. // replacing existing element
  47715. var oldElm = oldVnode.elm;
  47716. var parentElm = nodeOps.parentNode(oldElm);
  47717. // create new node
  47718. createElm(
  47719. vnode,
  47720. insertedVnodeQueue,
  47721. // extremely rare edge case: do not insert if old element is in a
  47722. // leaving transition. Only happens when combining transition +
  47723. // keep-alive + HOCs. (#4590)
  47724. oldElm._leaveCb ? null : parentElm,
  47725. nodeOps.nextSibling(oldElm)
  47726. );
  47727. // update parent placeholder node element, recursively
  47728. if (isDef(vnode.parent)) {
  47729. var ancestor = vnode.parent;
  47730. var patchable = isPatchable(vnode);
  47731. while (ancestor) {
  47732. for (var i = 0; i < cbs.destroy.length; ++i) {
  47733. cbs.destroy[i](ancestor);
  47734. }
  47735. ancestor.elm = vnode.elm;
  47736. if (patchable) {
  47737. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47738. cbs.create[i$1](emptyNode, ancestor);
  47739. }
  47740. // #6513
  47741. // invoke insert hooks that may have been merged by create hooks.
  47742. // e.g. for directives that uses the "inserted" hook.
  47743. var insert = ancestor.data.hook.insert;
  47744. if (insert.merged) {
  47745. // start at index 1 to avoid re-invoking component mounted hook
  47746. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47747. insert.fns[i$2]();
  47748. }
  47749. }
  47750. } else {
  47751. registerRef(ancestor);
  47752. }
  47753. ancestor = ancestor.parent;
  47754. }
  47755. }
  47756. // destroy old node
  47757. if (isDef(parentElm)) {
  47758. removeVnodes([oldVnode], 0, 0);
  47759. } else if (isDef(oldVnode.tag)) {
  47760. invokeDestroyHook(oldVnode);
  47761. }
  47762. }
  47763. }
  47764. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47765. return vnode.elm
  47766. }
  47767. }
  47768. /* */
  47769. var directives = {
  47770. create: updateDirectives,
  47771. update: updateDirectives,
  47772. destroy: function unbindDirectives (vnode) {
  47773. updateDirectives(vnode, emptyNode);
  47774. }
  47775. };
  47776. function updateDirectives (oldVnode, vnode) {
  47777. if (oldVnode.data.directives || vnode.data.directives) {
  47778. _update(oldVnode, vnode);
  47779. }
  47780. }
  47781. function _update (oldVnode, vnode) {
  47782. var isCreate = oldVnode === emptyNode;
  47783. var isDestroy = vnode === emptyNode;
  47784. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47785. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47786. var dirsWithInsert = [];
  47787. var dirsWithPostpatch = [];
  47788. var key, oldDir, dir;
  47789. for (key in newDirs) {
  47790. oldDir = oldDirs[key];
  47791. dir = newDirs[key];
  47792. if (!oldDir) {
  47793. // new directive, bind
  47794. callHook$1(dir, 'bind', vnode, oldVnode);
  47795. if (dir.def && dir.def.inserted) {
  47796. dirsWithInsert.push(dir);
  47797. }
  47798. } else {
  47799. // existing directive, update
  47800. dir.oldValue = oldDir.value;
  47801. dir.oldArg = oldDir.arg;
  47802. callHook$1(dir, 'update', vnode, oldVnode);
  47803. if (dir.def && dir.def.componentUpdated) {
  47804. dirsWithPostpatch.push(dir);
  47805. }
  47806. }
  47807. }
  47808. if (dirsWithInsert.length) {
  47809. var callInsert = function () {
  47810. for (var i = 0; i < dirsWithInsert.length; i++) {
  47811. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47812. }
  47813. };
  47814. if (isCreate) {
  47815. mergeVNodeHook(vnode, 'insert', callInsert);
  47816. } else {
  47817. callInsert();
  47818. }
  47819. }
  47820. if (dirsWithPostpatch.length) {
  47821. mergeVNodeHook(vnode, 'postpatch', function () {
  47822. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47823. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47824. }
  47825. });
  47826. }
  47827. if (!isCreate) {
  47828. for (key in oldDirs) {
  47829. if (!newDirs[key]) {
  47830. // no longer present, unbind
  47831. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47832. }
  47833. }
  47834. }
  47835. }
  47836. var emptyModifiers = Object.create(null);
  47837. function normalizeDirectives$1 (
  47838. dirs,
  47839. vm
  47840. ) {
  47841. var res = Object.create(null);
  47842. if (!dirs) {
  47843. // $flow-disable-line
  47844. return res
  47845. }
  47846. var i, dir;
  47847. for (i = 0; i < dirs.length; i++) {
  47848. dir = dirs[i];
  47849. if (!dir.modifiers) {
  47850. // $flow-disable-line
  47851. dir.modifiers = emptyModifiers;
  47852. }
  47853. res[getRawDirName(dir)] = dir;
  47854. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47855. }
  47856. // $flow-disable-line
  47857. return res
  47858. }
  47859. function getRawDirName (dir) {
  47860. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47861. }
  47862. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47863. var fn = dir.def && dir.def[hook];
  47864. if (fn) {
  47865. try {
  47866. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47867. } catch (e) {
  47868. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47869. }
  47870. }
  47871. }
  47872. var baseModules = [
  47873. ref,
  47874. directives
  47875. ];
  47876. /* */
  47877. function updateAttrs (oldVnode, vnode) {
  47878. var opts = vnode.componentOptions;
  47879. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47880. return
  47881. }
  47882. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47883. return
  47884. }
  47885. var key, cur, old;
  47886. var elm = vnode.elm;
  47887. var oldAttrs = oldVnode.data.attrs || {};
  47888. var attrs = vnode.data.attrs || {};
  47889. // clone observed objects, as the user probably wants to mutate it
  47890. if (isDef(attrs.__ob__)) {
  47891. attrs = vnode.data.attrs = extend({}, attrs);
  47892. }
  47893. for (key in attrs) {
  47894. cur = attrs[key];
  47895. old = oldAttrs[key];
  47896. if (old !== cur) {
  47897. setAttr(elm, key, cur);
  47898. }
  47899. }
  47900. // #4391: in IE9, setting type can reset value for input[type=radio]
  47901. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47902. /* istanbul ignore if */
  47903. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47904. setAttr(elm, 'value', attrs.value);
  47905. }
  47906. for (key in oldAttrs) {
  47907. if (isUndef(attrs[key])) {
  47908. if (isXlink(key)) {
  47909. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47910. } else if (!isEnumeratedAttr(key)) {
  47911. elm.removeAttribute(key);
  47912. }
  47913. }
  47914. }
  47915. }
  47916. function setAttr (el, key, value) {
  47917. if (el.tagName.indexOf('-') > -1) {
  47918. baseSetAttr(el, key, value);
  47919. } else if (isBooleanAttr(key)) {
  47920. // set attribute for blank value
  47921. // e.g. <option disabled>Select one</option>
  47922. if (isFalsyAttrValue(value)) {
  47923. el.removeAttribute(key);
  47924. } else {
  47925. // technically allowfullscreen is a boolean attribute for <iframe>,
  47926. // but Flash expects a value of "true" when used on <embed> tag
  47927. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  47928. ? 'true'
  47929. : key;
  47930. el.setAttribute(key, value);
  47931. }
  47932. } else if (isEnumeratedAttr(key)) {
  47933. el.setAttribute(key, convertEnumeratedValue(key, value));
  47934. } else if (isXlink(key)) {
  47935. if (isFalsyAttrValue(value)) {
  47936. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47937. } else {
  47938. el.setAttributeNS(xlinkNS, key, value);
  47939. }
  47940. } else {
  47941. baseSetAttr(el, key, value);
  47942. }
  47943. }
  47944. function baseSetAttr (el, key, value) {
  47945. if (isFalsyAttrValue(value)) {
  47946. el.removeAttribute(key);
  47947. } else {
  47948. // #7138: IE10 & 11 fires input event when setting placeholder on
  47949. // <textarea>... block the first input event and remove the blocker
  47950. // immediately.
  47951. /* istanbul ignore if */
  47952. if (
  47953. isIE && !isIE9 &&
  47954. el.tagName === 'TEXTAREA' &&
  47955. key === 'placeholder' && value !== '' && !el.__ieph
  47956. ) {
  47957. var blocker = function (e) {
  47958. e.stopImmediatePropagation();
  47959. el.removeEventListener('input', blocker);
  47960. };
  47961. el.addEventListener('input', blocker);
  47962. // $flow-disable-line
  47963. el.__ieph = true; /* IE placeholder patched */
  47964. }
  47965. el.setAttribute(key, value);
  47966. }
  47967. }
  47968. var attrs = {
  47969. create: updateAttrs,
  47970. update: updateAttrs
  47971. };
  47972. /* */
  47973. function updateClass (oldVnode, vnode) {
  47974. var el = vnode.elm;
  47975. var data = vnode.data;
  47976. var oldData = oldVnode.data;
  47977. if (
  47978. isUndef(data.staticClass) &&
  47979. isUndef(data.class) && (
  47980. isUndef(oldData) || (
  47981. isUndef(oldData.staticClass) &&
  47982. isUndef(oldData.class)
  47983. )
  47984. )
  47985. ) {
  47986. return
  47987. }
  47988. var cls = genClassForVnode(vnode);
  47989. // handle transition classes
  47990. var transitionClass = el._transitionClasses;
  47991. if (isDef(transitionClass)) {
  47992. cls = concat(cls, stringifyClass(transitionClass));
  47993. }
  47994. // set the class
  47995. if (cls !== el._prevClass) {
  47996. el.setAttribute('class', cls);
  47997. el._prevClass = cls;
  47998. }
  47999. }
  48000. var klass = {
  48001. create: updateClass,
  48002. update: updateClass
  48003. };
  48004. /* */
  48005. var validDivisionCharRE = /[\w).+\-_$\]]/;
  48006. function parseFilters (exp) {
  48007. var inSingle = false;
  48008. var inDouble = false;
  48009. var inTemplateString = false;
  48010. var inRegex = false;
  48011. var curly = 0;
  48012. var square = 0;
  48013. var paren = 0;
  48014. var lastFilterIndex = 0;
  48015. var c, prev, i, expression, filters;
  48016. for (i = 0; i < exp.length; i++) {
  48017. prev = c;
  48018. c = exp.charCodeAt(i);
  48019. if (inSingle) {
  48020. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  48021. } else if (inDouble) {
  48022. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  48023. } else if (inTemplateString) {
  48024. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  48025. } else if (inRegex) {
  48026. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  48027. } else if (
  48028. c === 0x7C && // pipe
  48029. exp.charCodeAt(i + 1) !== 0x7C &&
  48030. exp.charCodeAt(i - 1) !== 0x7C &&
  48031. !curly && !square && !paren
  48032. ) {
  48033. if (expression === undefined) {
  48034. // first filter, end of expression
  48035. lastFilterIndex = i + 1;
  48036. expression = exp.slice(0, i).trim();
  48037. } else {
  48038. pushFilter();
  48039. }
  48040. } else {
  48041. switch (c) {
  48042. case 0x22: inDouble = true; break // "
  48043. case 0x27: inSingle = true; break // '
  48044. case 0x60: inTemplateString = true; break // `
  48045. case 0x28: paren++; break // (
  48046. case 0x29: paren--; break // )
  48047. case 0x5B: square++; break // [
  48048. case 0x5D: square--; break // ]
  48049. case 0x7B: curly++; break // {
  48050. case 0x7D: curly--; break // }
  48051. }
  48052. if (c === 0x2f) { // /
  48053. var j = i - 1;
  48054. var p = (void 0);
  48055. // find first non-whitespace prev char
  48056. for (; j >= 0; j--) {
  48057. p = exp.charAt(j);
  48058. if (p !== ' ') { break }
  48059. }
  48060. if (!p || !validDivisionCharRE.test(p)) {
  48061. inRegex = true;
  48062. }
  48063. }
  48064. }
  48065. }
  48066. if (expression === undefined) {
  48067. expression = exp.slice(0, i).trim();
  48068. } else if (lastFilterIndex !== 0) {
  48069. pushFilter();
  48070. }
  48071. function pushFilter () {
  48072. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  48073. lastFilterIndex = i + 1;
  48074. }
  48075. if (filters) {
  48076. for (i = 0; i < filters.length; i++) {
  48077. expression = wrapFilter(expression, filters[i]);
  48078. }
  48079. }
  48080. return expression
  48081. }
  48082. function wrapFilter (exp, filter) {
  48083. var i = filter.indexOf('(');
  48084. if (i < 0) {
  48085. // _f: resolveFilter
  48086. return ("_f(\"" + filter + "\")(" + exp + ")")
  48087. } else {
  48088. var name = filter.slice(0, i);
  48089. var args = filter.slice(i + 1);
  48090. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  48091. }
  48092. }
  48093. /* */
  48094. /* eslint-disable no-unused-vars */
  48095. function baseWarn (msg, range) {
  48096. console.error(("[Vue compiler]: " + msg));
  48097. }
  48098. /* eslint-enable no-unused-vars */
  48099. function pluckModuleFunction (
  48100. modules,
  48101. key
  48102. ) {
  48103. return modules
  48104. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  48105. : []
  48106. }
  48107. function addProp (el, name, value, range, dynamic) {
  48108. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48109. el.plain = false;
  48110. }
  48111. function addAttr (el, name, value, range, dynamic) {
  48112. var attrs = dynamic
  48113. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  48114. : (el.attrs || (el.attrs = []));
  48115. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  48116. el.plain = false;
  48117. }
  48118. // add a raw attr (use this in preTransforms)
  48119. function addRawAttr (el, name, value, range) {
  48120. el.attrsMap[name] = value;
  48121. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  48122. }
  48123. function addDirective (
  48124. el,
  48125. name,
  48126. rawName,
  48127. value,
  48128. arg,
  48129. isDynamicArg,
  48130. modifiers,
  48131. range
  48132. ) {
  48133. (el.directives || (el.directives = [])).push(rangeSetItem({
  48134. name: name,
  48135. rawName: rawName,
  48136. value: value,
  48137. arg: arg,
  48138. isDynamicArg: isDynamicArg,
  48139. modifiers: modifiers
  48140. }, range));
  48141. el.plain = false;
  48142. }
  48143. function prependModifierMarker (symbol, name, dynamic) {
  48144. return dynamic
  48145. ? ("_p(" + name + ",\"" + symbol + "\")")
  48146. : symbol + name // mark the event as captured
  48147. }
  48148. function addHandler (
  48149. el,
  48150. name,
  48151. value,
  48152. modifiers,
  48153. important,
  48154. warn,
  48155. range,
  48156. dynamic
  48157. ) {
  48158. modifiers = modifiers || emptyObject;
  48159. // warn prevent and passive modifier
  48160. /* istanbul ignore if */
  48161. if (
  48162. warn &&
  48163. modifiers.prevent && modifiers.passive
  48164. ) {
  48165. warn(
  48166. 'passive and prevent can\'t be used together. ' +
  48167. 'Passive handler can\'t prevent default event.',
  48168. range
  48169. );
  48170. }
  48171. // normalize click.right and click.middle since they don't actually fire
  48172. // this is technically browser-specific, but at least for now browsers are
  48173. // the only target envs that have right/middle clicks.
  48174. if (modifiers.right) {
  48175. if (dynamic) {
  48176. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48177. } else if (name === 'click') {
  48178. name = 'contextmenu';
  48179. delete modifiers.right;
  48180. }
  48181. } else if (modifiers.middle) {
  48182. if (dynamic) {
  48183. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48184. } else if (name === 'click') {
  48185. name = 'mouseup';
  48186. }
  48187. }
  48188. // check capture modifier
  48189. if (modifiers.capture) {
  48190. delete modifiers.capture;
  48191. name = prependModifierMarker('!', name, dynamic);
  48192. }
  48193. if (modifiers.once) {
  48194. delete modifiers.once;
  48195. name = prependModifierMarker('~', name, dynamic);
  48196. }
  48197. /* istanbul ignore if */
  48198. if (modifiers.passive) {
  48199. delete modifiers.passive;
  48200. name = prependModifierMarker('&', name, dynamic);
  48201. }
  48202. var events;
  48203. if (modifiers.native) {
  48204. delete modifiers.native;
  48205. events = el.nativeEvents || (el.nativeEvents = {});
  48206. } else {
  48207. events = el.events || (el.events = {});
  48208. }
  48209. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48210. if (modifiers !== emptyObject) {
  48211. newHandler.modifiers = modifiers;
  48212. }
  48213. var handlers = events[name];
  48214. /* istanbul ignore if */
  48215. if (Array.isArray(handlers)) {
  48216. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48217. } else if (handlers) {
  48218. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48219. } else {
  48220. events[name] = newHandler;
  48221. }
  48222. el.plain = false;
  48223. }
  48224. function getRawBindingAttr (
  48225. el,
  48226. name
  48227. ) {
  48228. return el.rawAttrsMap[':' + name] ||
  48229. el.rawAttrsMap['v-bind:' + name] ||
  48230. el.rawAttrsMap[name]
  48231. }
  48232. function getBindingAttr (
  48233. el,
  48234. name,
  48235. getStatic
  48236. ) {
  48237. var dynamicValue =
  48238. getAndRemoveAttr(el, ':' + name) ||
  48239. getAndRemoveAttr(el, 'v-bind:' + name);
  48240. if (dynamicValue != null) {
  48241. return parseFilters(dynamicValue)
  48242. } else if (getStatic !== false) {
  48243. var staticValue = getAndRemoveAttr(el, name);
  48244. if (staticValue != null) {
  48245. return JSON.stringify(staticValue)
  48246. }
  48247. }
  48248. }
  48249. // note: this only removes the attr from the Array (attrsList) so that it
  48250. // doesn't get processed by processAttrs.
  48251. // By default it does NOT remove it from the map (attrsMap) because the map is
  48252. // needed during codegen.
  48253. function getAndRemoveAttr (
  48254. el,
  48255. name,
  48256. removeFromMap
  48257. ) {
  48258. var val;
  48259. if ((val = el.attrsMap[name]) != null) {
  48260. var list = el.attrsList;
  48261. for (var i = 0, l = list.length; i < l; i++) {
  48262. if (list[i].name === name) {
  48263. list.splice(i, 1);
  48264. break
  48265. }
  48266. }
  48267. }
  48268. if (removeFromMap) {
  48269. delete el.attrsMap[name];
  48270. }
  48271. return val
  48272. }
  48273. function getAndRemoveAttrByRegex (
  48274. el,
  48275. name
  48276. ) {
  48277. var list = el.attrsList;
  48278. for (var i = 0, l = list.length; i < l; i++) {
  48279. var attr = list[i];
  48280. if (name.test(attr.name)) {
  48281. list.splice(i, 1);
  48282. return attr
  48283. }
  48284. }
  48285. }
  48286. function rangeSetItem (
  48287. item,
  48288. range
  48289. ) {
  48290. if (range) {
  48291. if (range.start != null) {
  48292. item.start = range.start;
  48293. }
  48294. if (range.end != null) {
  48295. item.end = range.end;
  48296. }
  48297. }
  48298. return item
  48299. }
  48300. /* */
  48301. /**
  48302. * Cross-platform code generation for component v-model
  48303. */
  48304. function genComponentModel (
  48305. el,
  48306. value,
  48307. modifiers
  48308. ) {
  48309. var ref = modifiers || {};
  48310. var number = ref.number;
  48311. var trim = ref.trim;
  48312. var baseValueExpression = '$$v';
  48313. var valueExpression = baseValueExpression;
  48314. if (trim) {
  48315. valueExpression =
  48316. "(typeof " + baseValueExpression + " === 'string'" +
  48317. "? " + baseValueExpression + ".trim()" +
  48318. ": " + baseValueExpression + ")";
  48319. }
  48320. if (number) {
  48321. valueExpression = "_n(" + valueExpression + ")";
  48322. }
  48323. var assignment = genAssignmentCode(value, valueExpression);
  48324. el.model = {
  48325. value: ("(" + value + ")"),
  48326. expression: JSON.stringify(value),
  48327. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48328. };
  48329. }
  48330. /**
  48331. * Cross-platform codegen helper for generating v-model value assignment code.
  48332. */
  48333. function genAssignmentCode (
  48334. value,
  48335. assignment
  48336. ) {
  48337. var res = parseModel(value);
  48338. if (res.key === null) {
  48339. return (value + "=" + assignment)
  48340. } else {
  48341. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48342. }
  48343. }
  48344. /**
  48345. * Parse a v-model expression into a base path and a final key segment.
  48346. * Handles both dot-path and possible square brackets.
  48347. *
  48348. * Possible cases:
  48349. *
  48350. * - test
  48351. * - test[key]
  48352. * - test[test1[key]]
  48353. * - test["a"][key]
  48354. * - xxx.test[a[a].test1[key]]
  48355. * - test.xxx.a["asa"][test1[key]]
  48356. *
  48357. */
  48358. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48359. function parseModel (val) {
  48360. // Fix https://github.com/vuejs/vue/pull/7730
  48361. // allow v-model="obj.val " (trailing whitespace)
  48362. val = val.trim();
  48363. len = val.length;
  48364. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48365. index$1 = val.lastIndexOf('.');
  48366. if (index$1 > -1) {
  48367. return {
  48368. exp: val.slice(0, index$1),
  48369. key: '"' + val.slice(index$1 + 1) + '"'
  48370. }
  48371. } else {
  48372. return {
  48373. exp: val,
  48374. key: null
  48375. }
  48376. }
  48377. }
  48378. str = val;
  48379. index$1 = expressionPos = expressionEndPos = 0;
  48380. while (!eof()) {
  48381. chr = next();
  48382. /* istanbul ignore if */
  48383. if (isStringStart(chr)) {
  48384. parseString(chr);
  48385. } else if (chr === 0x5B) {
  48386. parseBracket(chr);
  48387. }
  48388. }
  48389. return {
  48390. exp: val.slice(0, expressionPos),
  48391. key: val.slice(expressionPos + 1, expressionEndPos)
  48392. }
  48393. }
  48394. function next () {
  48395. return str.charCodeAt(++index$1)
  48396. }
  48397. function eof () {
  48398. return index$1 >= len
  48399. }
  48400. function isStringStart (chr) {
  48401. return chr === 0x22 || chr === 0x27
  48402. }
  48403. function parseBracket (chr) {
  48404. var inBracket = 1;
  48405. expressionPos = index$1;
  48406. while (!eof()) {
  48407. chr = next();
  48408. if (isStringStart(chr)) {
  48409. parseString(chr);
  48410. continue
  48411. }
  48412. if (chr === 0x5B) { inBracket++; }
  48413. if (chr === 0x5D) { inBracket--; }
  48414. if (inBracket === 0) {
  48415. expressionEndPos = index$1;
  48416. break
  48417. }
  48418. }
  48419. }
  48420. function parseString (chr) {
  48421. var stringQuote = chr;
  48422. while (!eof()) {
  48423. chr = next();
  48424. if (chr === stringQuote) {
  48425. break
  48426. }
  48427. }
  48428. }
  48429. /* */
  48430. var warn$1;
  48431. // in some cases, the event used has to be determined at runtime
  48432. // so we used some reserved tokens during compile.
  48433. var RANGE_TOKEN = '__r';
  48434. var CHECKBOX_RADIO_TOKEN = '__c';
  48435. function model (
  48436. el,
  48437. dir,
  48438. _warn
  48439. ) {
  48440. warn$1 = _warn;
  48441. var value = dir.value;
  48442. var modifiers = dir.modifiers;
  48443. var tag = el.tag;
  48444. var type = el.attrsMap.type;
  48445. {
  48446. // inputs with type="file" are read only and setting the input's
  48447. // value will throw an error.
  48448. if (tag === 'input' && type === 'file') {
  48449. warn$1(
  48450. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48451. "File inputs are read only. Use a v-on:change listener instead.",
  48452. el.rawAttrsMap['v-model']
  48453. );
  48454. }
  48455. }
  48456. if (el.component) {
  48457. genComponentModel(el, value, modifiers);
  48458. // component v-model doesn't need extra runtime
  48459. return false
  48460. } else if (tag === 'select') {
  48461. genSelect(el, value, modifiers);
  48462. } else if (tag === 'input' && type === 'checkbox') {
  48463. genCheckboxModel(el, value, modifiers);
  48464. } else if (tag === 'input' && type === 'radio') {
  48465. genRadioModel(el, value, modifiers);
  48466. } else if (tag === 'input' || tag === 'textarea') {
  48467. genDefaultModel(el, value, modifiers);
  48468. } else if (!config.isReservedTag(tag)) {
  48469. genComponentModel(el, value, modifiers);
  48470. // component v-model doesn't need extra runtime
  48471. return false
  48472. } else {
  48473. warn$1(
  48474. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48475. "v-model is not supported on this element type. " +
  48476. 'If you are working with contenteditable, it\'s recommended to ' +
  48477. 'wrap a library dedicated for that purpose inside a custom component.',
  48478. el.rawAttrsMap['v-model']
  48479. );
  48480. }
  48481. // ensure runtime directive metadata
  48482. return true
  48483. }
  48484. function genCheckboxModel (
  48485. el,
  48486. value,
  48487. modifiers
  48488. ) {
  48489. var number = modifiers && modifiers.number;
  48490. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48491. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48492. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48493. addProp(el, 'checked',
  48494. "Array.isArray(" + value + ")" +
  48495. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48496. trueValueBinding === 'true'
  48497. ? (":(" + value + ")")
  48498. : (":_q(" + value + "," + trueValueBinding + ")")
  48499. )
  48500. );
  48501. addHandler(el, 'change',
  48502. "var $$a=" + value + "," +
  48503. '$$el=$event.target,' +
  48504. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48505. 'if(Array.isArray($$a)){' +
  48506. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48507. '$$i=_i($$a,$$v);' +
  48508. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48509. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48510. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48511. null, true
  48512. );
  48513. }
  48514. function genRadioModel (
  48515. el,
  48516. value,
  48517. modifiers
  48518. ) {
  48519. var number = modifiers && modifiers.number;
  48520. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48521. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48522. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48523. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48524. }
  48525. function genSelect (
  48526. el,
  48527. value,
  48528. modifiers
  48529. ) {
  48530. var number = modifiers && modifiers.number;
  48531. var selectedVal = "Array.prototype.filter" +
  48532. ".call($event.target.options,function(o){return o.selected})" +
  48533. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48534. "return " + (number ? '_n(val)' : 'val') + "})";
  48535. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48536. var code = "var $$selectedVal = " + selectedVal + ";";
  48537. code = code + " " + (genAssignmentCode(value, assignment));
  48538. addHandler(el, 'change', code, null, true);
  48539. }
  48540. function genDefaultModel (
  48541. el,
  48542. value,
  48543. modifiers
  48544. ) {
  48545. var type = el.attrsMap.type;
  48546. // warn if v-bind:value conflicts with v-model
  48547. // except for inputs with v-bind:type
  48548. {
  48549. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48550. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48551. if (value$1 && !typeBinding) {
  48552. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48553. warn$1(
  48554. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48555. 'because the latter already expands to a value binding internally',
  48556. el.rawAttrsMap[binding]
  48557. );
  48558. }
  48559. }
  48560. var ref = modifiers || {};
  48561. var lazy = ref.lazy;
  48562. var number = ref.number;
  48563. var trim = ref.trim;
  48564. var needCompositionGuard = !lazy && type !== 'range';
  48565. var event = lazy
  48566. ? 'change'
  48567. : type === 'range'
  48568. ? RANGE_TOKEN
  48569. : 'input';
  48570. var valueExpression = '$event.target.value';
  48571. if (trim) {
  48572. valueExpression = "$event.target.value.trim()";
  48573. }
  48574. if (number) {
  48575. valueExpression = "_n(" + valueExpression + ")";
  48576. }
  48577. var code = genAssignmentCode(value, valueExpression);
  48578. if (needCompositionGuard) {
  48579. code = "if($event.target.composing)return;" + code;
  48580. }
  48581. addProp(el, 'value', ("(" + value + ")"));
  48582. addHandler(el, event, code, null, true);
  48583. if (trim || number) {
  48584. addHandler(el, 'blur', '$forceUpdate()');
  48585. }
  48586. }
  48587. /* */
  48588. // normalize v-model event tokens that can only be determined at runtime.
  48589. // it's important to place the event as the first in the array because
  48590. // the whole point is ensuring the v-model callback gets called before
  48591. // user-attached handlers.
  48592. function normalizeEvents (on) {
  48593. /* istanbul ignore if */
  48594. if (isDef(on[RANGE_TOKEN])) {
  48595. // IE input[type=range] only supports `change` event
  48596. var event = isIE ? 'change' : 'input';
  48597. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48598. delete on[RANGE_TOKEN];
  48599. }
  48600. // This was originally intended to fix #4521 but no longer necessary
  48601. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48602. /* istanbul ignore if */
  48603. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48604. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48605. delete on[CHECKBOX_RADIO_TOKEN];
  48606. }
  48607. }
  48608. var target$1;
  48609. function createOnceHandler$1 (event, handler, capture) {
  48610. var _target = target$1; // save current target element in closure
  48611. return function onceHandler () {
  48612. var res = handler.apply(null, arguments);
  48613. if (res !== null) {
  48614. remove$2(event, onceHandler, capture, _target);
  48615. }
  48616. }
  48617. }
  48618. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48619. // implementation and does not fire microtasks in between event propagation, so
  48620. // safe to exclude.
  48621. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48622. function add$1 (
  48623. name,
  48624. handler,
  48625. capture,
  48626. passive
  48627. ) {
  48628. // async edge case #6566: inner click event triggers patch, event handler
  48629. // attached to outer element during patch, and triggered again. This
  48630. // happens because browsers fire microtask ticks between event propagation.
  48631. // the solution is simple: we save the timestamp when a handler is attached,
  48632. // and the handler would only fire if the event passed to it was fired
  48633. // AFTER it was attached.
  48634. if (useMicrotaskFix) {
  48635. var attachedTimestamp = currentFlushTimestamp;
  48636. var original = handler;
  48637. handler = original._wrapper = function (e) {
  48638. if (
  48639. // no bubbling, should always fire.
  48640. // this is just a safety net in case event.timeStamp is unreliable in
  48641. // certain weird environments...
  48642. e.target === e.currentTarget ||
  48643. // event is fired after handler attachment
  48644. e.timeStamp >= attachedTimestamp ||
  48645. // bail for environments that have buggy event.timeStamp implementations
  48646. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48647. // #9681 QtWebEngine event.timeStamp is negative value
  48648. e.timeStamp <= 0 ||
  48649. // #9448 bail if event is fired in another document in a multi-page
  48650. // electron/nw.js app, since event.timeStamp will be using a different
  48651. // starting reference
  48652. e.target.ownerDocument !== document
  48653. ) {
  48654. return original.apply(this, arguments)
  48655. }
  48656. };
  48657. }
  48658. target$1.addEventListener(
  48659. name,
  48660. handler,
  48661. supportsPassive
  48662. ? { capture: capture, passive: passive }
  48663. : capture
  48664. );
  48665. }
  48666. function remove$2 (
  48667. name,
  48668. handler,
  48669. capture,
  48670. _target
  48671. ) {
  48672. (_target || target$1).removeEventListener(
  48673. name,
  48674. handler._wrapper || handler,
  48675. capture
  48676. );
  48677. }
  48678. function updateDOMListeners (oldVnode, vnode) {
  48679. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48680. return
  48681. }
  48682. var on = vnode.data.on || {};
  48683. var oldOn = oldVnode.data.on || {};
  48684. target$1 = vnode.elm;
  48685. normalizeEvents(on);
  48686. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48687. target$1 = undefined;
  48688. }
  48689. var events = {
  48690. create: updateDOMListeners,
  48691. update: updateDOMListeners
  48692. };
  48693. /* */
  48694. var svgContainer;
  48695. function updateDOMProps (oldVnode, vnode) {
  48696. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48697. return
  48698. }
  48699. var key, cur;
  48700. var elm = vnode.elm;
  48701. var oldProps = oldVnode.data.domProps || {};
  48702. var props = vnode.data.domProps || {};
  48703. // clone observed objects, as the user probably wants to mutate it
  48704. if (isDef(props.__ob__)) {
  48705. props = vnode.data.domProps = extend({}, props);
  48706. }
  48707. for (key in oldProps) {
  48708. if (!(key in props)) {
  48709. elm[key] = '';
  48710. }
  48711. }
  48712. for (key in props) {
  48713. cur = props[key];
  48714. // ignore children if the node has textContent or innerHTML,
  48715. // as these will throw away existing DOM nodes and cause removal errors
  48716. // on subsequent patches (#3360)
  48717. if (key === 'textContent' || key === 'innerHTML') {
  48718. if (vnode.children) { vnode.children.length = 0; }
  48719. if (cur === oldProps[key]) { continue }
  48720. // #6601 work around Chrome version <= 55 bug where single textNode
  48721. // replaced by innerHTML/textContent retains its parentNode property
  48722. if (elm.childNodes.length === 1) {
  48723. elm.removeChild(elm.childNodes[0]);
  48724. }
  48725. }
  48726. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48727. // store value as _value as well since
  48728. // non-string values will be stringified
  48729. elm._value = cur;
  48730. // avoid resetting cursor position when value is the same
  48731. var strCur = isUndef(cur) ? '' : String(cur);
  48732. if (shouldUpdateValue(elm, strCur)) {
  48733. elm.value = strCur;
  48734. }
  48735. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48736. // IE doesn't support innerHTML for SVG elements
  48737. svgContainer = svgContainer || document.createElement('div');
  48738. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48739. var svg = svgContainer.firstChild;
  48740. while (elm.firstChild) {
  48741. elm.removeChild(elm.firstChild);
  48742. }
  48743. while (svg.firstChild) {
  48744. elm.appendChild(svg.firstChild);
  48745. }
  48746. } else if (
  48747. // skip the update if old and new VDOM state is the same.
  48748. // `value` is handled separately because the DOM value may be temporarily
  48749. // out of sync with VDOM state due to focus, composition and modifiers.
  48750. // This #4521 by skipping the unnecesarry `checked` update.
  48751. cur !== oldProps[key]
  48752. ) {
  48753. // some property updates can throw
  48754. // e.g. `value` on <progress> w/ non-finite value
  48755. try {
  48756. elm[key] = cur;
  48757. } catch (e) {}
  48758. }
  48759. }
  48760. }
  48761. // check platforms/web/util/attrs.js acceptValue
  48762. function shouldUpdateValue (elm, checkVal) {
  48763. return (!elm.composing && (
  48764. elm.tagName === 'OPTION' ||
  48765. isNotInFocusAndDirty(elm, checkVal) ||
  48766. isDirtyWithModifiers(elm, checkVal)
  48767. ))
  48768. }
  48769. function isNotInFocusAndDirty (elm, checkVal) {
  48770. // return true when textbox (.number and .trim) loses focus and its value is
  48771. // not equal to the updated value
  48772. var notInFocus = true;
  48773. // #6157
  48774. // work around IE bug when accessing document.activeElement in an iframe
  48775. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48776. return notInFocus && elm.value !== checkVal
  48777. }
  48778. function isDirtyWithModifiers (elm, newVal) {
  48779. var value = elm.value;
  48780. var modifiers = elm._vModifiers; // injected by v-model runtime
  48781. if (isDef(modifiers)) {
  48782. if (modifiers.number) {
  48783. return toNumber(value) !== toNumber(newVal)
  48784. }
  48785. if (modifiers.trim) {
  48786. return value.trim() !== newVal.trim()
  48787. }
  48788. }
  48789. return value !== newVal
  48790. }
  48791. var domProps = {
  48792. create: updateDOMProps,
  48793. update: updateDOMProps
  48794. };
  48795. /* */
  48796. var parseStyleText = cached(function (cssText) {
  48797. var res = {};
  48798. var listDelimiter = /;(?![^(]*\))/g;
  48799. var propertyDelimiter = /:(.+)/;
  48800. cssText.split(listDelimiter).forEach(function (item) {
  48801. if (item) {
  48802. var tmp = item.split(propertyDelimiter);
  48803. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48804. }
  48805. });
  48806. return res
  48807. });
  48808. // merge static and dynamic style data on the same vnode
  48809. function normalizeStyleData (data) {
  48810. var style = normalizeStyleBinding(data.style);
  48811. // static style is pre-processed into an object during compilation
  48812. // and is always a fresh object, so it's safe to merge into it
  48813. return data.staticStyle
  48814. ? extend(data.staticStyle, style)
  48815. : style
  48816. }
  48817. // normalize possible array / string values into Object
  48818. function normalizeStyleBinding (bindingStyle) {
  48819. if (Array.isArray(bindingStyle)) {
  48820. return toObject(bindingStyle)
  48821. }
  48822. if (typeof bindingStyle === 'string') {
  48823. return parseStyleText(bindingStyle)
  48824. }
  48825. return bindingStyle
  48826. }
  48827. /**
  48828. * parent component style should be after child's
  48829. * so that parent component's style could override it
  48830. */
  48831. function getStyle (vnode, checkChild) {
  48832. var res = {};
  48833. var styleData;
  48834. if (checkChild) {
  48835. var childNode = vnode;
  48836. while (childNode.componentInstance) {
  48837. childNode = childNode.componentInstance._vnode;
  48838. if (
  48839. childNode && childNode.data &&
  48840. (styleData = normalizeStyleData(childNode.data))
  48841. ) {
  48842. extend(res, styleData);
  48843. }
  48844. }
  48845. }
  48846. if ((styleData = normalizeStyleData(vnode.data))) {
  48847. extend(res, styleData);
  48848. }
  48849. var parentNode = vnode;
  48850. while ((parentNode = parentNode.parent)) {
  48851. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48852. extend(res, styleData);
  48853. }
  48854. }
  48855. return res
  48856. }
  48857. /* */
  48858. var cssVarRE = /^--/;
  48859. var importantRE = /\s*!important$/;
  48860. var setProp = function (el, name, val) {
  48861. /* istanbul ignore if */
  48862. if (cssVarRE.test(name)) {
  48863. el.style.setProperty(name, val);
  48864. } else if (importantRE.test(val)) {
  48865. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48866. } else {
  48867. var normalizedName = normalize(name);
  48868. if (Array.isArray(val)) {
  48869. // Support values array created by autoprefixer, e.g.
  48870. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48871. // Set them one by one, and the browser will only set those it can recognize
  48872. for (var i = 0, len = val.length; i < len; i++) {
  48873. el.style[normalizedName] = val[i];
  48874. }
  48875. } else {
  48876. el.style[normalizedName] = val;
  48877. }
  48878. }
  48879. };
  48880. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48881. var emptyStyle;
  48882. var normalize = cached(function (prop) {
  48883. emptyStyle = emptyStyle || document.createElement('div').style;
  48884. prop = camelize(prop);
  48885. if (prop !== 'filter' && (prop in emptyStyle)) {
  48886. return prop
  48887. }
  48888. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48889. for (var i = 0; i < vendorNames.length; i++) {
  48890. var name = vendorNames[i] + capName;
  48891. if (name in emptyStyle) {
  48892. return name
  48893. }
  48894. }
  48895. });
  48896. function updateStyle (oldVnode, vnode) {
  48897. var data = vnode.data;
  48898. var oldData = oldVnode.data;
  48899. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48900. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48901. ) {
  48902. return
  48903. }
  48904. var cur, name;
  48905. var el = vnode.elm;
  48906. var oldStaticStyle = oldData.staticStyle;
  48907. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  48908. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  48909. var oldStyle = oldStaticStyle || oldStyleBinding;
  48910. var style = normalizeStyleBinding(vnode.data.style) || {};
  48911. // store normalized style under a different key for next diff
  48912. // make sure to clone it if it's reactive, since the user likely wants
  48913. // to mutate it.
  48914. vnode.data.normalizedStyle = isDef(style.__ob__)
  48915. ? extend({}, style)
  48916. : style;
  48917. var newStyle = getStyle(vnode, true);
  48918. for (name in oldStyle) {
  48919. if (isUndef(newStyle[name])) {
  48920. setProp(el, name, '');
  48921. }
  48922. }
  48923. for (name in newStyle) {
  48924. cur = newStyle[name];
  48925. if (cur !== oldStyle[name]) {
  48926. // ie9 setting to null has no effect, must use empty string
  48927. setProp(el, name, cur == null ? '' : cur);
  48928. }
  48929. }
  48930. }
  48931. var style = {
  48932. create: updateStyle,
  48933. update: updateStyle
  48934. };
  48935. /* */
  48936. var whitespaceRE = /\s+/;
  48937. /**
  48938. * Add class with compatibility for SVG since classList is not supported on
  48939. * SVG elements in IE
  48940. */
  48941. function addClass (el, cls) {
  48942. /* istanbul ignore if */
  48943. if (!cls || !(cls = cls.trim())) {
  48944. return
  48945. }
  48946. /* istanbul ignore else */
  48947. if (el.classList) {
  48948. if (cls.indexOf(' ') > -1) {
  48949. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  48950. } else {
  48951. el.classList.add(cls);
  48952. }
  48953. } else {
  48954. var cur = " " + (el.getAttribute('class') || '') + " ";
  48955. if (cur.indexOf(' ' + cls + ' ') < 0) {
  48956. el.setAttribute('class', (cur + cls).trim());
  48957. }
  48958. }
  48959. }
  48960. /**
  48961. * Remove class with compatibility for SVG since classList is not supported on
  48962. * SVG elements in IE
  48963. */
  48964. function removeClass (el, cls) {
  48965. /* istanbul ignore if */
  48966. if (!cls || !(cls = cls.trim())) {
  48967. return
  48968. }
  48969. /* istanbul ignore else */
  48970. if (el.classList) {
  48971. if (cls.indexOf(' ') > -1) {
  48972. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  48973. } else {
  48974. el.classList.remove(cls);
  48975. }
  48976. if (!el.classList.length) {
  48977. el.removeAttribute('class');
  48978. }
  48979. } else {
  48980. var cur = " " + (el.getAttribute('class') || '') + " ";
  48981. var tar = ' ' + cls + ' ';
  48982. while (cur.indexOf(tar) >= 0) {
  48983. cur = cur.replace(tar, ' ');
  48984. }
  48985. cur = cur.trim();
  48986. if (cur) {
  48987. el.setAttribute('class', cur);
  48988. } else {
  48989. el.removeAttribute('class');
  48990. }
  48991. }
  48992. }
  48993. /* */
  48994. function resolveTransition (def$$1) {
  48995. if (!def$$1) {
  48996. return
  48997. }
  48998. /* istanbul ignore else */
  48999. if (typeof def$$1 === 'object') {
  49000. var res = {};
  49001. if (def$$1.css !== false) {
  49002. extend(res, autoCssTransition(def$$1.name || 'v'));
  49003. }
  49004. extend(res, def$$1);
  49005. return res
  49006. } else if (typeof def$$1 === 'string') {
  49007. return autoCssTransition(def$$1)
  49008. }
  49009. }
  49010. var autoCssTransition = cached(function (name) {
  49011. return {
  49012. enterClass: (name + "-enter"),
  49013. enterToClass: (name + "-enter-to"),
  49014. enterActiveClass: (name + "-enter-active"),
  49015. leaveClass: (name + "-leave"),
  49016. leaveToClass: (name + "-leave-to"),
  49017. leaveActiveClass: (name + "-leave-active")
  49018. }
  49019. });
  49020. var hasTransition = inBrowser && !isIE9;
  49021. var TRANSITION = 'transition';
  49022. var ANIMATION = 'animation';
  49023. // Transition property/event sniffing
  49024. var transitionProp = 'transition';
  49025. var transitionEndEvent = 'transitionend';
  49026. var animationProp = 'animation';
  49027. var animationEndEvent = 'animationend';
  49028. if (hasTransition) {
  49029. /* istanbul ignore if */
  49030. if (window.ontransitionend === undefined &&
  49031. window.onwebkittransitionend !== undefined
  49032. ) {
  49033. transitionProp = 'WebkitTransition';
  49034. transitionEndEvent = 'webkitTransitionEnd';
  49035. }
  49036. if (window.onanimationend === undefined &&
  49037. window.onwebkitanimationend !== undefined
  49038. ) {
  49039. animationProp = 'WebkitAnimation';
  49040. animationEndEvent = 'webkitAnimationEnd';
  49041. }
  49042. }
  49043. // binding to window is necessary to make hot reload work in IE in strict mode
  49044. var raf = inBrowser
  49045. ? window.requestAnimationFrame
  49046. ? window.requestAnimationFrame.bind(window)
  49047. : setTimeout
  49048. : /* istanbul ignore next */ function (fn) { return fn(); };
  49049. function nextFrame (fn) {
  49050. raf(function () {
  49051. raf(fn);
  49052. });
  49053. }
  49054. function addTransitionClass (el, cls) {
  49055. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  49056. if (transitionClasses.indexOf(cls) < 0) {
  49057. transitionClasses.push(cls);
  49058. addClass(el, cls);
  49059. }
  49060. }
  49061. function removeTransitionClass (el, cls) {
  49062. if (el._transitionClasses) {
  49063. remove(el._transitionClasses, cls);
  49064. }
  49065. removeClass(el, cls);
  49066. }
  49067. function whenTransitionEnds (
  49068. el,
  49069. expectedType,
  49070. cb
  49071. ) {
  49072. var ref = getTransitionInfo(el, expectedType);
  49073. var type = ref.type;
  49074. var timeout = ref.timeout;
  49075. var propCount = ref.propCount;
  49076. if (!type) { return cb() }
  49077. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  49078. var ended = 0;
  49079. var end = function () {
  49080. el.removeEventListener(event, onEnd);
  49081. cb();
  49082. };
  49083. var onEnd = function (e) {
  49084. if (e.target === el) {
  49085. if (++ended >= propCount) {
  49086. end();
  49087. }
  49088. }
  49089. };
  49090. setTimeout(function () {
  49091. if (ended < propCount) {
  49092. end();
  49093. }
  49094. }, timeout + 1);
  49095. el.addEventListener(event, onEnd);
  49096. }
  49097. var transformRE = /\b(transform|all)(,|$)/;
  49098. function getTransitionInfo (el, expectedType) {
  49099. var styles = window.getComputedStyle(el);
  49100. // JSDOM may return undefined for transition properties
  49101. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  49102. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  49103. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  49104. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  49105. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  49106. var animationTimeout = getTimeout(animationDelays, animationDurations);
  49107. var type;
  49108. var timeout = 0;
  49109. var propCount = 0;
  49110. /* istanbul ignore if */
  49111. if (expectedType === TRANSITION) {
  49112. if (transitionTimeout > 0) {
  49113. type = TRANSITION;
  49114. timeout = transitionTimeout;
  49115. propCount = transitionDurations.length;
  49116. }
  49117. } else if (expectedType === ANIMATION) {
  49118. if (animationTimeout > 0) {
  49119. type = ANIMATION;
  49120. timeout = animationTimeout;
  49121. propCount = animationDurations.length;
  49122. }
  49123. } else {
  49124. timeout = Math.max(transitionTimeout, animationTimeout);
  49125. type = timeout > 0
  49126. ? transitionTimeout > animationTimeout
  49127. ? TRANSITION
  49128. : ANIMATION
  49129. : null;
  49130. propCount = type
  49131. ? type === TRANSITION
  49132. ? transitionDurations.length
  49133. : animationDurations.length
  49134. : 0;
  49135. }
  49136. var hasTransform =
  49137. type === TRANSITION &&
  49138. transformRE.test(styles[transitionProp + 'Property']);
  49139. return {
  49140. type: type,
  49141. timeout: timeout,
  49142. propCount: propCount,
  49143. hasTransform: hasTransform
  49144. }
  49145. }
  49146. function getTimeout (delays, durations) {
  49147. /* istanbul ignore next */
  49148. while (delays.length < durations.length) {
  49149. delays = delays.concat(delays);
  49150. }
  49151. return Math.max.apply(null, durations.map(function (d, i) {
  49152. return toMs(d) + toMs(delays[i])
  49153. }))
  49154. }
  49155. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49156. // in a locale-dependent way, using a comma instead of a dot.
  49157. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49158. // as a floor function) causing unexpected behaviors
  49159. function toMs (s) {
  49160. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49161. }
  49162. /* */
  49163. function enter (vnode, toggleDisplay) {
  49164. var el = vnode.elm;
  49165. // call leave callback now
  49166. if (isDef(el._leaveCb)) {
  49167. el._leaveCb.cancelled = true;
  49168. el._leaveCb();
  49169. }
  49170. var data = resolveTransition(vnode.data.transition);
  49171. if (isUndef(data)) {
  49172. return
  49173. }
  49174. /* istanbul ignore if */
  49175. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49176. return
  49177. }
  49178. var css = data.css;
  49179. var type = data.type;
  49180. var enterClass = data.enterClass;
  49181. var enterToClass = data.enterToClass;
  49182. var enterActiveClass = data.enterActiveClass;
  49183. var appearClass = data.appearClass;
  49184. var appearToClass = data.appearToClass;
  49185. var appearActiveClass = data.appearActiveClass;
  49186. var beforeEnter = data.beforeEnter;
  49187. var enter = data.enter;
  49188. var afterEnter = data.afterEnter;
  49189. var enterCancelled = data.enterCancelled;
  49190. var beforeAppear = data.beforeAppear;
  49191. var appear = data.appear;
  49192. var afterAppear = data.afterAppear;
  49193. var appearCancelled = data.appearCancelled;
  49194. var duration = data.duration;
  49195. // activeInstance will always be the <transition> component managing this
  49196. // transition. One edge case to check is when the <transition> is placed
  49197. // as the root node of a child component. In that case we need to check
  49198. // <transition>'s parent for appear check.
  49199. var context = activeInstance;
  49200. var transitionNode = activeInstance.$vnode;
  49201. while (transitionNode && transitionNode.parent) {
  49202. context = transitionNode.context;
  49203. transitionNode = transitionNode.parent;
  49204. }
  49205. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49206. if (isAppear && !appear && appear !== '') {
  49207. return
  49208. }
  49209. var startClass = isAppear && appearClass
  49210. ? appearClass
  49211. : enterClass;
  49212. var activeClass = isAppear && appearActiveClass
  49213. ? appearActiveClass
  49214. : enterActiveClass;
  49215. var toClass = isAppear && appearToClass
  49216. ? appearToClass
  49217. : enterToClass;
  49218. var beforeEnterHook = isAppear
  49219. ? (beforeAppear || beforeEnter)
  49220. : beforeEnter;
  49221. var enterHook = isAppear
  49222. ? (typeof appear === 'function' ? appear : enter)
  49223. : enter;
  49224. var afterEnterHook = isAppear
  49225. ? (afterAppear || afterEnter)
  49226. : afterEnter;
  49227. var enterCancelledHook = isAppear
  49228. ? (appearCancelled || enterCancelled)
  49229. : enterCancelled;
  49230. var explicitEnterDuration = toNumber(
  49231. isObject(duration)
  49232. ? duration.enter
  49233. : duration
  49234. );
  49235. if (explicitEnterDuration != null) {
  49236. checkDuration(explicitEnterDuration, 'enter', vnode);
  49237. }
  49238. var expectsCSS = css !== false && !isIE9;
  49239. var userWantsControl = getHookArgumentsLength(enterHook);
  49240. var cb = el._enterCb = once(function () {
  49241. if (expectsCSS) {
  49242. removeTransitionClass(el, toClass);
  49243. removeTransitionClass(el, activeClass);
  49244. }
  49245. if (cb.cancelled) {
  49246. if (expectsCSS) {
  49247. removeTransitionClass(el, startClass);
  49248. }
  49249. enterCancelledHook && enterCancelledHook(el);
  49250. } else {
  49251. afterEnterHook && afterEnterHook(el);
  49252. }
  49253. el._enterCb = null;
  49254. });
  49255. if (!vnode.data.show) {
  49256. // remove pending leave element on enter by injecting an insert hook
  49257. mergeVNodeHook(vnode, 'insert', function () {
  49258. var parent = el.parentNode;
  49259. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49260. if (pendingNode &&
  49261. pendingNode.tag === vnode.tag &&
  49262. pendingNode.elm._leaveCb
  49263. ) {
  49264. pendingNode.elm._leaveCb();
  49265. }
  49266. enterHook && enterHook(el, cb);
  49267. });
  49268. }
  49269. // start enter transition
  49270. beforeEnterHook && beforeEnterHook(el);
  49271. if (expectsCSS) {
  49272. addTransitionClass(el, startClass);
  49273. addTransitionClass(el, activeClass);
  49274. nextFrame(function () {
  49275. removeTransitionClass(el, startClass);
  49276. if (!cb.cancelled) {
  49277. addTransitionClass(el, toClass);
  49278. if (!userWantsControl) {
  49279. if (isValidDuration(explicitEnterDuration)) {
  49280. setTimeout(cb, explicitEnterDuration);
  49281. } else {
  49282. whenTransitionEnds(el, type, cb);
  49283. }
  49284. }
  49285. }
  49286. });
  49287. }
  49288. if (vnode.data.show) {
  49289. toggleDisplay && toggleDisplay();
  49290. enterHook && enterHook(el, cb);
  49291. }
  49292. if (!expectsCSS && !userWantsControl) {
  49293. cb();
  49294. }
  49295. }
  49296. function leave (vnode, rm) {
  49297. var el = vnode.elm;
  49298. // call enter callback now
  49299. if (isDef(el._enterCb)) {
  49300. el._enterCb.cancelled = true;
  49301. el._enterCb();
  49302. }
  49303. var data = resolveTransition(vnode.data.transition);
  49304. if (isUndef(data) || el.nodeType !== 1) {
  49305. return rm()
  49306. }
  49307. /* istanbul ignore if */
  49308. if (isDef(el._leaveCb)) {
  49309. return
  49310. }
  49311. var css = data.css;
  49312. var type = data.type;
  49313. var leaveClass = data.leaveClass;
  49314. var leaveToClass = data.leaveToClass;
  49315. var leaveActiveClass = data.leaveActiveClass;
  49316. var beforeLeave = data.beforeLeave;
  49317. var leave = data.leave;
  49318. var afterLeave = data.afterLeave;
  49319. var leaveCancelled = data.leaveCancelled;
  49320. var delayLeave = data.delayLeave;
  49321. var duration = data.duration;
  49322. var expectsCSS = css !== false && !isIE9;
  49323. var userWantsControl = getHookArgumentsLength(leave);
  49324. var explicitLeaveDuration = toNumber(
  49325. isObject(duration)
  49326. ? duration.leave
  49327. : duration
  49328. );
  49329. if (isDef(explicitLeaveDuration)) {
  49330. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49331. }
  49332. var cb = el._leaveCb = once(function () {
  49333. if (el.parentNode && el.parentNode._pending) {
  49334. el.parentNode._pending[vnode.key] = null;
  49335. }
  49336. if (expectsCSS) {
  49337. removeTransitionClass(el, leaveToClass);
  49338. removeTransitionClass(el, leaveActiveClass);
  49339. }
  49340. if (cb.cancelled) {
  49341. if (expectsCSS) {
  49342. removeTransitionClass(el, leaveClass);
  49343. }
  49344. leaveCancelled && leaveCancelled(el);
  49345. } else {
  49346. rm();
  49347. afterLeave && afterLeave(el);
  49348. }
  49349. el._leaveCb = null;
  49350. });
  49351. if (delayLeave) {
  49352. delayLeave(performLeave);
  49353. } else {
  49354. performLeave();
  49355. }
  49356. function performLeave () {
  49357. // the delayed leave may have already been cancelled
  49358. if (cb.cancelled) {
  49359. return
  49360. }
  49361. // record leaving element
  49362. if (!vnode.data.show && el.parentNode) {
  49363. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49364. }
  49365. beforeLeave && beforeLeave(el);
  49366. if (expectsCSS) {
  49367. addTransitionClass(el, leaveClass);
  49368. addTransitionClass(el, leaveActiveClass);
  49369. nextFrame(function () {
  49370. removeTransitionClass(el, leaveClass);
  49371. if (!cb.cancelled) {
  49372. addTransitionClass(el, leaveToClass);
  49373. if (!userWantsControl) {
  49374. if (isValidDuration(explicitLeaveDuration)) {
  49375. setTimeout(cb, explicitLeaveDuration);
  49376. } else {
  49377. whenTransitionEnds(el, type, cb);
  49378. }
  49379. }
  49380. }
  49381. });
  49382. }
  49383. leave && leave(el, cb);
  49384. if (!expectsCSS && !userWantsControl) {
  49385. cb();
  49386. }
  49387. }
  49388. }
  49389. // only used in dev mode
  49390. function checkDuration (val, name, vnode) {
  49391. if (typeof val !== 'number') {
  49392. warn(
  49393. "<transition> explicit " + name + " duration is not a valid number - " +
  49394. "got " + (JSON.stringify(val)) + ".",
  49395. vnode.context
  49396. );
  49397. } else if (isNaN(val)) {
  49398. warn(
  49399. "<transition> explicit " + name + " duration is NaN - " +
  49400. 'the duration expression might be incorrect.',
  49401. vnode.context
  49402. );
  49403. }
  49404. }
  49405. function isValidDuration (val) {
  49406. return typeof val === 'number' && !isNaN(val)
  49407. }
  49408. /**
  49409. * Normalize a transition hook's argument length. The hook may be:
  49410. * - a merged hook (invoker) with the original in .fns
  49411. * - a wrapped component method (check ._length)
  49412. * - a plain function (.length)
  49413. */
  49414. function getHookArgumentsLength (fn) {
  49415. if (isUndef(fn)) {
  49416. return false
  49417. }
  49418. var invokerFns = fn.fns;
  49419. if (isDef(invokerFns)) {
  49420. // invoker
  49421. return getHookArgumentsLength(
  49422. Array.isArray(invokerFns)
  49423. ? invokerFns[0]
  49424. : invokerFns
  49425. )
  49426. } else {
  49427. return (fn._length || fn.length) > 1
  49428. }
  49429. }
  49430. function _enter (_, vnode) {
  49431. if (vnode.data.show !== true) {
  49432. enter(vnode);
  49433. }
  49434. }
  49435. var transition = inBrowser ? {
  49436. create: _enter,
  49437. activate: _enter,
  49438. remove: function remove$$1 (vnode, rm) {
  49439. /* istanbul ignore else */
  49440. if (vnode.data.show !== true) {
  49441. leave(vnode, rm);
  49442. } else {
  49443. rm();
  49444. }
  49445. }
  49446. } : {};
  49447. var platformModules = [
  49448. attrs,
  49449. klass,
  49450. events,
  49451. domProps,
  49452. style,
  49453. transition
  49454. ];
  49455. /* */
  49456. // the directive module should be applied last, after all
  49457. // built-in modules have been applied.
  49458. var modules = platformModules.concat(baseModules);
  49459. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49460. /**
  49461. * Not type checking this file because flow doesn't like attaching
  49462. * properties to Elements.
  49463. */
  49464. /* istanbul ignore if */
  49465. if (isIE9) {
  49466. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49467. document.addEventListener('selectionchange', function () {
  49468. var el = document.activeElement;
  49469. if (el && el.vmodel) {
  49470. trigger(el, 'input');
  49471. }
  49472. });
  49473. }
  49474. var directive = {
  49475. inserted: function inserted (el, binding, vnode, oldVnode) {
  49476. if (vnode.tag === 'select') {
  49477. // #6903
  49478. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49479. mergeVNodeHook(vnode, 'postpatch', function () {
  49480. directive.componentUpdated(el, binding, vnode);
  49481. });
  49482. } else {
  49483. setSelected(el, binding, vnode.context);
  49484. }
  49485. el._vOptions = [].map.call(el.options, getValue);
  49486. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49487. el._vModifiers = binding.modifiers;
  49488. if (!binding.modifiers.lazy) {
  49489. el.addEventListener('compositionstart', onCompositionStart);
  49490. el.addEventListener('compositionend', onCompositionEnd);
  49491. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49492. // switching focus before confirming composition choice
  49493. // this also fixes the issue where some browsers e.g. iOS Chrome
  49494. // fires "change" instead of "input" on autocomplete.
  49495. el.addEventListener('change', onCompositionEnd);
  49496. /* istanbul ignore if */
  49497. if (isIE9) {
  49498. el.vmodel = true;
  49499. }
  49500. }
  49501. }
  49502. },
  49503. componentUpdated: function componentUpdated (el, binding, vnode) {
  49504. if (vnode.tag === 'select') {
  49505. setSelected(el, binding, vnode.context);
  49506. // in case the options rendered by v-for have changed,
  49507. // it's possible that the value is out-of-sync with the rendered options.
  49508. // detect such cases and filter out values that no longer has a matching
  49509. // option in the DOM.
  49510. var prevOptions = el._vOptions;
  49511. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49512. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49513. // trigger change event if
  49514. // no matching option found for at least one value
  49515. var needReset = el.multiple
  49516. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49517. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49518. if (needReset) {
  49519. trigger(el, 'change');
  49520. }
  49521. }
  49522. }
  49523. }
  49524. };
  49525. function setSelected (el, binding, vm) {
  49526. actuallySetSelected(el, binding, vm);
  49527. /* istanbul ignore if */
  49528. if (isIE || isEdge) {
  49529. setTimeout(function () {
  49530. actuallySetSelected(el, binding, vm);
  49531. }, 0);
  49532. }
  49533. }
  49534. function actuallySetSelected (el, binding, vm) {
  49535. var value = binding.value;
  49536. var isMultiple = el.multiple;
  49537. if (isMultiple && !Array.isArray(value)) {
  49538. warn(
  49539. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49540. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49541. vm
  49542. );
  49543. return
  49544. }
  49545. var selected, option;
  49546. for (var i = 0, l = el.options.length; i < l; i++) {
  49547. option = el.options[i];
  49548. if (isMultiple) {
  49549. selected = looseIndexOf(value, getValue(option)) > -1;
  49550. if (option.selected !== selected) {
  49551. option.selected = selected;
  49552. }
  49553. } else {
  49554. if (looseEqual(getValue(option), value)) {
  49555. if (el.selectedIndex !== i) {
  49556. el.selectedIndex = i;
  49557. }
  49558. return
  49559. }
  49560. }
  49561. }
  49562. if (!isMultiple) {
  49563. el.selectedIndex = -1;
  49564. }
  49565. }
  49566. function hasNoMatchingOption (value, options) {
  49567. return options.every(function (o) { return !looseEqual(o, value); })
  49568. }
  49569. function getValue (option) {
  49570. return '_value' in option
  49571. ? option._value
  49572. : option.value
  49573. }
  49574. function onCompositionStart (e) {
  49575. e.target.composing = true;
  49576. }
  49577. function onCompositionEnd (e) {
  49578. // prevent triggering an input event for no reason
  49579. if (!e.target.composing) { return }
  49580. e.target.composing = false;
  49581. trigger(e.target, 'input');
  49582. }
  49583. function trigger (el, type) {
  49584. var e = document.createEvent('HTMLEvents');
  49585. e.initEvent(type, true, true);
  49586. el.dispatchEvent(e);
  49587. }
  49588. /* */
  49589. // recursively search for possible transition defined inside the component root
  49590. function locateNode (vnode) {
  49591. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49592. ? locateNode(vnode.componentInstance._vnode)
  49593. : vnode
  49594. }
  49595. var show = {
  49596. bind: function bind (el, ref, vnode) {
  49597. var value = ref.value;
  49598. vnode = locateNode(vnode);
  49599. var transition$$1 = vnode.data && vnode.data.transition;
  49600. var originalDisplay = el.__vOriginalDisplay =
  49601. el.style.display === 'none' ? '' : el.style.display;
  49602. if (value && transition$$1) {
  49603. vnode.data.show = true;
  49604. enter(vnode, function () {
  49605. el.style.display = originalDisplay;
  49606. });
  49607. } else {
  49608. el.style.display = value ? originalDisplay : 'none';
  49609. }
  49610. },
  49611. update: function update (el, ref, vnode) {
  49612. var value = ref.value;
  49613. var oldValue = ref.oldValue;
  49614. /* istanbul ignore if */
  49615. if (!value === !oldValue) { return }
  49616. vnode = locateNode(vnode);
  49617. var transition$$1 = vnode.data && vnode.data.transition;
  49618. if (transition$$1) {
  49619. vnode.data.show = true;
  49620. if (value) {
  49621. enter(vnode, function () {
  49622. el.style.display = el.__vOriginalDisplay;
  49623. });
  49624. } else {
  49625. leave(vnode, function () {
  49626. el.style.display = 'none';
  49627. });
  49628. }
  49629. } else {
  49630. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49631. }
  49632. },
  49633. unbind: function unbind (
  49634. el,
  49635. binding,
  49636. vnode,
  49637. oldVnode,
  49638. isDestroy
  49639. ) {
  49640. if (!isDestroy) {
  49641. el.style.display = el.__vOriginalDisplay;
  49642. }
  49643. }
  49644. };
  49645. var platformDirectives = {
  49646. model: directive,
  49647. show: show
  49648. };
  49649. /* */
  49650. var transitionProps = {
  49651. name: String,
  49652. appear: Boolean,
  49653. css: Boolean,
  49654. mode: String,
  49655. type: String,
  49656. enterClass: String,
  49657. leaveClass: String,
  49658. enterToClass: String,
  49659. leaveToClass: String,
  49660. enterActiveClass: String,
  49661. leaveActiveClass: String,
  49662. appearClass: String,
  49663. appearActiveClass: String,
  49664. appearToClass: String,
  49665. duration: [Number, String, Object]
  49666. };
  49667. // in case the child is also an abstract component, e.g. <keep-alive>
  49668. // we want to recursively retrieve the real component to be rendered
  49669. function getRealChild (vnode) {
  49670. var compOptions = vnode && vnode.componentOptions;
  49671. if (compOptions && compOptions.Ctor.options.abstract) {
  49672. return getRealChild(getFirstComponentChild(compOptions.children))
  49673. } else {
  49674. return vnode
  49675. }
  49676. }
  49677. function extractTransitionData (comp) {
  49678. var data = {};
  49679. var options = comp.$options;
  49680. // props
  49681. for (var key in options.propsData) {
  49682. data[key] = comp[key];
  49683. }
  49684. // events.
  49685. // extract listeners and pass them directly to the transition methods
  49686. var listeners = options._parentListeners;
  49687. for (var key$1 in listeners) {
  49688. data[camelize(key$1)] = listeners[key$1];
  49689. }
  49690. return data
  49691. }
  49692. function placeholder (h, rawChild) {
  49693. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49694. return h('keep-alive', {
  49695. props: rawChild.componentOptions.propsData
  49696. })
  49697. }
  49698. }
  49699. function hasParentTransition (vnode) {
  49700. while ((vnode = vnode.parent)) {
  49701. if (vnode.data.transition) {
  49702. return true
  49703. }
  49704. }
  49705. }
  49706. function isSameChild (child, oldChild) {
  49707. return oldChild.key === child.key && oldChild.tag === child.tag
  49708. }
  49709. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49710. var isVShowDirective = function (d) { return d.name === 'show'; };
  49711. var Transition = {
  49712. name: 'transition',
  49713. props: transitionProps,
  49714. abstract: true,
  49715. render: function render (h) {
  49716. var this$1 = this;
  49717. var children = this.$slots.default;
  49718. if (!children) {
  49719. return
  49720. }
  49721. // filter out text nodes (possible whitespaces)
  49722. children = children.filter(isNotTextNode);
  49723. /* istanbul ignore if */
  49724. if (!children.length) {
  49725. return
  49726. }
  49727. // warn multiple elements
  49728. if (children.length > 1) {
  49729. warn(
  49730. '<transition> can only be used on a single element. Use ' +
  49731. '<transition-group> for lists.',
  49732. this.$parent
  49733. );
  49734. }
  49735. var mode = this.mode;
  49736. // warn invalid mode
  49737. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49738. ) {
  49739. warn(
  49740. 'invalid <transition> mode: ' + mode,
  49741. this.$parent
  49742. );
  49743. }
  49744. var rawChild = children[0];
  49745. // if this is a component root node and the component's
  49746. // parent container node also has transition, skip.
  49747. if (hasParentTransition(this.$vnode)) {
  49748. return rawChild
  49749. }
  49750. // apply transition data to child
  49751. // use getRealChild() to ignore abstract components e.g. keep-alive
  49752. var child = getRealChild(rawChild);
  49753. /* istanbul ignore if */
  49754. if (!child) {
  49755. return rawChild
  49756. }
  49757. if (this._leaving) {
  49758. return placeholder(h, rawChild)
  49759. }
  49760. // ensure a key that is unique to the vnode type and to this transition
  49761. // component instance. This key will be used to remove pending leaving nodes
  49762. // during entering.
  49763. var id = "__transition-" + (this._uid) + "-";
  49764. child.key = child.key == null
  49765. ? child.isComment
  49766. ? id + 'comment'
  49767. : id + child.tag
  49768. : isPrimitive(child.key)
  49769. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49770. : child.key;
  49771. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49772. var oldRawChild = this._vnode;
  49773. var oldChild = getRealChild(oldRawChild);
  49774. // mark v-show
  49775. // so that the transition module can hand over the control to the directive
  49776. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49777. child.data.show = true;
  49778. }
  49779. if (
  49780. oldChild &&
  49781. oldChild.data &&
  49782. !isSameChild(child, oldChild) &&
  49783. !isAsyncPlaceholder(oldChild) &&
  49784. // #6687 component root is a comment node
  49785. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49786. ) {
  49787. // replace old child transition data with fresh one
  49788. // important for dynamic transitions!
  49789. var oldData = oldChild.data.transition = extend({}, data);
  49790. // handle transition mode
  49791. if (mode === 'out-in') {
  49792. // return placeholder node and queue update when leave finishes
  49793. this._leaving = true;
  49794. mergeVNodeHook(oldData, 'afterLeave', function () {
  49795. this$1._leaving = false;
  49796. this$1.$forceUpdate();
  49797. });
  49798. return placeholder(h, rawChild)
  49799. } else if (mode === 'in-out') {
  49800. if (isAsyncPlaceholder(child)) {
  49801. return oldRawChild
  49802. }
  49803. var delayedLeave;
  49804. var performLeave = function () { delayedLeave(); };
  49805. mergeVNodeHook(data, 'afterEnter', performLeave);
  49806. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49807. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49808. }
  49809. }
  49810. return rawChild
  49811. }
  49812. };
  49813. /* */
  49814. var props = extend({
  49815. tag: String,
  49816. moveClass: String
  49817. }, transitionProps);
  49818. delete props.mode;
  49819. var TransitionGroup = {
  49820. props: props,
  49821. beforeMount: function beforeMount () {
  49822. var this$1 = this;
  49823. var update = this._update;
  49824. this._update = function (vnode, hydrating) {
  49825. var restoreActiveInstance = setActiveInstance(this$1);
  49826. // force removing pass
  49827. this$1.__patch__(
  49828. this$1._vnode,
  49829. this$1.kept,
  49830. false, // hydrating
  49831. true // removeOnly (!important, avoids unnecessary moves)
  49832. );
  49833. this$1._vnode = this$1.kept;
  49834. restoreActiveInstance();
  49835. update.call(this$1, vnode, hydrating);
  49836. };
  49837. },
  49838. render: function render (h) {
  49839. var tag = this.tag || this.$vnode.data.tag || 'span';
  49840. var map = Object.create(null);
  49841. var prevChildren = this.prevChildren = this.children;
  49842. var rawChildren = this.$slots.default || [];
  49843. var children = this.children = [];
  49844. var transitionData = extractTransitionData(this);
  49845. for (var i = 0; i < rawChildren.length; i++) {
  49846. var c = rawChildren[i];
  49847. if (c.tag) {
  49848. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49849. children.push(c);
  49850. map[c.key] = c
  49851. ;(c.data || (c.data = {})).transition = transitionData;
  49852. } else {
  49853. var opts = c.componentOptions;
  49854. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49855. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49856. }
  49857. }
  49858. }
  49859. if (prevChildren) {
  49860. var kept = [];
  49861. var removed = [];
  49862. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49863. var c$1 = prevChildren[i$1];
  49864. c$1.data.transition = transitionData;
  49865. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49866. if (map[c$1.key]) {
  49867. kept.push(c$1);
  49868. } else {
  49869. removed.push(c$1);
  49870. }
  49871. }
  49872. this.kept = h(tag, null, kept);
  49873. this.removed = removed;
  49874. }
  49875. return h(tag, null, children)
  49876. },
  49877. updated: function updated () {
  49878. var children = this.prevChildren;
  49879. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49880. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49881. return
  49882. }
  49883. // we divide the work into three loops to avoid mixing DOM reads and writes
  49884. // in each iteration - which helps prevent layout thrashing.
  49885. children.forEach(callPendingCbs);
  49886. children.forEach(recordPosition);
  49887. children.forEach(applyTranslation);
  49888. // force reflow to put everything in position
  49889. // assign to this to avoid being removed in tree-shaking
  49890. // $flow-disable-line
  49891. this._reflow = document.body.offsetHeight;
  49892. children.forEach(function (c) {
  49893. if (c.data.moved) {
  49894. var el = c.elm;
  49895. var s = el.style;
  49896. addTransitionClass(el, moveClass);
  49897. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49898. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49899. if (e && e.target !== el) {
  49900. return
  49901. }
  49902. if (!e || /transform$/.test(e.propertyName)) {
  49903. el.removeEventListener(transitionEndEvent, cb);
  49904. el._moveCb = null;
  49905. removeTransitionClass(el, moveClass);
  49906. }
  49907. });
  49908. }
  49909. });
  49910. },
  49911. methods: {
  49912. hasMove: function hasMove (el, moveClass) {
  49913. /* istanbul ignore if */
  49914. if (!hasTransition) {
  49915. return false
  49916. }
  49917. /* istanbul ignore if */
  49918. if (this._hasMove) {
  49919. return this._hasMove
  49920. }
  49921. // Detect whether an element with the move class applied has
  49922. // CSS transitions. Since the element may be inside an entering
  49923. // transition at this very moment, we make a clone of it and remove
  49924. // all other transition classes applied to ensure only the move class
  49925. // is applied.
  49926. var clone = el.cloneNode();
  49927. if (el._transitionClasses) {
  49928. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  49929. }
  49930. addClass(clone, moveClass);
  49931. clone.style.display = 'none';
  49932. this.$el.appendChild(clone);
  49933. var info = getTransitionInfo(clone);
  49934. this.$el.removeChild(clone);
  49935. return (this._hasMove = info.hasTransform)
  49936. }
  49937. }
  49938. };
  49939. function callPendingCbs (c) {
  49940. /* istanbul ignore if */
  49941. if (c.elm._moveCb) {
  49942. c.elm._moveCb();
  49943. }
  49944. /* istanbul ignore if */
  49945. if (c.elm._enterCb) {
  49946. c.elm._enterCb();
  49947. }
  49948. }
  49949. function recordPosition (c) {
  49950. c.data.newPos = c.elm.getBoundingClientRect();
  49951. }
  49952. function applyTranslation (c) {
  49953. var oldPos = c.data.pos;
  49954. var newPos = c.data.newPos;
  49955. var dx = oldPos.left - newPos.left;
  49956. var dy = oldPos.top - newPos.top;
  49957. if (dx || dy) {
  49958. c.data.moved = true;
  49959. var s = c.elm.style;
  49960. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  49961. s.transitionDuration = '0s';
  49962. }
  49963. }
  49964. var platformComponents = {
  49965. Transition: Transition,
  49966. TransitionGroup: TransitionGroup
  49967. };
  49968. /* */
  49969. // install platform specific utils
  49970. Vue.config.mustUseProp = mustUseProp;
  49971. Vue.config.isReservedTag = isReservedTag;
  49972. Vue.config.isReservedAttr = isReservedAttr;
  49973. Vue.config.getTagNamespace = getTagNamespace;
  49974. Vue.config.isUnknownElement = isUnknownElement;
  49975. // install platform runtime directives & components
  49976. extend(Vue.options.directives, platformDirectives);
  49977. extend(Vue.options.components, platformComponents);
  49978. // install platform patch function
  49979. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  49980. // public mount method
  49981. Vue.prototype.$mount = function (
  49982. el,
  49983. hydrating
  49984. ) {
  49985. el = el && inBrowser ? query(el) : undefined;
  49986. return mountComponent(this, el, hydrating)
  49987. };
  49988. // devtools global hook
  49989. /* istanbul ignore next */
  49990. if (inBrowser) {
  49991. setTimeout(function () {
  49992. if (config.devtools) {
  49993. if (devtools) {
  49994. devtools.emit('init', Vue);
  49995. } else {
  49996. console[console.info ? 'info' : 'log'](
  49997. 'Download the Vue Devtools extension for a better development experience:\n' +
  49998. 'https://github.com/vuejs/vue-devtools'
  49999. );
  50000. }
  50001. }
  50002. if (config.productionTip !== false &&
  50003. typeof console !== 'undefined'
  50004. ) {
  50005. console[console.info ? 'info' : 'log'](
  50006. "You are running Vue in development mode.\n" +
  50007. "Make sure to turn on production mode when deploying for production.\n" +
  50008. "See more tips at https://vuejs.org/guide/deployment.html"
  50009. );
  50010. }
  50011. }, 0);
  50012. }
  50013. /* */
  50014. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  50015. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  50016. var buildRegex = cached(function (delimiters) {
  50017. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  50018. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  50019. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  50020. });
  50021. function parseText (
  50022. text,
  50023. delimiters
  50024. ) {
  50025. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  50026. if (!tagRE.test(text)) {
  50027. return
  50028. }
  50029. var tokens = [];
  50030. var rawTokens = [];
  50031. var lastIndex = tagRE.lastIndex = 0;
  50032. var match, index, tokenValue;
  50033. while ((match = tagRE.exec(text))) {
  50034. index = match.index;
  50035. // push text token
  50036. if (index > lastIndex) {
  50037. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  50038. tokens.push(JSON.stringify(tokenValue));
  50039. }
  50040. // tag token
  50041. var exp = parseFilters(match[1].trim());
  50042. tokens.push(("_s(" + exp + ")"));
  50043. rawTokens.push({ '@binding': exp });
  50044. lastIndex = index + match[0].length;
  50045. }
  50046. if (lastIndex < text.length) {
  50047. rawTokens.push(tokenValue = text.slice(lastIndex));
  50048. tokens.push(JSON.stringify(tokenValue));
  50049. }
  50050. return {
  50051. expression: tokens.join('+'),
  50052. tokens: rawTokens
  50053. }
  50054. }
  50055. /* */
  50056. function transformNode (el, options) {
  50057. var warn = options.warn || baseWarn;
  50058. var staticClass = getAndRemoveAttr(el, 'class');
  50059. if (staticClass) {
  50060. var res = parseText(staticClass, options.delimiters);
  50061. if (res) {
  50062. warn(
  50063. "class=\"" + staticClass + "\": " +
  50064. 'Interpolation inside attributes has been removed. ' +
  50065. 'Use v-bind or the colon shorthand instead. For example, ' +
  50066. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  50067. el.rawAttrsMap['class']
  50068. );
  50069. }
  50070. }
  50071. if (staticClass) {
  50072. el.staticClass = JSON.stringify(staticClass);
  50073. }
  50074. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  50075. if (classBinding) {
  50076. el.classBinding = classBinding;
  50077. }
  50078. }
  50079. function genData (el) {
  50080. var data = '';
  50081. if (el.staticClass) {
  50082. data += "staticClass:" + (el.staticClass) + ",";
  50083. }
  50084. if (el.classBinding) {
  50085. data += "class:" + (el.classBinding) + ",";
  50086. }
  50087. return data
  50088. }
  50089. var klass$1 = {
  50090. staticKeys: ['staticClass'],
  50091. transformNode: transformNode,
  50092. genData: genData
  50093. };
  50094. /* */
  50095. function transformNode$1 (el, options) {
  50096. var warn = options.warn || baseWarn;
  50097. var staticStyle = getAndRemoveAttr(el, 'style');
  50098. if (staticStyle) {
  50099. /* istanbul ignore if */
  50100. {
  50101. var res = parseText(staticStyle, options.delimiters);
  50102. if (res) {
  50103. warn(
  50104. "style=\"" + staticStyle + "\": " +
  50105. 'Interpolation inside attributes has been removed. ' +
  50106. 'Use v-bind or the colon shorthand instead. For example, ' +
  50107. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  50108. el.rawAttrsMap['style']
  50109. );
  50110. }
  50111. }
  50112. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  50113. }
  50114. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  50115. if (styleBinding) {
  50116. el.styleBinding = styleBinding;
  50117. }
  50118. }
  50119. function genData$1 (el) {
  50120. var data = '';
  50121. if (el.staticStyle) {
  50122. data += "staticStyle:" + (el.staticStyle) + ",";
  50123. }
  50124. if (el.styleBinding) {
  50125. data += "style:(" + (el.styleBinding) + "),";
  50126. }
  50127. return data
  50128. }
  50129. var style$1 = {
  50130. staticKeys: ['staticStyle'],
  50131. transformNode: transformNode$1,
  50132. genData: genData$1
  50133. };
  50134. /* */
  50135. var decoder;
  50136. var he = {
  50137. decode: function decode (html) {
  50138. decoder = decoder || document.createElement('div');
  50139. decoder.innerHTML = html;
  50140. return decoder.textContent
  50141. }
  50142. };
  50143. /* */
  50144. var isUnaryTag = makeMap(
  50145. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50146. 'link,meta,param,source,track,wbr'
  50147. );
  50148. // Elements that you can, intentionally, leave open
  50149. // (and which close themselves)
  50150. var canBeLeftOpenTag = makeMap(
  50151. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50152. );
  50153. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50154. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50155. var isNonPhrasingTag = makeMap(
  50156. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50157. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50158. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50159. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50160. 'title,tr,track'
  50161. );
  50162. /**
  50163. * Not type-checking this file because it's mostly vendor code.
  50164. */
  50165. // Regular Expressions for parsing tags and attributes
  50166. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50167. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50168. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50169. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50170. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50171. var startTagClose = /^\s*(\/?)>/;
  50172. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50173. var doctype = /^<!DOCTYPE [^>]+>/i;
  50174. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50175. var comment = /^<!\--/;
  50176. var conditionalComment = /^<!\[/;
  50177. // Special Elements (can contain anything)
  50178. var isPlainTextElement = makeMap('script,style,textarea', true);
  50179. var reCache = {};
  50180. var decodingMap = {
  50181. '&lt;': '<',
  50182. '&gt;': '>',
  50183. '&quot;': '"',
  50184. '&amp;': '&',
  50185. '&#10;': '\n',
  50186. '&#9;': '\t',
  50187. '&#39;': "'"
  50188. };
  50189. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50190. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50191. // #5992
  50192. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50193. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50194. function decodeAttr (value, shouldDecodeNewlines) {
  50195. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50196. return value.replace(re, function (match) { return decodingMap[match]; })
  50197. }
  50198. function parseHTML (html, options) {
  50199. var stack = [];
  50200. var expectHTML = options.expectHTML;
  50201. var isUnaryTag$$1 = options.isUnaryTag || no;
  50202. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50203. var index = 0;
  50204. var last, lastTag;
  50205. while (html) {
  50206. last = html;
  50207. // Make sure we're not in a plaintext content element like script/style
  50208. if (!lastTag || !isPlainTextElement(lastTag)) {
  50209. var textEnd = html.indexOf('<');
  50210. if (textEnd === 0) {
  50211. // Comment:
  50212. if (comment.test(html)) {
  50213. var commentEnd = html.indexOf('-->');
  50214. if (commentEnd >= 0) {
  50215. if (options.shouldKeepComment) {
  50216. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50217. }
  50218. advance(commentEnd + 3);
  50219. continue
  50220. }
  50221. }
  50222. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50223. if (conditionalComment.test(html)) {
  50224. var conditionalEnd = html.indexOf(']>');
  50225. if (conditionalEnd >= 0) {
  50226. advance(conditionalEnd + 2);
  50227. continue
  50228. }
  50229. }
  50230. // Doctype:
  50231. var doctypeMatch = html.match(doctype);
  50232. if (doctypeMatch) {
  50233. advance(doctypeMatch[0].length);
  50234. continue
  50235. }
  50236. // End tag:
  50237. var endTagMatch = html.match(endTag);
  50238. if (endTagMatch) {
  50239. var curIndex = index;
  50240. advance(endTagMatch[0].length);
  50241. parseEndTag(endTagMatch[1], curIndex, index);
  50242. continue
  50243. }
  50244. // Start tag:
  50245. var startTagMatch = parseStartTag();
  50246. if (startTagMatch) {
  50247. handleStartTag(startTagMatch);
  50248. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50249. advance(1);
  50250. }
  50251. continue
  50252. }
  50253. }
  50254. var text = (void 0), rest = (void 0), next = (void 0);
  50255. if (textEnd >= 0) {
  50256. rest = html.slice(textEnd);
  50257. while (
  50258. !endTag.test(rest) &&
  50259. !startTagOpen.test(rest) &&
  50260. !comment.test(rest) &&
  50261. !conditionalComment.test(rest)
  50262. ) {
  50263. // < in plain text, be forgiving and treat it as text
  50264. next = rest.indexOf('<', 1);
  50265. if (next < 0) { break }
  50266. textEnd += next;
  50267. rest = html.slice(textEnd);
  50268. }
  50269. text = html.substring(0, textEnd);
  50270. }
  50271. if (textEnd < 0) {
  50272. text = html;
  50273. }
  50274. if (text) {
  50275. advance(text.length);
  50276. }
  50277. if (options.chars && text) {
  50278. options.chars(text, index - text.length, index);
  50279. }
  50280. } else {
  50281. var endTagLength = 0;
  50282. var stackedTag = lastTag.toLowerCase();
  50283. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50284. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50285. endTagLength = endTag.length;
  50286. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50287. text = text
  50288. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50289. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50290. }
  50291. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50292. text = text.slice(1);
  50293. }
  50294. if (options.chars) {
  50295. options.chars(text);
  50296. }
  50297. return ''
  50298. });
  50299. index += html.length - rest$1.length;
  50300. html = rest$1;
  50301. parseEndTag(stackedTag, index - endTagLength, index);
  50302. }
  50303. if (html === last) {
  50304. options.chars && options.chars(html);
  50305. if (!stack.length && options.warn) {
  50306. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50307. }
  50308. break
  50309. }
  50310. }
  50311. // Clean up any remaining tags
  50312. parseEndTag();
  50313. function advance (n) {
  50314. index += n;
  50315. html = html.substring(n);
  50316. }
  50317. function parseStartTag () {
  50318. var start = html.match(startTagOpen);
  50319. if (start) {
  50320. var match = {
  50321. tagName: start[1],
  50322. attrs: [],
  50323. start: index
  50324. };
  50325. advance(start[0].length);
  50326. var end, attr;
  50327. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50328. attr.start = index;
  50329. advance(attr[0].length);
  50330. attr.end = index;
  50331. match.attrs.push(attr);
  50332. }
  50333. if (end) {
  50334. match.unarySlash = end[1];
  50335. advance(end[0].length);
  50336. match.end = index;
  50337. return match
  50338. }
  50339. }
  50340. }
  50341. function handleStartTag (match) {
  50342. var tagName = match.tagName;
  50343. var unarySlash = match.unarySlash;
  50344. if (expectHTML) {
  50345. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50346. parseEndTag(lastTag);
  50347. }
  50348. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50349. parseEndTag(tagName);
  50350. }
  50351. }
  50352. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50353. var l = match.attrs.length;
  50354. var attrs = new Array(l);
  50355. for (var i = 0; i < l; i++) {
  50356. var args = match.attrs[i];
  50357. var value = args[3] || args[4] || args[5] || '';
  50358. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50359. ? options.shouldDecodeNewlinesForHref
  50360. : options.shouldDecodeNewlines;
  50361. attrs[i] = {
  50362. name: args[1],
  50363. value: decodeAttr(value, shouldDecodeNewlines)
  50364. };
  50365. if (options.outputSourceRange) {
  50366. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50367. attrs[i].end = args.end;
  50368. }
  50369. }
  50370. if (!unary) {
  50371. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50372. lastTag = tagName;
  50373. }
  50374. if (options.start) {
  50375. options.start(tagName, attrs, unary, match.start, match.end);
  50376. }
  50377. }
  50378. function parseEndTag (tagName, start, end) {
  50379. var pos, lowerCasedTagName;
  50380. if (start == null) { start = index; }
  50381. if (end == null) { end = index; }
  50382. // Find the closest opened tag of the same type
  50383. if (tagName) {
  50384. lowerCasedTagName = tagName.toLowerCase();
  50385. for (pos = stack.length - 1; pos >= 0; pos--) {
  50386. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50387. break
  50388. }
  50389. }
  50390. } else {
  50391. // If no tag name is provided, clean shop
  50392. pos = 0;
  50393. }
  50394. if (pos >= 0) {
  50395. // Close all the open elements, up the stack
  50396. for (var i = stack.length - 1; i >= pos; i--) {
  50397. if (i > pos || !tagName &&
  50398. options.warn
  50399. ) {
  50400. options.warn(
  50401. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50402. { start: stack[i].start, end: stack[i].end }
  50403. );
  50404. }
  50405. if (options.end) {
  50406. options.end(stack[i].tag, start, end);
  50407. }
  50408. }
  50409. // Remove the open elements from the stack
  50410. stack.length = pos;
  50411. lastTag = pos && stack[pos - 1].tag;
  50412. } else if (lowerCasedTagName === 'br') {
  50413. if (options.start) {
  50414. options.start(tagName, [], true, start, end);
  50415. }
  50416. } else if (lowerCasedTagName === 'p') {
  50417. if (options.start) {
  50418. options.start(tagName, [], false, start, end);
  50419. }
  50420. if (options.end) {
  50421. options.end(tagName, start, end);
  50422. }
  50423. }
  50424. }
  50425. }
  50426. /* */
  50427. var onRE = /^@|^v-on:/;
  50428. var dirRE = /^v-|^@|^:|^#/;
  50429. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50430. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50431. var stripParensRE = /^\(|\)$/g;
  50432. var dynamicArgRE = /^\[.*\]$/;
  50433. var argRE = /:(.*)$/;
  50434. var bindRE = /^:|^\.|^v-bind:/;
  50435. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50436. var slotRE = /^v-slot(:|$)|^#/;
  50437. var lineBreakRE = /[\r\n]/;
  50438. var whitespaceRE$1 = /\s+/g;
  50439. var invalidAttributeRE = /[\s"'<>\/=]/;
  50440. var decodeHTMLCached = cached(he.decode);
  50441. var emptySlotScopeToken = "_empty_";
  50442. // configurable state
  50443. var warn$2;
  50444. var delimiters;
  50445. var transforms;
  50446. var preTransforms;
  50447. var postTransforms;
  50448. var platformIsPreTag;
  50449. var platformMustUseProp;
  50450. var platformGetTagNamespace;
  50451. var maybeComponent;
  50452. function createASTElement (
  50453. tag,
  50454. attrs,
  50455. parent
  50456. ) {
  50457. return {
  50458. type: 1,
  50459. tag: tag,
  50460. attrsList: attrs,
  50461. attrsMap: makeAttrsMap(attrs),
  50462. rawAttrsMap: {},
  50463. parent: parent,
  50464. children: []
  50465. }
  50466. }
  50467. /**
  50468. * Convert HTML string to AST.
  50469. */
  50470. function parse (
  50471. template,
  50472. options
  50473. ) {
  50474. warn$2 = options.warn || baseWarn;
  50475. platformIsPreTag = options.isPreTag || no;
  50476. platformMustUseProp = options.mustUseProp || no;
  50477. platformGetTagNamespace = options.getTagNamespace || no;
  50478. var isReservedTag = options.isReservedTag || no;
  50479. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50480. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50481. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50482. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50483. delimiters = options.delimiters;
  50484. var stack = [];
  50485. var preserveWhitespace = options.preserveWhitespace !== false;
  50486. var whitespaceOption = options.whitespace;
  50487. var root;
  50488. var currentParent;
  50489. var inVPre = false;
  50490. var inPre = false;
  50491. var warned = false;
  50492. function warnOnce (msg, range) {
  50493. if (!warned) {
  50494. warned = true;
  50495. warn$2(msg, range);
  50496. }
  50497. }
  50498. function closeElement (element) {
  50499. trimEndingWhitespace(element);
  50500. if (!inVPre && !element.processed) {
  50501. element = processElement(element, options);
  50502. }
  50503. // tree management
  50504. if (!stack.length && element !== root) {
  50505. // allow root elements with v-if, v-else-if and v-else
  50506. if (root.if && (element.elseif || element.else)) {
  50507. {
  50508. checkRootConstraints(element);
  50509. }
  50510. addIfCondition(root, {
  50511. exp: element.elseif,
  50512. block: element
  50513. });
  50514. } else {
  50515. warnOnce(
  50516. "Component template should contain exactly one root element. " +
  50517. "If you are using v-if on multiple elements, " +
  50518. "use v-else-if to chain them instead.",
  50519. { start: element.start }
  50520. );
  50521. }
  50522. }
  50523. if (currentParent && !element.forbidden) {
  50524. if (element.elseif || element.else) {
  50525. processIfConditions(element, currentParent);
  50526. } else {
  50527. if (element.slotScope) {
  50528. // scoped slot
  50529. // keep it in the children list so that v-else(-if) conditions can
  50530. // find it as the prev node.
  50531. var name = element.slotTarget || '"default"'
  50532. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50533. }
  50534. currentParent.children.push(element);
  50535. element.parent = currentParent;
  50536. }
  50537. }
  50538. // final children cleanup
  50539. // filter out scoped slots
  50540. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50541. // remove trailing whitespace node again
  50542. trimEndingWhitespace(element);
  50543. // check pre state
  50544. if (element.pre) {
  50545. inVPre = false;
  50546. }
  50547. if (platformIsPreTag(element.tag)) {
  50548. inPre = false;
  50549. }
  50550. // apply post-transforms
  50551. for (var i = 0; i < postTransforms.length; i++) {
  50552. postTransforms[i](element, options);
  50553. }
  50554. }
  50555. function trimEndingWhitespace (el) {
  50556. // remove trailing whitespace node
  50557. if (!inPre) {
  50558. var lastNode;
  50559. while (
  50560. (lastNode = el.children[el.children.length - 1]) &&
  50561. lastNode.type === 3 &&
  50562. lastNode.text === ' '
  50563. ) {
  50564. el.children.pop();
  50565. }
  50566. }
  50567. }
  50568. function checkRootConstraints (el) {
  50569. if (el.tag === 'slot' || el.tag === 'template') {
  50570. warnOnce(
  50571. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50572. 'contain multiple nodes.',
  50573. { start: el.start }
  50574. );
  50575. }
  50576. if (el.attrsMap.hasOwnProperty('v-for')) {
  50577. warnOnce(
  50578. 'Cannot use v-for on stateful component root element because ' +
  50579. 'it renders multiple elements.',
  50580. el.rawAttrsMap['v-for']
  50581. );
  50582. }
  50583. }
  50584. parseHTML(template, {
  50585. warn: warn$2,
  50586. expectHTML: options.expectHTML,
  50587. isUnaryTag: options.isUnaryTag,
  50588. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50589. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50590. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50591. shouldKeepComment: options.comments,
  50592. outputSourceRange: options.outputSourceRange,
  50593. start: function start (tag, attrs, unary, start$1, end) {
  50594. // check namespace.
  50595. // inherit parent ns if there is one
  50596. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50597. // handle IE svg bug
  50598. /* istanbul ignore if */
  50599. if (isIE && ns === 'svg') {
  50600. attrs = guardIESVGBug(attrs);
  50601. }
  50602. var element = createASTElement(tag, attrs, currentParent);
  50603. if (ns) {
  50604. element.ns = ns;
  50605. }
  50606. {
  50607. if (options.outputSourceRange) {
  50608. element.start = start$1;
  50609. element.end = end;
  50610. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50611. cumulated[attr.name] = attr;
  50612. return cumulated
  50613. }, {});
  50614. }
  50615. attrs.forEach(function (attr) {
  50616. if (invalidAttributeRE.test(attr.name)) {
  50617. warn$2(
  50618. "Invalid dynamic argument expression: attribute names cannot contain " +
  50619. "spaces, quotes, <, >, / or =.",
  50620. {
  50621. start: attr.start + attr.name.indexOf("["),
  50622. end: attr.start + attr.name.length
  50623. }
  50624. );
  50625. }
  50626. });
  50627. }
  50628. if (isForbiddenTag(element) && !isServerRendering()) {
  50629. element.forbidden = true;
  50630. warn$2(
  50631. 'Templates should only be responsible for mapping the state to the ' +
  50632. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50633. "<" + tag + ">" + ', as they will not be parsed.',
  50634. { start: element.start }
  50635. );
  50636. }
  50637. // apply pre-transforms
  50638. for (var i = 0; i < preTransforms.length; i++) {
  50639. element = preTransforms[i](element, options) || element;
  50640. }
  50641. if (!inVPre) {
  50642. processPre(element);
  50643. if (element.pre) {
  50644. inVPre = true;
  50645. }
  50646. }
  50647. if (platformIsPreTag(element.tag)) {
  50648. inPre = true;
  50649. }
  50650. if (inVPre) {
  50651. processRawAttrs(element);
  50652. } else if (!element.processed) {
  50653. // structural directives
  50654. processFor(element);
  50655. processIf(element);
  50656. processOnce(element);
  50657. }
  50658. if (!root) {
  50659. root = element;
  50660. {
  50661. checkRootConstraints(root);
  50662. }
  50663. }
  50664. if (!unary) {
  50665. currentParent = element;
  50666. stack.push(element);
  50667. } else {
  50668. closeElement(element);
  50669. }
  50670. },
  50671. end: function end (tag, start, end$1) {
  50672. var element = stack[stack.length - 1];
  50673. // pop stack
  50674. stack.length -= 1;
  50675. currentParent = stack[stack.length - 1];
  50676. if (options.outputSourceRange) {
  50677. element.end = end$1;
  50678. }
  50679. closeElement(element);
  50680. },
  50681. chars: function chars (text, start, end) {
  50682. if (!currentParent) {
  50683. {
  50684. if (text === template) {
  50685. warnOnce(
  50686. 'Component template requires a root element, rather than just text.',
  50687. { start: start }
  50688. );
  50689. } else if ((text = text.trim())) {
  50690. warnOnce(
  50691. ("text \"" + text + "\" outside root element will be ignored."),
  50692. { start: start }
  50693. );
  50694. }
  50695. }
  50696. return
  50697. }
  50698. // IE textarea placeholder bug
  50699. /* istanbul ignore if */
  50700. if (isIE &&
  50701. currentParent.tag === 'textarea' &&
  50702. currentParent.attrsMap.placeholder === text
  50703. ) {
  50704. return
  50705. }
  50706. var children = currentParent.children;
  50707. if (inPre || text.trim()) {
  50708. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50709. } else if (!children.length) {
  50710. // remove the whitespace-only node right after an opening tag
  50711. text = '';
  50712. } else if (whitespaceOption) {
  50713. if (whitespaceOption === 'condense') {
  50714. // in condense mode, remove the whitespace node if it contains
  50715. // line break, otherwise condense to a single space
  50716. text = lineBreakRE.test(text) ? '' : ' ';
  50717. } else {
  50718. text = ' ';
  50719. }
  50720. } else {
  50721. text = preserveWhitespace ? ' ' : '';
  50722. }
  50723. if (text) {
  50724. if (!inPre && whitespaceOption === 'condense') {
  50725. // condense consecutive whitespaces into single space
  50726. text = text.replace(whitespaceRE$1, ' ');
  50727. }
  50728. var res;
  50729. var child;
  50730. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50731. child = {
  50732. type: 2,
  50733. expression: res.expression,
  50734. tokens: res.tokens,
  50735. text: text
  50736. };
  50737. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50738. child = {
  50739. type: 3,
  50740. text: text
  50741. };
  50742. }
  50743. if (child) {
  50744. if (options.outputSourceRange) {
  50745. child.start = start;
  50746. child.end = end;
  50747. }
  50748. children.push(child);
  50749. }
  50750. }
  50751. },
  50752. comment: function comment (text, start, end) {
  50753. // adding anyting as a sibling to the root node is forbidden
  50754. // comments should still be allowed, but ignored
  50755. if (currentParent) {
  50756. var child = {
  50757. type: 3,
  50758. text: text,
  50759. isComment: true
  50760. };
  50761. if (options.outputSourceRange) {
  50762. child.start = start;
  50763. child.end = end;
  50764. }
  50765. currentParent.children.push(child);
  50766. }
  50767. }
  50768. });
  50769. return root
  50770. }
  50771. function processPre (el) {
  50772. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50773. el.pre = true;
  50774. }
  50775. }
  50776. function processRawAttrs (el) {
  50777. var list = el.attrsList;
  50778. var len = list.length;
  50779. if (len) {
  50780. var attrs = el.attrs = new Array(len);
  50781. for (var i = 0; i < len; i++) {
  50782. attrs[i] = {
  50783. name: list[i].name,
  50784. value: JSON.stringify(list[i].value)
  50785. };
  50786. if (list[i].start != null) {
  50787. attrs[i].start = list[i].start;
  50788. attrs[i].end = list[i].end;
  50789. }
  50790. }
  50791. } else if (!el.pre) {
  50792. // non root node in pre blocks with no attributes
  50793. el.plain = true;
  50794. }
  50795. }
  50796. function processElement (
  50797. element,
  50798. options
  50799. ) {
  50800. processKey(element);
  50801. // determine whether this is a plain element after
  50802. // removing structural attributes
  50803. element.plain = (
  50804. !element.key &&
  50805. !element.scopedSlots &&
  50806. !element.attrsList.length
  50807. );
  50808. processRef(element);
  50809. processSlotContent(element);
  50810. processSlotOutlet(element);
  50811. processComponent(element);
  50812. for (var i = 0; i < transforms.length; i++) {
  50813. element = transforms[i](element, options) || element;
  50814. }
  50815. processAttrs(element);
  50816. return element
  50817. }
  50818. function processKey (el) {
  50819. var exp = getBindingAttr(el, 'key');
  50820. if (exp) {
  50821. {
  50822. if (el.tag === 'template') {
  50823. warn$2(
  50824. "<template> cannot be keyed. Place the key on real elements instead.",
  50825. getRawBindingAttr(el, 'key')
  50826. );
  50827. }
  50828. if (el.for) {
  50829. var iterator = el.iterator2 || el.iterator1;
  50830. var parent = el.parent;
  50831. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50832. warn$2(
  50833. "Do not use v-for index as key on <transition-group> children, " +
  50834. "this is the same as not using keys.",
  50835. getRawBindingAttr(el, 'key'),
  50836. true /* tip */
  50837. );
  50838. }
  50839. }
  50840. }
  50841. el.key = exp;
  50842. }
  50843. }
  50844. function processRef (el) {
  50845. var ref = getBindingAttr(el, 'ref');
  50846. if (ref) {
  50847. el.ref = ref;
  50848. el.refInFor = checkInFor(el);
  50849. }
  50850. }
  50851. function processFor (el) {
  50852. var exp;
  50853. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50854. var res = parseFor(exp);
  50855. if (res) {
  50856. extend(el, res);
  50857. } else {
  50858. warn$2(
  50859. ("Invalid v-for expression: " + exp),
  50860. el.rawAttrsMap['v-for']
  50861. );
  50862. }
  50863. }
  50864. }
  50865. function parseFor (exp) {
  50866. var inMatch = exp.match(forAliasRE);
  50867. if (!inMatch) { return }
  50868. var res = {};
  50869. res.for = inMatch[2].trim();
  50870. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50871. var iteratorMatch = alias.match(forIteratorRE);
  50872. if (iteratorMatch) {
  50873. res.alias = alias.replace(forIteratorRE, '').trim();
  50874. res.iterator1 = iteratorMatch[1].trim();
  50875. if (iteratorMatch[2]) {
  50876. res.iterator2 = iteratorMatch[2].trim();
  50877. }
  50878. } else {
  50879. res.alias = alias;
  50880. }
  50881. return res
  50882. }
  50883. function processIf (el) {
  50884. var exp = getAndRemoveAttr(el, 'v-if');
  50885. if (exp) {
  50886. el.if = exp;
  50887. addIfCondition(el, {
  50888. exp: exp,
  50889. block: el
  50890. });
  50891. } else {
  50892. if (getAndRemoveAttr(el, 'v-else') != null) {
  50893. el.else = true;
  50894. }
  50895. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50896. if (elseif) {
  50897. el.elseif = elseif;
  50898. }
  50899. }
  50900. }
  50901. function processIfConditions (el, parent) {
  50902. var prev = findPrevElement(parent.children);
  50903. if (prev && prev.if) {
  50904. addIfCondition(prev, {
  50905. exp: el.elseif,
  50906. block: el
  50907. });
  50908. } else {
  50909. warn$2(
  50910. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  50911. "used on element <" + (el.tag) + "> without corresponding v-if.",
  50912. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  50913. );
  50914. }
  50915. }
  50916. function findPrevElement (children) {
  50917. var i = children.length;
  50918. while (i--) {
  50919. if (children[i].type === 1) {
  50920. return children[i]
  50921. } else {
  50922. if (children[i].text !== ' ') {
  50923. warn$2(
  50924. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  50925. "will be ignored.",
  50926. children[i]
  50927. );
  50928. }
  50929. children.pop();
  50930. }
  50931. }
  50932. }
  50933. function addIfCondition (el, condition) {
  50934. if (!el.ifConditions) {
  50935. el.ifConditions = [];
  50936. }
  50937. el.ifConditions.push(condition);
  50938. }
  50939. function processOnce (el) {
  50940. var once$$1 = getAndRemoveAttr(el, 'v-once');
  50941. if (once$$1 != null) {
  50942. el.once = true;
  50943. }
  50944. }
  50945. // handle content being passed to a component as slot,
  50946. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  50947. function processSlotContent (el) {
  50948. var slotScope;
  50949. if (el.tag === 'template') {
  50950. slotScope = getAndRemoveAttr(el, 'scope');
  50951. /* istanbul ignore if */
  50952. if (slotScope) {
  50953. warn$2(
  50954. "the \"scope\" attribute for scoped slots have been deprecated and " +
  50955. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  50956. "can also be used on plain elements in addition to <template> to " +
  50957. "denote scoped slots.",
  50958. el.rawAttrsMap['scope'],
  50959. true
  50960. );
  50961. }
  50962. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  50963. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  50964. /* istanbul ignore if */
  50965. if (el.attrsMap['v-for']) {
  50966. warn$2(
  50967. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  50968. "(v-for takes higher priority). Use a wrapper <template> for the " +
  50969. "scoped slot to make it clearer.",
  50970. el.rawAttrsMap['slot-scope'],
  50971. true
  50972. );
  50973. }
  50974. el.slotScope = slotScope;
  50975. }
  50976. // slot="xxx"
  50977. var slotTarget = getBindingAttr(el, 'slot');
  50978. if (slotTarget) {
  50979. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  50980. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  50981. // preserve slot as an attribute for native shadow DOM compat
  50982. // only for non-scoped slots.
  50983. if (el.tag !== 'template' && !el.slotScope) {
  50984. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  50985. }
  50986. }
  50987. // 2.6 v-slot syntax
  50988. {
  50989. if (el.tag === 'template') {
  50990. // v-slot on <template>
  50991. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  50992. if (slotBinding) {
  50993. {
  50994. if (el.slotTarget || el.slotScope) {
  50995. warn$2(
  50996. "Unexpected mixed usage of different slot syntaxes.",
  50997. el
  50998. );
  50999. }
  51000. if (el.parent && !maybeComponent(el.parent)) {
  51001. warn$2(
  51002. "<template v-slot> can only appear at the root level inside " +
  51003. "the receiving component",
  51004. el
  51005. );
  51006. }
  51007. }
  51008. var ref = getSlotName(slotBinding);
  51009. var name = ref.name;
  51010. var dynamic = ref.dynamic;
  51011. el.slotTarget = name;
  51012. el.slotTargetDynamic = dynamic;
  51013. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  51014. }
  51015. } else {
  51016. // v-slot on component, denotes default slot
  51017. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  51018. if (slotBinding$1) {
  51019. {
  51020. if (!maybeComponent(el)) {
  51021. warn$2(
  51022. "v-slot can only be used on components or <template>.",
  51023. slotBinding$1
  51024. );
  51025. }
  51026. if (el.slotScope || el.slotTarget) {
  51027. warn$2(
  51028. "Unexpected mixed usage of different slot syntaxes.",
  51029. el
  51030. );
  51031. }
  51032. if (el.scopedSlots) {
  51033. warn$2(
  51034. "To avoid scope ambiguity, the default slot should also use " +
  51035. "<template> syntax when there are other named slots.",
  51036. slotBinding$1
  51037. );
  51038. }
  51039. }
  51040. // add the component's children to its default slot
  51041. var slots = el.scopedSlots || (el.scopedSlots = {});
  51042. var ref$1 = getSlotName(slotBinding$1);
  51043. var name$1 = ref$1.name;
  51044. var dynamic$1 = ref$1.dynamic;
  51045. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  51046. slotContainer.slotTarget = name$1;
  51047. slotContainer.slotTargetDynamic = dynamic$1;
  51048. slotContainer.children = el.children.filter(function (c) {
  51049. if (!c.slotScope) {
  51050. c.parent = slotContainer;
  51051. return true
  51052. }
  51053. });
  51054. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  51055. // remove children as they are returned from scopedSlots now
  51056. el.children = [];
  51057. // mark el non-plain so data gets generated
  51058. el.plain = false;
  51059. }
  51060. }
  51061. }
  51062. }
  51063. function getSlotName (binding) {
  51064. var name = binding.name.replace(slotRE, '');
  51065. if (!name) {
  51066. if (binding.name[0] !== '#') {
  51067. name = 'default';
  51068. } else {
  51069. warn$2(
  51070. "v-slot shorthand syntax requires a slot name.",
  51071. binding
  51072. );
  51073. }
  51074. }
  51075. return dynamicArgRE.test(name)
  51076. // dynamic [name]
  51077. ? { name: name.slice(1, -1), dynamic: true }
  51078. // static name
  51079. : { name: ("\"" + name + "\""), dynamic: false }
  51080. }
  51081. // handle <slot/> outlets
  51082. function processSlotOutlet (el) {
  51083. if (el.tag === 'slot') {
  51084. el.slotName = getBindingAttr(el, 'name');
  51085. if (el.key) {
  51086. warn$2(
  51087. "`key` does not work on <slot> because slots are abstract outlets " +
  51088. "and can possibly expand into multiple elements. " +
  51089. "Use the key on a wrapping element instead.",
  51090. getRawBindingAttr(el, 'key')
  51091. );
  51092. }
  51093. }
  51094. }
  51095. function processComponent (el) {
  51096. var binding;
  51097. if ((binding = getBindingAttr(el, 'is'))) {
  51098. el.component = binding;
  51099. }
  51100. if (getAndRemoveAttr(el, 'inline-template') != null) {
  51101. el.inlineTemplate = true;
  51102. }
  51103. }
  51104. function processAttrs (el) {
  51105. var list = el.attrsList;
  51106. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  51107. for (i = 0, l = list.length; i < l; i++) {
  51108. name = rawName = list[i].name;
  51109. value = list[i].value;
  51110. if (dirRE.test(name)) {
  51111. // mark element as dynamic
  51112. el.hasBindings = true;
  51113. // modifiers
  51114. modifiers = parseModifiers(name.replace(dirRE, ''));
  51115. // support .foo shorthand syntax for the .prop modifier
  51116. if (modifiers) {
  51117. name = name.replace(modifierRE, '');
  51118. }
  51119. if (bindRE.test(name)) { // v-bind
  51120. name = name.replace(bindRE, '');
  51121. value = parseFilters(value);
  51122. isDynamic = dynamicArgRE.test(name);
  51123. if (isDynamic) {
  51124. name = name.slice(1, -1);
  51125. }
  51126. if (
  51127. value.trim().length === 0
  51128. ) {
  51129. warn$2(
  51130. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  51131. );
  51132. }
  51133. if (modifiers) {
  51134. if (modifiers.prop && !isDynamic) {
  51135. name = camelize(name);
  51136. if (name === 'innerHtml') { name = 'innerHTML'; }
  51137. }
  51138. if (modifiers.camel && !isDynamic) {
  51139. name = camelize(name);
  51140. }
  51141. if (modifiers.sync) {
  51142. syncGen = genAssignmentCode(value, "$event");
  51143. if (!isDynamic) {
  51144. addHandler(
  51145. el,
  51146. ("update:" + (camelize(name))),
  51147. syncGen,
  51148. null,
  51149. false,
  51150. warn$2,
  51151. list[i]
  51152. );
  51153. if (hyphenate(name) !== camelize(name)) {
  51154. addHandler(
  51155. el,
  51156. ("update:" + (hyphenate(name))),
  51157. syncGen,
  51158. null,
  51159. false,
  51160. warn$2,
  51161. list[i]
  51162. );
  51163. }
  51164. } else {
  51165. // handler w/ dynamic event name
  51166. addHandler(
  51167. el,
  51168. ("\"update:\"+(" + name + ")"),
  51169. syncGen,
  51170. null,
  51171. false,
  51172. warn$2,
  51173. list[i],
  51174. true // dynamic
  51175. );
  51176. }
  51177. }
  51178. }
  51179. if ((modifiers && modifiers.prop) || (
  51180. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51181. )) {
  51182. addProp(el, name, value, list[i], isDynamic);
  51183. } else {
  51184. addAttr(el, name, value, list[i], isDynamic);
  51185. }
  51186. } else if (onRE.test(name)) { // v-on
  51187. name = name.replace(onRE, '');
  51188. isDynamic = dynamicArgRE.test(name);
  51189. if (isDynamic) {
  51190. name = name.slice(1, -1);
  51191. }
  51192. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51193. } else { // normal directives
  51194. name = name.replace(dirRE, '');
  51195. // parse arg
  51196. var argMatch = name.match(argRE);
  51197. var arg = argMatch && argMatch[1];
  51198. isDynamic = false;
  51199. if (arg) {
  51200. name = name.slice(0, -(arg.length + 1));
  51201. if (dynamicArgRE.test(arg)) {
  51202. arg = arg.slice(1, -1);
  51203. isDynamic = true;
  51204. }
  51205. }
  51206. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51207. if (name === 'model') {
  51208. checkForAliasModel(el, value);
  51209. }
  51210. }
  51211. } else {
  51212. // literal attribute
  51213. {
  51214. var res = parseText(value, delimiters);
  51215. if (res) {
  51216. warn$2(
  51217. name + "=\"" + value + "\": " +
  51218. 'Interpolation inside attributes has been removed. ' +
  51219. 'Use v-bind or the colon shorthand instead. For example, ' +
  51220. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51221. list[i]
  51222. );
  51223. }
  51224. }
  51225. addAttr(el, name, JSON.stringify(value), list[i]);
  51226. // #6887 firefox doesn't update muted state if set via attribute
  51227. // even immediately after element creation
  51228. if (!el.component &&
  51229. name === 'muted' &&
  51230. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51231. addProp(el, name, 'true', list[i]);
  51232. }
  51233. }
  51234. }
  51235. }
  51236. function checkInFor (el) {
  51237. var parent = el;
  51238. while (parent) {
  51239. if (parent.for !== undefined) {
  51240. return true
  51241. }
  51242. parent = parent.parent;
  51243. }
  51244. return false
  51245. }
  51246. function parseModifiers (name) {
  51247. var match = name.match(modifierRE);
  51248. if (match) {
  51249. var ret = {};
  51250. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51251. return ret
  51252. }
  51253. }
  51254. function makeAttrsMap (attrs) {
  51255. var map = {};
  51256. for (var i = 0, l = attrs.length; i < l; i++) {
  51257. if (
  51258. map[attrs[i].name] && !isIE && !isEdge
  51259. ) {
  51260. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51261. }
  51262. map[attrs[i].name] = attrs[i].value;
  51263. }
  51264. return map
  51265. }
  51266. // for script (e.g. type="x/template") or style, do not decode content
  51267. function isTextTag (el) {
  51268. return el.tag === 'script' || el.tag === 'style'
  51269. }
  51270. function isForbiddenTag (el) {
  51271. return (
  51272. el.tag === 'style' ||
  51273. (el.tag === 'script' && (
  51274. !el.attrsMap.type ||
  51275. el.attrsMap.type === 'text/javascript'
  51276. ))
  51277. )
  51278. }
  51279. var ieNSBug = /^xmlns:NS\d+/;
  51280. var ieNSPrefix = /^NS\d+:/;
  51281. /* istanbul ignore next */
  51282. function guardIESVGBug (attrs) {
  51283. var res = [];
  51284. for (var i = 0; i < attrs.length; i++) {
  51285. var attr = attrs[i];
  51286. if (!ieNSBug.test(attr.name)) {
  51287. attr.name = attr.name.replace(ieNSPrefix, '');
  51288. res.push(attr);
  51289. }
  51290. }
  51291. return res
  51292. }
  51293. function checkForAliasModel (el, value) {
  51294. var _el = el;
  51295. while (_el) {
  51296. if (_el.for && _el.alias === value) {
  51297. warn$2(
  51298. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51299. "You are binding v-model directly to a v-for iteration alias. " +
  51300. "This will not be able to modify the v-for source array because " +
  51301. "writing to the alias is like modifying a function local variable. " +
  51302. "Consider using an array of objects and use v-model on an object property instead.",
  51303. el.rawAttrsMap['v-model']
  51304. );
  51305. }
  51306. _el = _el.parent;
  51307. }
  51308. }
  51309. /* */
  51310. function preTransformNode (el, options) {
  51311. if (el.tag === 'input') {
  51312. var map = el.attrsMap;
  51313. if (!map['v-model']) {
  51314. return
  51315. }
  51316. var typeBinding;
  51317. if (map[':type'] || map['v-bind:type']) {
  51318. typeBinding = getBindingAttr(el, 'type');
  51319. }
  51320. if (!map.type && !typeBinding && map['v-bind']) {
  51321. typeBinding = "(" + (map['v-bind']) + ").type";
  51322. }
  51323. if (typeBinding) {
  51324. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51325. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51326. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51327. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51328. // 1. checkbox
  51329. var branch0 = cloneASTElement(el);
  51330. // process for on the main node
  51331. processFor(branch0);
  51332. addRawAttr(branch0, 'type', 'checkbox');
  51333. processElement(branch0, options);
  51334. branch0.processed = true; // prevent it from double-processed
  51335. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51336. addIfCondition(branch0, {
  51337. exp: branch0.if,
  51338. block: branch0
  51339. });
  51340. // 2. add radio else-if condition
  51341. var branch1 = cloneASTElement(el);
  51342. getAndRemoveAttr(branch1, 'v-for', true);
  51343. addRawAttr(branch1, 'type', 'radio');
  51344. processElement(branch1, options);
  51345. addIfCondition(branch0, {
  51346. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51347. block: branch1
  51348. });
  51349. // 3. other
  51350. var branch2 = cloneASTElement(el);
  51351. getAndRemoveAttr(branch2, 'v-for', true);
  51352. addRawAttr(branch2, ':type', typeBinding);
  51353. processElement(branch2, options);
  51354. addIfCondition(branch0, {
  51355. exp: ifCondition,
  51356. block: branch2
  51357. });
  51358. if (hasElse) {
  51359. branch0.else = true;
  51360. } else if (elseIfCondition) {
  51361. branch0.elseif = elseIfCondition;
  51362. }
  51363. return branch0
  51364. }
  51365. }
  51366. }
  51367. function cloneASTElement (el) {
  51368. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51369. }
  51370. var model$1 = {
  51371. preTransformNode: preTransformNode
  51372. };
  51373. var modules$1 = [
  51374. klass$1,
  51375. style$1,
  51376. model$1
  51377. ];
  51378. /* */
  51379. function text (el, dir) {
  51380. if (dir.value) {
  51381. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51382. }
  51383. }
  51384. /* */
  51385. function html (el, dir) {
  51386. if (dir.value) {
  51387. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51388. }
  51389. }
  51390. var directives$1 = {
  51391. model: model,
  51392. text: text,
  51393. html: html
  51394. };
  51395. /* */
  51396. var baseOptions = {
  51397. expectHTML: true,
  51398. modules: modules$1,
  51399. directives: directives$1,
  51400. isPreTag: isPreTag,
  51401. isUnaryTag: isUnaryTag,
  51402. mustUseProp: mustUseProp,
  51403. canBeLeftOpenTag: canBeLeftOpenTag,
  51404. isReservedTag: isReservedTag,
  51405. getTagNamespace: getTagNamespace,
  51406. staticKeys: genStaticKeys(modules$1)
  51407. };
  51408. /* */
  51409. var isStaticKey;
  51410. var isPlatformReservedTag;
  51411. var genStaticKeysCached = cached(genStaticKeys$1);
  51412. /**
  51413. * Goal of the optimizer: walk the generated template AST tree
  51414. * and detect sub-trees that are purely static, i.e. parts of
  51415. * the DOM that never needs to change.
  51416. *
  51417. * Once we detect these sub-trees, we can:
  51418. *
  51419. * 1. Hoist them into constants, so that we no longer need to
  51420. * create fresh nodes for them on each re-render;
  51421. * 2. Completely skip them in the patching process.
  51422. */
  51423. function optimize (root, options) {
  51424. if (!root) { return }
  51425. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51426. isPlatformReservedTag = options.isReservedTag || no;
  51427. // first pass: mark all non-static nodes.
  51428. markStatic$1(root);
  51429. // second pass: mark static roots.
  51430. markStaticRoots(root, false);
  51431. }
  51432. function genStaticKeys$1 (keys) {
  51433. return makeMap(
  51434. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51435. (keys ? ',' + keys : '')
  51436. )
  51437. }
  51438. function markStatic$1 (node) {
  51439. node.static = isStatic(node);
  51440. if (node.type === 1) {
  51441. // do not make component slot content static. this avoids
  51442. // 1. components not able to mutate slot nodes
  51443. // 2. static slot content fails for hot-reloading
  51444. if (
  51445. !isPlatformReservedTag(node.tag) &&
  51446. node.tag !== 'slot' &&
  51447. node.attrsMap['inline-template'] == null
  51448. ) {
  51449. return
  51450. }
  51451. for (var i = 0, l = node.children.length; i < l; i++) {
  51452. var child = node.children[i];
  51453. markStatic$1(child);
  51454. if (!child.static) {
  51455. node.static = false;
  51456. }
  51457. }
  51458. if (node.ifConditions) {
  51459. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51460. var block = node.ifConditions[i$1].block;
  51461. markStatic$1(block);
  51462. if (!block.static) {
  51463. node.static = false;
  51464. }
  51465. }
  51466. }
  51467. }
  51468. }
  51469. function markStaticRoots (node, isInFor) {
  51470. if (node.type === 1) {
  51471. if (node.static || node.once) {
  51472. node.staticInFor = isInFor;
  51473. }
  51474. // For a node to qualify as a static root, it should have children that
  51475. // are not just static text. Otherwise the cost of hoisting out will
  51476. // outweigh the benefits and it's better off to just always render it fresh.
  51477. if (node.static && node.children.length && !(
  51478. node.children.length === 1 &&
  51479. node.children[0].type === 3
  51480. )) {
  51481. node.staticRoot = true;
  51482. return
  51483. } else {
  51484. node.staticRoot = false;
  51485. }
  51486. if (node.children) {
  51487. for (var i = 0, l = node.children.length; i < l; i++) {
  51488. markStaticRoots(node.children[i], isInFor || !!node.for);
  51489. }
  51490. }
  51491. if (node.ifConditions) {
  51492. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51493. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51494. }
  51495. }
  51496. }
  51497. }
  51498. function isStatic (node) {
  51499. if (node.type === 2) { // expression
  51500. return false
  51501. }
  51502. if (node.type === 3) { // text
  51503. return true
  51504. }
  51505. return !!(node.pre || (
  51506. !node.hasBindings && // no dynamic bindings
  51507. !node.if && !node.for && // not v-if or v-for or v-else
  51508. !isBuiltInTag(node.tag) && // not a built-in
  51509. isPlatformReservedTag(node.tag) && // not a component
  51510. !isDirectChildOfTemplateFor(node) &&
  51511. Object.keys(node).every(isStaticKey)
  51512. ))
  51513. }
  51514. function isDirectChildOfTemplateFor (node) {
  51515. while (node.parent) {
  51516. node = node.parent;
  51517. if (node.tag !== 'template') {
  51518. return false
  51519. }
  51520. if (node.for) {
  51521. return true
  51522. }
  51523. }
  51524. return false
  51525. }
  51526. /* */
  51527. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51528. var fnInvokeRE = /\([^)]*?\);*$/;
  51529. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51530. // KeyboardEvent.keyCode aliases
  51531. var keyCodes = {
  51532. esc: 27,
  51533. tab: 9,
  51534. enter: 13,
  51535. space: 32,
  51536. up: 38,
  51537. left: 37,
  51538. right: 39,
  51539. down: 40,
  51540. 'delete': [8, 46]
  51541. };
  51542. // KeyboardEvent.key aliases
  51543. var keyNames = {
  51544. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51545. esc: ['Esc', 'Escape'],
  51546. tab: 'Tab',
  51547. enter: 'Enter',
  51548. // #9112: IE11 uses `Spacebar` for Space key name.
  51549. space: [' ', 'Spacebar'],
  51550. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51551. up: ['Up', 'ArrowUp'],
  51552. left: ['Left', 'ArrowLeft'],
  51553. right: ['Right', 'ArrowRight'],
  51554. down: ['Down', 'ArrowDown'],
  51555. // #9112: IE11 uses `Del` for Delete key name.
  51556. 'delete': ['Backspace', 'Delete', 'Del']
  51557. };
  51558. // #4868: modifiers that prevent the execution of the listener
  51559. // need to explicitly return null so that we can determine whether to remove
  51560. // the listener for .once
  51561. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51562. var modifierCode = {
  51563. stop: '$event.stopPropagation();',
  51564. prevent: '$event.preventDefault();',
  51565. self: genGuard("$event.target !== $event.currentTarget"),
  51566. ctrl: genGuard("!$event.ctrlKey"),
  51567. shift: genGuard("!$event.shiftKey"),
  51568. alt: genGuard("!$event.altKey"),
  51569. meta: genGuard("!$event.metaKey"),
  51570. left: genGuard("'button' in $event && $event.button !== 0"),
  51571. middle: genGuard("'button' in $event && $event.button !== 1"),
  51572. right: genGuard("'button' in $event && $event.button !== 2")
  51573. };
  51574. function genHandlers (
  51575. events,
  51576. isNative
  51577. ) {
  51578. var prefix = isNative ? 'nativeOn:' : 'on:';
  51579. var staticHandlers = "";
  51580. var dynamicHandlers = "";
  51581. for (var name in events) {
  51582. var handlerCode = genHandler(events[name]);
  51583. if (events[name] && events[name].dynamic) {
  51584. dynamicHandlers += name + "," + handlerCode + ",";
  51585. } else {
  51586. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51587. }
  51588. }
  51589. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51590. if (dynamicHandlers) {
  51591. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51592. } else {
  51593. return prefix + staticHandlers
  51594. }
  51595. }
  51596. function genHandler (handler) {
  51597. if (!handler) {
  51598. return 'function(){}'
  51599. }
  51600. if (Array.isArray(handler)) {
  51601. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51602. }
  51603. var isMethodPath = simplePathRE.test(handler.value);
  51604. var isFunctionExpression = fnExpRE.test(handler.value);
  51605. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51606. if (!handler.modifiers) {
  51607. if (isMethodPath || isFunctionExpression) {
  51608. return handler.value
  51609. }
  51610. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51611. } else {
  51612. var code = '';
  51613. var genModifierCode = '';
  51614. var keys = [];
  51615. for (var key in handler.modifiers) {
  51616. if (modifierCode[key]) {
  51617. genModifierCode += modifierCode[key];
  51618. // left/right
  51619. if (keyCodes[key]) {
  51620. keys.push(key);
  51621. }
  51622. } else if (key === 'exact') {
  51623. var modifiers = (handler.modifiers);
  51624. genModifierCode += genGuard(
  51625. ['ctrl', 'shift', 'alt', 'meta']
  51626. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51627. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51628. .join('||')
  51629. );
  51630. } else {
  51631. keys.push(key);
  51632. }
  51633. }
  51634. if (keys.length) {
  51635. code += genKeyFilter(keys);
  51636. }
  51637. // Make sure modifiers like prevent and stop get executed after key filtering
  51638. if (genModifierCode) {
  51639. code += genModifierCode;
  51640. }
  51641. var handlerCode = isMethodPath
  51642. ? ("return " + (handler.value) + "($event)")
  51643. : isFunctionExpression
  51644. ? ("return (" + (handler.value) + ")($event)")
  51645. : isFunctionInvocation
  51646. ? ("return " + (handler.value))
  51647. : handler.value;
  51648. return ("function($event){" + code + handlerCode + "}")
  51649. }
  51650. }
  51651. function genKeyFilter (keys) {
  51652. return (
  51653. // make sure the key filters only apply to KeyboardEvents
  51654. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51655. // key events that do not have keyCode property...
  51656. "if(!$event.type.indexOf('key')&&" +
  51657. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51658. )
  51659. }
  51660. function genFilterCode (key) {
  51661. var keyVal = parseInt(key, 10);
  51662. if (keyVal) {
  51663. return ("$event.keyCode!==" + keyVal)
  51664. }
  51665. var keyCode = keyCodes[key];
  51666. var keyName = keyNames[key];
  51667. return (
  51668. "_k($event.keyCode," +
  51669. (JSON.stringify(key)) + "," +
  51670. (JSON.stringify(keyCode)) + "," +
  51671. "$event.key," +
  51672. "" + (JSON.stringify(keyName)) +
  51673. ")"
  51674. )
  51675. }
  51676. /* */
  51677. function on (el, dir) {
  51678. if (dir.modifiers) {
  51679. warn("v-on without argument does not support modifiers.");
  51680. }
  51681. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51682. }
  51683. /* */
  51684. function bind$1 (el, dir) {
  51685. el.wrapData = function (code) {
  51686. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51687. };
  51688. }
  51689. /* */
  51690. var baseDirectives = {
  51691. on: on,
  51692. bind: bind$1,
  51693. cloak: noop
  51694. };
  51695. /* */
  51696. var CodegenState = function CodegenState (options) {
  51697. this.options = options;
  51698. this.warn = options.warn || baseWarn;
  51699. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51700. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51701. this.directives = extend(extend({}, baseDirectives), options.directives);
  51702. var isReservedTag = options.isReservedTag || no;
  51703. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51704. this.onceId = 0;
  51705. this.staticRenderFns = [];
  51706. this.pre = false;
  51707. };
  51708. function generate (
  51709. ast,
  51710. options
  51711. ) {
  51712. var state = new CodegenState(options);
  51713. var code = ast ? genElement(ast, state) : '_c("div")';
  51714. return {
  51715. render: ("with(this){return " + code + "}"),
  51716. staticRenderFns: state.staticRenderFns
  51717. }
  51718. }
  51719. function genElement (el, state) {
  51720. if (el.parent) {
  51721. el.pre = el.pre || el.parent.pre;
  51722. }
  51723. if (el.staticRoot && !el.staticProcessed) {
  51724. return genStatic(el, state)
  51725. } else if (el.once && !el.onceProcessed) {
  51726. return genOnce(el, state)
  51727. } else if (el.for && !el.forProcessed) {
  51728. return genFor(el, state)
  51729. } else if (el.if && !el.ifProcessed) {
  51730. return genIf(el, state)
  51731. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51732. return genChildren(el, state) || 'void 0'
  51733. } else if (el.tag === 'slot') {
  51734. return genSlot(el, state)
  51735. } else {
  51736. // component or element
  51737. var code;
  51738. if (el.component) {
  51739. code = genComponent(el.component, el, state);
  51740. } else {
  51741. var data;
  51742. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51743. data = genData$2(el, state);
  51744. }
  51745. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51746. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51747. }
  51748. // module transforms
  51749. for (var i = 0; i < state.transforms.length; i++) {
  51750. code = state.transforms[i](el, code);
  51751. }
  51752. return code
  51753. }
  51754. }
  51755. // hoist static sub-trees out
  51756. function genStatic (el, state) {
  51757. el.staticProcessed = true;
  51758. // Some elements (templates) need to behave differently inside of a v-pre
  51759. // node. All pre nodes are static roots, so we can use this as a location to
  51760. // wrap a state change and reset it upon exiting the pre node.
  51761. var originalPreState = state.pre;
  51762. if (el.pre) {
  51763. state.pre = el.pre;
  51764. }
  51765. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51766. state.pre = originalPreState;
  51767. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51768. }
  51769. // v-once
  51770. function genOnce (el, state) {
  51771. el.onceProcessed = true;
  51772. if (el.if && !el.ifProcessed) {
  51773. return genIf(el, state)
  51774. } else if (el.staticInFor) {
  51775. var key = '';
  51776. var parent = el.parent;
  51777. while (parent) {
  51778. if (parent.for) {
  51779. key = parent.key;
  51780. break
  51781. }
  51782. parent = parent.parent;
  51783. }
  51784. if (!key) {
  51785. state.warn(
  51786. "v-once can only be used inside v-for that is keyed. ",
  51787. el.rawAttrsMap['v-once']
  51788. );
  51789. return genElement(el, state)
  51790. }
  51791. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51792. } else {
  51793. return genStatic(el, state)
  51794. }
  51795. }
  51796. function genIf (
  51797. el,
  51798. state,
  51799. altGen,
  51800. altEmpty
  51801. ) {
  51802. el.ifProcessed = true; // avoid recursion
  51803. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51804. }
  51805. function genIfConditions (
  51806. conditions,
  51807. state,
  51808. altGen,
  51809. altEmpty
  51810. ) {
  51811. if (!conditions.length) {
  51812. return altEmpty || '_e()'
  51813. }
  51814. var condition = conditions.shift();
  51815. if (condition.exp) {
  51816. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51817. } else {
  51818. return ("" + (genTernaryExp(condition.block)))
  51819. }
  51820. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51821. function genTernaryExp (el) {
  51822. return altGen
  51823. ? altGen(el, state)
  51824. : el.once
  51825. ? genOnce(el, state)
  51826. : genElement(el, state)
  51827. }
  51828. }
  51829. function genFor (
  51830. el,
  51831. state,
  51832. altGen,
  51833. altHelper
  51834. ) {
  51835. var exp = el.for;
  51836. var alias = el.alias;
  51837. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51838. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51839. if (state.maybeComponent(el) &&
  51840. el.tag !== 'slot' &&
  51841. el.tag !== 'template' &&
  51842. !el.key
  51843. ) {
  51844. state.warn(
  51845. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51846. "v-for should have explicit keys. " +
  51847. "See https://vuejs.org/guide/list.html#key for more info.",
  51848. el.rawAttrsMap['v-for'],
  51849. true /* tip */
  51850. );
  51851. }
  51852. el.forProcessed = true; // avoid recursion
  51853. return (altHelper || '_l') + "((" + exp + ")," +
  51854. "function(" + alias + iterator1 + iterator2 + "){" +
  51855. "return " + ((altGen || genElement)(el, state)) +
  51856. '})'
  51857. }
  51858. function genData$2 (el, state) {
  51859. var data = '{';
  51860. // directives first.
  51861. // directives may mutate the el's other properties before they are generated.
  51862. var dirs = genDirectives(el, state);
  51863. if (dirs) { data += dirs + ','; }
  51864. // key
  51865. if (el.key) {
  51866. data += "key:" + (el.key) + ",";
  51867. }
  51868. // ref
  51869. if (el.ref) {
  51870. data += "ref:" + (el.ref) + ",";
  51871. }
  51872. if (el.refInFor) {
  51873. data += "refInFor:true,";
  51874. }
  51875. // pre
  51876. if (el.pre) {
  51877. data += "pre:true,";
  51878. }
  51879. // record original tag name for components using "is" attribute
  51880. if (el.component) {
  51881. data += "tag:\"" + (el.tag) + "\",";
  51882. }
  51883. // module data generation functions
  51884. for (var i = 0; i < state.dataGenFns.length; i++) {
  51885. data += state.dataGenFns[i](el);
  51886. }
  51887. // attributes
  51888. if (el.attrs) {
  51889. data += "attrs:" + (genProps(el.attrs)) + ",";
  51890. }
  51891. // DOM props
  51892. if (el.props) {
  51893. data += "domProps:" + (genProps(el.props)) + ",";
  51894. }
  51895. // event handlers
  51896. if (el.events) {
  51897. data += (genHandlers(el.events, false)) + ",";
  51898. }
  51899. if (el.nativeEvents) {
  51900. data += (genHandlers(el.nativeEvents, true)) + ",";
  51901. }
  51902. // slot target
  51903. // only for non-scoped slots
  51904. if (el.slotTarget && !el.slotScope) {
  51905. data += "slot:" + (el.slotTarget) + ",";
  51906. }
  51907. // scoped slots
  51908. if (el.scopedSlots) {
  51909. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  51910. }
  51911. // component v-model
  51912. if (el.model) {
  51913. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  51914. }
  51915. // inline-template
  51916. if (el.inlineTemplate) {
  51917. var inlineTemplate = genInlineTemplate(el, state);
  51918. if (inlineTemplate) {
  51919. data += inlineTemplate + ",";
  51920. }
  51921. }
  51922. data = data.replace(/,$/, '') + '}';
  51923. // v-bind dynamic argument wrap
  51924. // v-bind with dynamic arguments must be applied using the same v-bind object
  51925. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  51926. if (el.dynamicAttrs) {
  51927. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  51928. }
  51929. // v-bind data wrap
  51930. if (el.wrapData) {
  51931. data = el.wrapData(data);
  51932. }
  51933. // v-on data wrap
  51934. if (el.wrapListeners) {
  51935. data = el.wrapListeners(data);
  51936. }
  51937. return data
  51938. }
  51939. function genDirectives (el, state) {
  51940. var dirs = el.directives;
  51941. if (!dirs) { return }
  51942. var res = 'directives:[';
  51943. var hasRuntime = false;
  51944. var i, l, dir, needRuntime;
  51945. for (i = 0, l = dirs.length; i < l; i++) {
  51946. dir = dirs[i];
  51947. needRuntime = true;
  51948. var gen = state.directives[dir.name];
  51949. if (gen) {
  51950. // compile-time directive that manipulates AST.
  51951. // returns true if it also needs a runtime counterpart.
  51952. needRuntime = !!gen(el, dir, state.warn);
  51953. }
  51954. if (needRuntime) {
  51955. hasRuntime = true;
  51956. 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))) : '') + "},";
  51957. }
  51958. }
  51959. if (hasRuntime) {
  51960. return res.slice(0, -1) + ']'
  51961. }
  51962. }
  51963. function genInlineTemplate (el, state) {
  51964. var ast = el.children[0];
  51965. if (el.children.length !== 1 || ast.type !== 1) {
  51966. state.warn(
  51967. 'Inline-template components must have exactly one child element.',
  51968. { start: el.start }
  51969. );
  51970. }
  51971. if (ast && ast.type === 1) {
  51972. var inlineRenderFns = generate(ast, state.options);
  51973. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  51974. }
  51975. }
  51976. function genScopedSlots (
  51977. el,
  51978. slots,
  51979. state
  51980. ) {
  51981. // by default scoped slots are considered "stable", this allows child
  51982. // components with only scoped slots to skip forced updates from parent.
  51983. // but in some cases we have to bail-out of this optimization
  51984. // for example if the slot contains dynamic names, has v-if or v-for on them...
  51985. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  51986. var slot = slots[key];
  51987. return (
  51988. slot.slotTargetDynamic ||
  51989. slot.if ||
  51990. slot.for ||
  51991. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  51992. )
  51993. });
  51994. // #9534: if a component with scoped slots is inside a conditional branch,
  51995. // it's possible for the same component to be reused but with different
  51996. // compiled slot content. To avoid that, we generate a unique key based on
  51997. // the generated code of all the slot contents.
  51998. var needsKey = !!el.if;
  51999. // OR when it is inside another scoped slot or v-for (the reactivity may be
  52000. // disconnected due to the intermediate scope variable)
  52001. // #9438, #9506
  52002. // TODO: this can be further optimized by properly analyzing in-scope bindings
  52003. // and skip force updating ones that do not actually use scope variables.
  52004. if (!needsForceUpdate) {
  52005. var parent = el.parent;
  52006. while (parent) {
  52007. if (
  52008. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  52009. parent.for
  52010. ) {
  52011. needsForceUpdate = true;
  52012. break
  52013. }
  52014. if (parent.if) {
  52015. needsKey = true;
  52016. }
  52017. parent = parent.parent;
  52018. }
  52019. }
  52020. var generatedSlots = Object.keys(slots)
  52021. .map(function (key) { return genScopedSlot(slots[key], state); })
  52022. .join(',');
  52023. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  52024. }
  52025. function hash(str) {
  52026. var hash = 5381;
  52027. var i = str.length;
  52028. while(i) {
  52029. hash = (hash * 33) ^ str.charCodeAt(--i);
  52030. }
  52031. return hash >>> 0
  52032. }
  52033. function containsSlotChild (el) {
  52034. if (el.type === 1) {
  52035. if (el.tag === 'slot') {
  52036. return true
  52037. }
  52038. return el.children.some(containsSlotChild)
  52039. }
  52040. return false
  52041. }
  52042. function genScopedSlot (
  52043. el,
  52044. state
  52045. ) {
  52046. var isLegacySyntax = el.attrsMap['slot-scope'];
  52047. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  52048. return genIf(el, state, genScopedSlot, "null")
  52049. }
  52050. if (el.for && !el.forProcessed) {
  52051. return genFor(el, state, genScopedSlot)
  52052. }
  52053. var slotScope = el.slotScope === emptySlotScopeToken
  52054. ? ""
  52055. : String(el.slotScope);
  52056. var fn = "function(" + slotScope + "){" +
  52057. "return " + (el.tag === 'template'
  52058. ? el.if && isLegacySyntax
  52059. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  52060. : genChildren(el, state) || 'undefined'
  52061. : genElement(el, state)) + "}";
  52062. // reverse proxy v-slot without scope on this.$slots
  52063. var reverseProxy = slotScope ? "" : ",proxy:true";
  52064. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  52065. }
  52066. function genChildren (
  52067. el,
  52068. state,
  52069. checkSkip,
  52070. altGenElement,
  52071. altGenNode
  52072. ) {
  52073. var children = el.children;
  52074. if (children.length) {
  52075. var el$1 = children[0];
  52076. // optimize single v-for
  52077. if (children.length === 1 &&
  52078. el$1.for &&
  52079. el$1.tag !== 'template' &&
  52080. el$1.tag !== 'slot'
  52081. ) {
  52082. var normalizationType = checkSkip
  52083. ? state.maybeComponent(el$1) ? ",1" : ",0"
  52084. : "";
  52085. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  52086. }
  52087. var normalizationType$1 = checkSkip
  52088. ? getNormalizationType(children, state.maybeComponent)
  52089. : 0;
  52090. var gen = altGenNode || genNode;
  52091. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  52092. }
  52093. }
  52094. // determine the normalization needed for the children array.
  52095. // 0: no normalization needed
  52096. // 1: simple normalization needed (possible 1-level deep nested array)
  52097. // 2: full normalization needed
  52098. function getNormalizationType (
  52099. children,
  52100. maybeComponent
  52101. ) {
  52102. var res = 0;
  52103. for (var i = 0; i < children.length; i++) {
  52104. var el = children[i];
  52105. if (el.type !== 1) {
  52106. continue
  52107. }
  52108. if (needsNormalization(el) ||
  52109. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  52110. res = 2;
  52111. break
  52112. }
  52113. if (maybeComponent(el) ||
  52114. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  52115. res = 1;
  52116. }
  52117. }
  52118. return res
  52119. }
  52120. function needsNormalization (el) {
  52121. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  52122. }
  52123. function genNode (node, state) {
  52124. if (node.type === 1) {
  52125. return genElement(node, state)
  52126. } else if (node.type === 3 && node.isComment) {
  52127. return genComment(node)
  52128. } else {
  52129. return genText(node)
  52130. }
  52131. }
  52132. function genText (text) {
  52133. return ("_v(" + (text.type === 2
  52134. ? text.expression // no need for () because already wrapped in _s()
  52135. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  52136. }
  52137. function genComment (comment) {
  52138. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52139. }
  52140. function genSlot (el, state) {
  52141. var slotName = el.slotName || '"default"';
  52142. var children = genChildren(el, state);
  52143. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52144. var attrs = el.attrs || el.dynamicAttrs
  52145. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52146. // slot props are camelized
  52147. name: camelize(attr.name),
  52148. value: attr.value,
  52149. dynamic: attr.dynamic
  52150. }); }))
  52151. : null;
  52152. var bind$$1 = el.attrsMap['v-bind'];
  52153. if ((attrs || bind$$1) && !children) {
  52154. res += ",null";
  52155. }
  52156. if (attrs) {
  52157. res += "," + attrs;
  52158. }
  52159. if (bind$$1) {
  52160. res += (attrs ? '' : ',null') + "," + bind$$1;
  52161. }
  52162. return res + ')'
  52163. }
  52164. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52165. function genComponent (
  52166. componentName,
  52167. el,
  52168. state
  52169. ) {
  52170. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52171. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52172. }
  52173. function genProps (props) {
  52174. var staticProps = "";
  52175. var dynamicProps = "";
  52176. for (var i = 0; i < props.length; i++) {
  52177. var prop = props[i];
  52178. var value = transformSpecialNewlines(prop.value);
  52179. if (prop.dynamic) {
  52180. dynamicProps += (prop.name) + "," + value + ",";
  52181. } else {
  52182. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52183. }
  52184. }
  52185. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52186. if (dynamicProps) {
  52187. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52188. } else {
  52189. return staticProps
  52190. }
  52191. }
  52192. // #3895, #4268
  52193. function transformSpecialNewlines (text) {
  52194. return text
  52195. .replace(/\u2028/g, '\\u2028')
  52196. .replace(/\u2029/g, '\\u2029')
  52197. }
  52198. /* */
  52199. // these keywords should not appear inside expressions, but operators like
  52200. // typeof, instanceof and in are allowed
  52201. var prohibitedKeywordRE = new RegExp('\\b' + (
  52202. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52203. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52204. 'extends,finally,continue,debugger,function,arguments'
  52205. ).split(',').join('\\b|\\b') + '\\b');
  52206. // these unary operators should not be used as property/method names
  52207. var unaryOperatorsRE = new RegExp('\\b' + (
  52208. 'delete,typeof,void'
  52209. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52210. // strip strings in expressions
  52211. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52212. // detect problematic expressions in a template
  52213. function detectErrors (ast, warn) {
  52214. if (ast) {
  52215. checkNode(ast, warn);
  52216. }
  52217. }
  52218. function checkNode (node, warn) {
  52219. if (node.type === 1) {
  52220. for (var name in node.attrsMap) {
  52221. if (dirRE.test(name)) {
  52222. var value = node.attrsMap[name];
  52223. if (value) {
  52224. var range = node.rawAttrsMap[name];
  52225. if (name === 'v-for') {
  52226. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52227. } else if (name === 'v-slot' || name[0] === '#') {
  52228. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52229. } else if (onRE.test(name)) {
  52230. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52231. } else {
  52232. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52233. }
  52234. }
  52235. }
  52236. }
  52237. if (node.children) {
  52238. for (var i = 0; i < node.children.length; i++) {
  52239. checkNode(node.children[i], warn);
  52240. }
  52241. }
  52242. } else if (node.type === 2) {
  52243. checkExpression(node.expression, node.text, warn, node);
  52244. }
  52245. }
  52246. function checkEvent (exp, text, warn, range) {
  52247. var stripped = exp.replace(stripStringRE, '');
  52248. var keywordMatch = stripped.match(unaryOperatorsRE);
  52249. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52250. warn(
  52251. "avoid using JavaScript unary operator as property name: " +
  52252. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52253. range
  52254. );
  52255. }
  52256. checkExpression(exp, text, warn, range);
  52257. }
  52258. function checkFor (node, text, warn, range) {
  52259. checkExpression(node.for || '', text, warn, range);
  52260. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52261. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52262. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52263. }
  52264. function checkIdentifier (
  52265. ident,
  52266. type,
  52267. text,
  52268. warn,
  52269. range
  52270. ) {
  52271. if (typeof ident === 'string') {
  52272. try {
  52273. new Function(("var " + ident + "=_"));
  52274. } catch (e) {
  52275. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52276. }
  52277. }
  52278. }
  52279. function checkExpression (exp, text, warn, range) {
  52280. try {
  52281. new Function(("return " + exp));
  52282. } catch (e) {
  52283. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52284. if (keywordMatch) {
  52285. warn(
  52286. "avoid using JavaScript keyword as property name: " +
  52287. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52288. range
  52289. );
  52290. } else {
  52291. warn(
  52292. "invalid expression: " + (e.message) + " in\n\n" +
  52293. " " + exp + "\n\n" +
  52294. " Raw expression: " + (text.trim()) + "\n",
  52295. range
  52296. );
  52297. }
  52298. }
  52299. }
  52300. function checkFunctionParameterExpression (exp, text, warn, range) {
  52301. try {
  52302. new Function(exp, '');
  52303. } catch (e) {
  52304. warn(
  52305. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52306. " " + exp + "\n\n" +
  52307. " Raw expression: " + (text.trim()) + "\n",
  52308. range
  52309. );
  52310. }
  52311. }
  52312. /* */
  52313. var range = 2;
  52314. function generateCodeFrame (
  52315. source,
  52316. start,
  52317. end
  52318. ) {
  52319. if ( start === void 0 ) start = 0;
  52320. if ( end === void 0 ) end = source.length;
  52321. var lines = source.split(/\r?\n/);
  52322. var count = 0;
  52323. var res = [];
  52324. for (var i = 0; i < lines.length; i++) {
  52325. count += lines[i].length + 1;
  52326. if (count >= start) {
  52327. for (var j = i - range; j <= i + range || end > count; j++) {
  52328. if (j < 0 || j >= lines.length) { continue }
  52329. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52330. var lineLength = lines[j].length;
  52331. if (j === i) {
  52332. // push underline
  52333. var pad = start - (count - lineLength) + 1;
  52334. var length = end > count ? lineLength - pad : end - start;
  52335. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52336. } else if (j > i) {
  52337. if (end > count) {
  52338. var length$1 = Math.min(end - count, lineLength);
  52339. res.push(" | " + repeat$1("^", length$1));
  52340. }
  52341. count += lineLength + 1;
  52342. }
  52343. }
  52344. break
  52345. }
  52346. }
  52347. return res.join('\n')
  52348. }
  52349. function repeat$1 (str, n) {
  52350. var result = '';
  52351. if (n > 0) {
  52352. while (true) { // eslint-disable-line
  52353. if (n & 1) { result += str; }
  52354. n >>>= 1;
  52355. if (n <= 0) { break }
  52356. str += str;
  52357. }
  52358. }
  52359. return result
  52360. }
  52361. /* */
  52362. function createFunction (code, errors) {
  52363. try {
  52364. return new Function(code)
  52365. } catch (err) {
  52366. errors.push({ err: err, code: code });
  52367. return noop
  52368. }
  52369. }
  52370. function createCompileToFunctionFn (compile) {
  52371. var cache = Object.create(null);
  52372. return function compileToFunctions (
  52373. template,
  52374. options,
  52375. vm
  52376. ) {
  52377. options = extend({}, options);
  52378. var warn$$1 = options.warn || warn;
  52379. delete options.warn;
  52380. /* istanbul ignore if */
  52381. {
  52382. // detect possible CSP restriction
  52383. try {
  52384. new Function('return 1');
  52385. } catch (e) {
  52386. if (e.toString().match(/unsafe-eval|CSP/)) {
  52387. warn$$1(
  52388. 'It seems you are using the standalone build of Vue.js in an ' +
  52389. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52390. 'The template compiler cannot work in this environment. Consider ' +
  52391. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52392. 'templates into render functions.'
  52393. );
  52394. }
  52395. }
  52396. }
  52397. // check cache
  52398. var key = options.delimiters
  52399. ? String(options.delimiters) + template
  52400. : template;
  52401. if (cache[key]) {
  52402. return cache[key]
  52403. }
  52404. // compile
  52405. var compiled = compile(template, options);
  52406. // check compilation errors/tips
  52407. {
  52408. if (compiled.errors && compiled.errors.length) {
  52409. if (options.outputSourceRange) {
  52410. compiled.errors.forEach(function (e) {
  52411. warn$$1(
  52412. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52413. generateCodeFrame(template, e.start, e.end),
  52414. vm
  52415. );
  52416. });
  52417. } else {
  52418. warn$$1(
  52419. "Error compiling template:\n\n" + template + "\n\n" +
  52420. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52421. vm
  52422. );
  52423. }
  52424. }
  52425. if (compiled.tips && compiled.tips.length) {
  52426. if (options.outputSourceRange) {
  52427. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52428. } else {
  52429. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52430. }
  52431. }
  52432. }
  52433. // turn code into functions
  52434. var res = {};
  52435. var fnGenErrors = [];
  52436. res.render = createFunction(compiled.render, fnGenErrors);
  52437. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52438. return createFunction(code, fnGenErrors)
  52439. });
  52440. // check function generation errors.
  52441. // this should only happen if there is a bug in the compiler itself.
  52442. // mostly for codegen development use
  52443. /* istanbul ignore if */
  52444. {
  52445. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52446. warn$$1(
  52447. "Failed to generate render function:\n\n" +
  52448. fnGenErrors.map(function (ref) {
  52449. var err = ref.err;
  52450. var code = ref.code;
  52451. return ((err.toString()) + " in\n\n" + code + "\n");
  52452. }).join('\n'),
  52453. vm
  52454. );
  52455. }
  52456. }
  52457. return (cache[key] = res)
  52458. }
  52459. }
  52460. /* */
  52461. function createCompilerCreator (baseCompile) {
  52462. return function createCompiler (baseOptions) {
  52463. function compile (
  52464. template,
  52465. options
  52466. ) {
  52467. var finalOptions = Object.create(baseOptions);
  52468. var errors = [];
  52469. var tips = [];
  52470. var warn = function (msg, range, tip) {
  52471. (tip ? tips : errors).push(msg);
  52472. };
  52473. if (options) {
  52474. if (options.outputSourceRange) {
  52475. // $flow-disable-line
  52476. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52477. warn = function (msg, range, tip) {
  52478. var data = { msg: msg };
  52479. if (range) {
  52480. if (range.start != null) {
  52481. data.start = range.start + leadingSpaceLength;
  52482. }
  52483. if (range.end != null) {
  52484. data.end = range.end + leadingSpaceLength;
  52485. }
  52486. }
  52487. (tip ? tips : errors).push(data);
  52488. };
  52489. }
  52490. // merge custom modules
  52491. if (options.modules) {
  52492. finalOptions.modules =
  52493. (baseOptions.modules || []).concat(options.modules);
  52494. }
  52495. // merge custom directives
  52496. if (options.directives) {
  52497. finalOptions.directives = extend(
  52498. Object.create(baseOptions.directives || null),
  52499. options.directives
  52500. );
  52501. }
  52502. // copy other options
  52503. for (var key in options) {
  52504. if (key !== 'modules' && key !== 'directives') {
  52505. finalOptions[key] = options[key];
  52506. }
  52507. }
  52508. }
  52509. finalOptions.warn = warn;
  52510. var compiled = baseCompile(template.trim(), finalOptions);
  52511. {
  52512. detectErrors(compiled.ast, warn);
  52513. }
  52514. compiled.errors = errors;
  52515. compiled.tips = tips;
  52516. return compiled
  52517. }
  52518. return {
  52519. compile: compile,
  52520. compileToFunctions: createCompileToFunctionFn(compile)
  52521. }
  52522. }
  52523. }
  52524. /* */
  52525. // `createCompilerCreator` allows creating compilers that use alternative
  52526. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52527. // Here we just export a default compiler using the default parts.
  52528. var createCompiler = createCompilerCreator(function baseCompile (
  52529. template,
  52530. options
  52531. ) {
  52532. var ast = parse(template.trim(), options);
  52533. if (options.optimize !== false) {
  52534. optimize(ast, options);
  52535. }
  52536. var code = generate(ast, options);
  52537. return {
  52538. ast: ast,
  52539. render: code.render,
  52540. staticRenderFns: code.staticRenderFns
  52541. }
  52542. });
  52543. /* */
  52544. var ref$1 = createCompiler(baseOptions);
  52545. var compile = ref$1.compile;
  52546. var compileToFunctions = ref$1.compileToFunctions;
  52547. /* */
  52548. // check whether current browser encodes a char inside attribute values
  52549. var div;
  52550. function getShouldDecode (href) {
  52551. div = div || document.createElement('div');
  52552. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52553. return div.innerHTML.indexOf('&#10;') > 0
  52554. }
  52555. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52556. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52557. // #6828: chrome encodes content in a[href]
  52558. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52559. /* */
  52560. var idToTemplate = cached(function (id) {
  52561. var el = query(id);
  52562. return el && el.innerHTML
  52563. });
  52564. var mount = Vue.prototype.$mount;
  52565. Vue.prototype.$mount = function (
  52566. el,
  52567. hydrating
  52568. ) {
  52569. el = el && query(el);
  52570. /* istanbul ignore if */
  52571. if (el === document.body || el === document.documentElement) {
  52572. warn(
  52573. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52574. );
  52575. return this
  52576. }
  52577. var options = this.$options;
  52578. // resolve template/el and convert to render function
  52579. if (!options.render) {
  52580. var template = options.template;
  52581. if (template) {
  52582. if (typeof template === 'string') {
  52583. if (template.charAt(0) === '#') {
  52584. template = idToTemplate(template);
  52585. /* istanbul ignore if */
  52586. if (!template) {
  52587. warn(
  52588. ("Template element not found or is empty: " + (options.template)),
  52589. this
  52590. );
  52591. }
  52592. }
  52593. } else if (template.nodeType) {
  52594. template = template.innerHTML;
  52595. } else {
  52596. {
  52597. warn('invalid template option:' + template, this);
  52598. }
  52599. return this
  52600. }
  52601. } else if (el) {
  52602. template = getOuterHTML(el);
  52603. }
  52604. if (template) {
  52605. /* istanbul ignore if */
  52606. if (config.performance && mark) {
  52607. mark('compile');
  52608. }
  52609. var ref = compileToFunctions(template, {
  52610. outputSourceRange: "development" !== 'production',
  52611. shouldDecodeNewlines: shouldDecodeNewlines,
  52612. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52613. delimiters: options.delimiters,
  52614. comments: options.comments
  52615. }, this);
  52616. var render = ref.render;
  52617. var staticRenderFns = ref.staticRenderFns;
  52618. options.render = render;
  52619. options.staticRenderFns = staticRenderFns;
  52620. /* istanbul ignore if */
  52621. if (config.performance && mark) {
  52622. mark('compile end');
  52623. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52624. }
  52625. }
  52626. }
  52627. return mount.call(this, el, hydrating)
  52628. };
  52629. /**
  52630. * Get outerHTML of elements, taking care
  52631. * of SVG elements in IE as well.
  52632. */
  52633. function getOuterHTML (el) {
  52634. if (el.outerHTML) {
  52635. return el.outerHTML
  52636. } else {
  52637. var container = document.createElement('div');
  52638. container.appendChild(el.cloneNode(true));
  52639. return container.innerHTML
  52640. }
  52641. }
  52642. Vue.compile = compileToFunctions;
  52643. module.exports = Vue;
  52644. /* 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))
  52645. /***/ }),
  52646. /***/ "./node_modules/vue/dist/vue.common.js":
  52647. /*!*********************************************!*\
  52648. !*** ./node_modules/vue/dist/vue.common.js ***!
  52649. \*********************************************/
  52650. /*! no static exports found */
  52651. /***/ (function(module, exports, __webpack_require__) {
  52652. if (false) {} else {
  52653. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52654. }
  52655. /***/ }),
  52656. /***/ "./node_modules/webpack/buildin/global.js":
  52657. /*!***********************************!*\
  52658. !*** (webpack)/buildin/global.js ***!
  52659. \***********************************/
  52660. /*! no static exports found */
  52661. /***/ (function(module, exports) {
  52662. var g;
  52663. // This works in non-strict mode
  52664. g = (function() {
  52665. return this;
  52666. })();
  52667. try {
  52668. // This works if eval is allowed (see CSP)
  52669. g = g || new Function("return this")();
  52670. } catch (e) {
  52671. // This works if the window reference is available
  52672. if (typeof window === "object") g = window;
  52673. }
  52674. // g can still be undefined, but nothing to do about it...
  52675. // We return undefined, instead of nothing here, so it's
  52676. // easier to handle this case. if(!global) { ...}
  52677. module.exports = g;
  52678. /***/ }),
  52679. /***/ "./node_modules/webpack/buildin/module.js":
  52680. /*!***********************************!*\
  52681. !*** (webpack)/buildin/module.js ***!
  52682. \***********************************/
  52683. /*! no static exports found */
  52684. /***/ (function(module, exports) {
  52685. module.exports = function(module) {
  52686. if (!module.webpackPolyfill) {
  52687. module.deprecate = function() {};
  52688. module.paths = [];
  52689. // module.parent = undefined by default
  52690. if (!module.children) module.children = [];
  52691. Object.defineProperty(module, "loaded", {
  52692. enumerable: true,
  52693. get: function() {
  52694. return module.l;
  52695. }
  52696. });
  52697. Object.defineProperty(module, "id", {
  52698. enumerable: true,
  52699. get: function() {
  52700. return module.i;
  52701. }
  52702. });
  52703. module.webpackPolyfill = 1;
  52704. }
  52705. return module;
  52706. };
  52707. /***/ }),
  52708. /***/ "./resources/js/app.js":
  52709. /*!*****************************!*\
  52710. !*** ./resources/js/app.js ***!
  52711. \*****************************/
  52712. /*! no static exports found */
  52713. /***/ (function(module, exports, __webpack_require__) {
  52714. /**
  52715. * First we will load all of this project's JavaScript dependencies which
  52716. * includes Vue and other libraries. It is a great starting point when
  52717. * building robust, powerful web applications using Vue and Laravel.
  52718. */
  52719. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52720. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52721. /**
  52722. * The following block of code may be used to automatically register your
  52723. * Vue components. It will recursively scan this directory for the Vue
  52724. * components and automatically register them with their "basename".
  52725. *
  52726. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52727. */
  52728. // const files = require.context('./', true, /\.vue$/i)
  52729. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52730. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52731. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  52732. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  52733. /**
  52734. * Next, we will create a fresh Vue application instance and attach it to
  52735. * the page. Then, you may begin adding components to this application
  52736. * or customize the JavaScript scaffolding to fit your unique needs.
  52737. */
  52738. var app = new Vue({
  52739. el: '#app'
  52740. });
  52741. $(function () {
  52742. $('[data-toggle="tooltip"]').tooltip();
  52743. });
  52744. /***/ }),
  52745. /***/ "./resources/js/bootstrap.js":
  52746. /*!***********************************!*\
  52747. !*** ./resources/js/bootstrap.js ***!
  52748. \***********************************/
  52749. /*! no exports provided */
  52750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52751. "use strict";
  52752. __webpack_require__.r(__webpack_exports__);
  52753. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52754. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52755. /**
  52756. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52757. * for JavaScript based Bootstrap features such as modals and tabs. This
  52758. * code may be modified to fit the specific needs of your application.
  52759. */
  52760. try {
  52761. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52762. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52763. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52764. } catch (e) {}
  52765. /**
  52766. * We'll load the axios HTTP library which allows us to easily issue requests
  52767. * to our Laravel back-end. This library automatically handles sending the
  52768. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52769. */
  52770. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52771. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52772. /**
  52773. * Echo exposes an expressive API for subscribing to channels and listening
  52774. * for events that are broadcast by Laravel. Echo and event broadcasting
  52775. * allows your team to easily build robust real-time web applications.
  52776. */
  52777. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52778. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52779. broadcaster: 'pusher',
  52780. key: "upccrt",
  52781. wsHost: window.location.hostname,
  52782. wsPort: 6001,
  52783. disableStats: true
  52784. });
  52785. /***/ }),
  52786. /***/ "./resources/js/components/ExampleComponent.vue":
  52787. /*!******************************************************!*\
  52788. !*** ./resources/js/components/ExampleComponent.vue ***!
  52789. \******************************************************/
  52790. /*! exports provided: default */
  52791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52792. "use strict";
  52793. __webpack_require__.r(__webpack_exports__);
  52794. /* 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&");
  52795. /* 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&");
  52796. /* 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");
  52797. /* normalize component */
  52798. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52799. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52800. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52801. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52802. false,
  52803. null,
  52804. null,
  52805. null
  52806. )
  52807. /* hot reload */
  52808. if (false) { var api; }
  52809. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52810. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52811. /***/ }),
  52812. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52813. /*!*******************************************************************************!*\
  52814. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52815. \*******************************************************************************/
  52816. /*! exports provided: default */
  52817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52818. "use strict";
  52819. __webpack_require__.r(__webpack_exports__);
  52820. /* 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&");
  52821. /* 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"]);
  52822. /***/ }),
  52823. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52824. /*!*************************************************************************************!*\
  52825. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52826. \*************************************************************************************/
  52827. /*! exports provided: render, staticRenderFns */
  52828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52829. "use strict";
  52830. __webpack_require__.r(__webpack_exports__);
  52831. /* 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&");
  52832. /* 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"]; });
  52833. /* 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"]; });
  52834. /***/ }),
  52835. /***/ "./resources/js/components/assetinfo.vue":
  52836. /*!***********************************************!*\
  52837. !*** ./resources/js/components/assetinfo.vue ***!
  52838. \***********************************************/
  52839. /*! exports provided: default */
  52840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52841. "use strict";
  52842. __webpack_require__.r(__webpack_exports__);
  52843. /* 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&");
  52844. /* 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&");
  52845. /* 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");
  52846. /* normalize component */
  52847. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52848. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52849. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  52850. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52851. false,
  52852. null,
  52853. null,
  52854. null
  52855. )
  52856. /* hot reload */
  52857. if (false) { var api; }
  52858. component.options.__file = "resources/js/components/assetinfo.vue"
  52859. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52860. /***/ }),
  52861. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  52862. /*!************************************************************************!*\
  52863. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  52864. \************************************************************************/
  52865. /*! exports provided: default */
  52866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52867. "use strict";
  52868. __webpack_require__.r(__webpack_exports__);
  52869. /* 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&");
  52870. /* 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"]);
  52871. /***/ }),
  52872. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  52873. /*!******************************************************************************!*\
  52874. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  52875. \******************************************************************************/
  52876. /*! exports provided: render, staticRenderFns */
  52877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52878. "use strict";
  52879. __webpack_require__.r(__webpack_exports__);
  52880. /* 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&");
  52881. /* 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"]; });
  52882. /* 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"]; });
  52883. /***/ }),
  52884. /***/ "./resources/js/components/woinfo.vue":
  52885. /*!********************************************!*\
  52886. !*** ./resources/js/components/woinfo.vue ***!
  52887. \********************************************/
  52888. /*! exports provided: default */
  52889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52890. "use strict";
  52891. __webpack_require__.r(__webpack_exports__);
  52892. /* 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&");
  52893. /* 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&");
  52894. /* 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");
  52895. /* normalize component */
  52896. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52897. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52898. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  52899. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52900. false,
  52901. null,
  52902. null,
  52903. null
  52904. )
  52905. /* hot reload */
  52906. if (false) { var api; }
  52907. component.options.__file = "resources/js/components/woinfo.vue"
  52908. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52909. /***/ }),
  52910. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  52911. /*!*********************************************************************!*\
  52912. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  52913. \*********************************************************************/
  52914. /*! exports provided: default */
  52915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52916. "use strict";
  52917. __webpack_require__.r(__webpack_exports__);
  52918. /* 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&");
  52919. /* 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"]);
  52920. /***/ }),
  52921. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  52922. /*!***************************************************************************!*\
  52923. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  52924. \***************************************************************************/
  52925. /*! exports provided: render, staticRenderFns */
  52926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52927. "use strict";
  52928. __webpack_require__.r(__webpack_exports__);
  52929. /* 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&");
  52930. /* 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"]; });
  52931. /* 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"]; });
  52932. /***/ }),
  52933. /***/ "./resources/js/mixins/dateMixin.js":
  52934. /*!******************************************!*\
  52935. !*** ./resources/js/mixins/dateMixin.js ***!
  52936. \******************************************/
  52937. /*! exports provided: default */
  52938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52939. "use strict";
  52940. __webpack_require__.r(__webpack_exports__);
  52941. /* harmony default export */ __webpack_exports__["default"] = ({
  52942. methods: {
  52943. treatAsUTC: function treatAsUTC(date) {
  52944. var result = new Date(date);
  52945. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  52946. return result;
  52947. },
  52948. daysSinceToday: function daysSinceToday(date) {
  52949. var currentDate = new Date();
  52950. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  52951. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  52952. },
  52953. getHRDate: function getHRDate(dateString) {
  52954. var date = new Date(dateString);
  52955. var year = date.getFullYear();
  52956. var month = date.toLocaleString('default', {
  52957. month: 'short'
  52958. });
  52959. var day = date.getDate();
  52960. var hour = date.getHours() % 12;
  52961. var minute = date.getMinutes();
  52962. var period = date.getHours() < 24 ? 'AM' : 'PM';
  52963. return month + " " + day + ", " + year + " " + hour + ":" + minute + " " + period;
  52964. },
  52965. isZero: function isZero(dateString) {
  52966. return dateString === '0000-00-00 00:00:00';
  52967. }
  52968. }
  52969. });
  52970. /***/ }),
  52971. /***/ "./resources/sass/app.scss":
  52972. /*!*********************************!*\
  52973. !*** ./resources/sass/app.scss ***!
  52974. \*********************************/
  52975. /*! no static exports found */
  52976. /***/ (function(module, exports) {
  52977. // removed by extract-text-webpack-plugin
  52978. /***/ }),
  52979. /***/ 0:
  52980. /*!*************************************************************!*\
  52981. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  52982. \*************************************************************/
  52983. /*! no static exports found */
  52984. /***/ (function(module, exports, __webpack_require__) {
  52985. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  52986. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  52987. /***/ })
  52988. /******/ });